working dos vga writes!
This commit is contained in:
1 parent
5789cafd4e
commit
55ac075e4d
25 files changed
+454
-149
No files matched your search
@@ -0,0 +1,3 @@
|
||||
/*
|
||||
https://gist.github.com/takaswie/d8a9553c230971d974a3dfc759b2ff67
|
||||
*/
|
||||
+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};
|
||||
|
||||
+22
-16
@@ -126,9 +126,11 @@ static bool plr_x11_handshake(com_std_fd xfd,
|
||||
if (!com_std_write(xfd, AUTH_ENTRY_MAGIC_COOKIE,
|
||||
sizeof AUTH_ENTRY_MAGIC_COOKIE - 1))
|
||||
return false;
|
||||
/* Use 2 bytes back for padding. */
|
||||
if (!com_std_write(xfd, &auth_entry.auth_data->data[-2],
|
||||
auth_entry.auth_data->len + 2))
|
||||
/* 2 bytes padding after magic cookie. */
|
||||
if (!com_std_write(xfd, &request, 2))
|
||||
return false;
|
||||
if (!com_std_write(xfd, auth_entry.auth_data->data,
|
||||
auth_entry.auth_data->len))
|
||||
return false;
|
||||
|
||||
struct {
|
||||
@@ -293,8 +295,8 @@ static uint32_t plr_x11_create_graphical_context(com_std_fd xfd) {
|
||||
|
||||
static uint32_t plr_x11_create_window(com_std_fd xfd) {
|
||||
/* TODO: Use the ones provided in headers ? */
|
||||
#define FLAG_WIN_BG_PIXEL 2
|
||||
#define FLAG_WIN_EVENT 0x800
|
||||
#define FLAG_WIN_BG_PIXEL 0x0002
|
||||
#define FLAG_WIN_EVENT 0x0800
|
||||
#define EVENT_FLAG_EXPOSURE 0x8000
|
||||
#define EVENT_FLAG_KEY_PRESS 0x1
|
||||
#define EVENT_FLAG_KEY_RELEASE 0x2
|
||||
@@ -331,7 +333,7 @@ static uint32_t plr_x11_create_window(com_std_fd xfd) {
|
||||
.class = 1,
|
||||
.root_visual_id = plr_x11_root_screen.root_visual_id,
|
||||
.bitmask = FLAG_WIN_BG_PIXEL | FLAG_WIN_EVENT,
|
||||
.value1 = 0x00000000,
|
||||
.value1 = 0xff000000,
|
||||
.value2 = EVENT_FLAG_EXPOSURE | EVENT_FLAG_BUTTON_RELEASE |
|
||||
EVENT_FLAG_BUTTON_PRESS | EVENT_FLAG_KEY_PRESS |
|
||||
EVENT_FLAG_KEY_RELEASE,
|
||||
@@ -419,6 +421,10 @@ static uint8_t plr_x11_query_extension(com_std_fd xfd, com_str const *ext) {
|
||||
static bool plr_x11_enable_big_requests(com_std_fd xfd) {
|
||||
static com_str bigreqext = com_str_lit("BIG-REQUESTS");
|
||||
uint8_t const opcode = plr_x11_query_extension(xfd, &bigreqext);
|
||||
if (!opcode) {
|
||||
com_std_print('c', "Big request can't accommodate for framebuffer.");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Request the thing. */
|
||||
struct {
|
||||
@@ -439,8 +445,8 @@ static bool plr_x11_enable_big_requests(com_std_fd xfd) {
|
||||
plr_x11_poll_reply(xfd, seq, &response);
|
||||
|
||||
uint32_t const limit = *(uint32_t *)response.reply.pad;
|
||||
com_std_print('c', "Request limit: ", 'u', limit);
|
||||
if (limit < COM_CFG_FBSIZE) {
|
||||
com_std_print('c', "X11 request limit: ", 'u', limit);
|
||||
if (limit < COM_CFG_FBSIZE / 4) {
|
||||
com_std_print('c', "Big request can't accommodate for framebuffer.");
|
||||
return false;
|
||||
}
|
||||
@@ -449,7 +455,7 @@ static bool plr_x11_enable_big_requests(com_std_fd xfd) {
|
||||
}
|
||||
|
||||
static bool plr_x11_put_framebuffer(com_std_fd xfd, uint32_t gc_id,
|
||||
uint32_t pixmap_id,
|
||||
uint32_t drawable_id,
|
||||
uint8_t pixels[COM_CFG_FBSIZE]) {
|
||||
uint32_t const padded = com_bits_nalign(COM_CFG_FBSIZE, 4);
|
||||
uint32_t const seq = plr_x11_next_seqid();
|
||||
@@ -472,7 +478,7 @@ static bool plr_x11_put_framebuffer(com_std_fd xfd, uint32_t gc_id,
|
||||
.opcode = 72,
|
||||
.format = 2, // ZPixmap
|
||||
.request_length = sizeof request / 4 + padded / 4,
|
||||
.drawable_id = pixmap_id,
|
||||
.drawable_id = drawable_id,
|
||||
.gc_id = gc_id,
|
||||
.width = COM_CFG_WIDTH,
|
||||
.height = COM_CFG_HEIGHT,
|
||||
@@ -600,11 +606,11 @@ extern int plr_display_x11_main(int argc, char const *const *argv) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint32_t const fb = plr_x11_create_pixmap(xfd, win);
|
||||
if (!fb) {
|
||||
com_std_print('c', "Failure to initialize X11");
|
||||
return -1;
|
||||
}
|
||||
// uint32_t const fb = plr_x11_create_pixmap(xfd, win);
|
||||
// if (!fb) {
|
||||
// com_std_print('c', "Failure to initialize X11");
|
||||
// return -1;
|
||||
// }
|
||||
|
||||
// Display *display = XOpenDisplay(NULL);
|
||||
// if (NULL == display) {
|
||||
@@ -704,7 +710,7 @@ extern int plr_display_x11_main(int argc, char const *const *argv) {
|
||||
uint8_t *fbm = plr_draw_get_pixel_buffer();
|
||||
plr_draw_screen(fbm);
|
||||
|
||||
if (!plr_x11_put_framebuffer(xfd, gc, fb, fbm)) {
|
||||
if (!plr_x11_put_framebuffer(xfd, gc, win, fbm)) {
|
||||
com_std_print('c', "Failure to drive X11");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
.section .data
|
||||
.align 4
|
||||
# TODO: Make sure it's placed under 1 MiB.
|
||||
# The DPMI Register Structure (50 bytes total)
|
||||
# This holds the register states injected into Real Mode.
|
||||
|
||||
.section .text
|
||||
.global _start
|
||||
|
||||
Whitespace-only changes.
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
Inter-process communicating socket, useful for local testing and admin
|
||||
playing.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#define MAXBUFFSIZE 4194304 /* 4.0MiB */
|
||||
|
||||
int plr_socket_unix_try_connect(const char *filepath) {
|
||||
int sock = 0;
|
||||
|
||||
if ((sock = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
|
||||
perror("Error creating client UNIX socket: ");
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct sockaddr_un remote = {0};
|
||||
remote.sun_family = AF_UNIX;
|
||||
strcpy(remote.sun_path, filepath);
|
||||
int const remote_len = SUN_LEN(&remote);
|
||||
|
||||
return 0;
|
||||
}
|
||||
+4
-7
@@ -6,29 +6,26 @@ We do not use abstractions, as the simplicity of the required set of features sh
|
||||
---- Restrictions ----
|
||||
* Fixed sized paletted frambuffer, defaulted to 640x480.
|
||||
* Deterministic logic via Q15.16 fixed point numbers.
|
||||
* .gam image format, derived from .gif. RLE and Delta Frame Optimiztion is added, palette is predefined.
|
||||
* .gam image format, derived from .gif. Palette is globally predefined.
|
||||
* Textures are 32x32 pixels.
|
||||
* 30 FPS display rate.
|
||||
* Fonts are in ASCII bitmaps. Tile slicing commands are issued to render them in.
|
||||
* Audio samples are in our own .sam format (s8 frame delta + lzw).
|
||||
* Audio samples are in our own .sam format (s8 + ulaw + lzw).
|
||||
* Music pieces are written in our own simple .tam tracker format, using the same .sam sample db.
|
||||
* Connections are over TCP and their supersets (like WebSocket).
|
||||
* Textbox provides another client-controlled view, with history.
|
||||
* Content usage has to be predefined, to allow preloading and compilation.
|
||||
|
||||
|
||||
---- Building ----
|
||||
==== DOS ====
|
||||
Open Watcom 2.0 32bit toolchain is used under Linux host.
|
||||
Place a copy of DOS4GW.EXE alongside the executable.
|
||||
Expect to need to configure $INCLUDE and $LIB variables.
|
||||
Nothing is needed. Just compile.
|
||||
|
||||
|
||||
---- .sam format ----
|
||||
Thin sample compressing scheme tailored for use with .tam tracker.
|
||||
Leading and tailing silence is stored as number of frames.
|
||||
Sample data is 1 channel only, but panning can be expressed via graph.
|
||||
Sample bit format is signed 8 bit delta, first frame is delta against 0. Clamping is allowed.
|
||||
Sample bit format is signed 8 bit delta. Clamping is allowed.
|
||||
Generic LZW compression is applied as the last step.
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user