From c5e314048afd1ba3f87204b0655af70f95ae7ab1 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Thu, 8 Jun 2023 21:49:39 +0100 Subject: Set VGA 320x200 256 col at 60Hz --- TODO.md | 3 +-- src/vga.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/TODO.md b/TODO.md index 090b178..a3e7d49 100644 --- a/TODO.md +++ b/TODO.md @@ -1,6 +1,7 @@ # TODO - drawing + - detect VGA - sw blitter - input - joystick? @@ -19,6 +20,4 @@ # REVIEW -- review use of the timer - - tick frequency is 18.2 times per second - use dosemu instead of dosbox? diff --git a/src/vga.c b/src/vga.c index 6665c79..e90ebba 100644 --- a/src/vga.c +++ b/src/vga.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "vga.h" @@ -29,6 +30,33 @@ void set_mode(uint8_t mode) __dpmi_regs regs = { 0 }; regs.x.ax = mode; __dpmi_int(0x10, ®s); + + if (mode == 0x13) + { + /* setup the VGA: 320x200 @ 60Hz */ + /* from: https://gist.github.com/juj/34306e6da02a8a7043e393f01e013f24 */ + disable(); + + /* XXX: probably not neeed */ + wait_vsync(); + + outportw(0x3d4, 0x0011); /* Turn off write protect to CRTC registers */ + outportw(0x3d4, 0x0b06); /* New vertical total=525 lines, bits 0-7 */ + outportw(0x3d4, 0x3e07); /* New vertical total=525 lines, bits 8-9 */ + + outportw(0x3d4, 0xb910); /* Vsync start=scanline 185 */ + outportw(0x3d4, 0x8f12); /* Vertical display end=scanline 399, bits 0-7 */ + outportw(0x3d4, 0xb815); /* Vertical blanking start=scanline 440, bits 0-7 */ + outportw(0x3d4, 0xe216); /* Adjust vblank end position */ + outportw(0x3d4, 0x8511); /* Vsync length=2 lines + turn write protect back on */ + + /* XXX: probably not neeed */ + wait_vsync(); + + outportw(0x3d4, 0x2813); /* 8 pixel chars */ + outportw(0x3d4, 0x8e11); /* restore retrace */ + enable(); + } } void wait_vsync() -- cgit v1.2.3