!ifdef __UNIX__
-dosobj = src/dos/djdpmi.obj src/dos/gfx.obj src/dos/keyb.obj src/dos/logger.obj &
- src/dos/main.obj src/dos/timer.obj src/dos/vbe.obj src/dos/vga.obj src/dos/watdpmi.obj
+dosobj = src/dos/djdpmi.obj src/dos/gfx.obj src/dos/keyb.obj src/dos/main.obj &
+ src/dos/mouse.obj src/dos/vbe.obj src/dos/vga.obj src/dos/watdpmi.obj
appobj = src/app.obj src/cmesh.obj src/darray.obj src/font.obj src/logger.obj &
src/meshgen.obj src/meshload.obj src/options.obj src/rbtree.obj src/rt.obj &
- src/rtk.obj src/scene.obj src/scr_mod.obj src/scr_rend.obj src/util.obj
+ src/rtk.obj src/scene.obj src/scr_mod.obj src/scr_rend.obj src/util.obj &
+ src/util_s.obj src/cpuid.obj src/cpuid_s.obj
gawobj = src/gaw/gaw_sw.obj src/gaw/gawswtnl.obj src/gaw/polyclip.obj src/gaw/polyfill.obj
incpath = -Isrc -Isrc/dos -Ilibs -Ilibs/imago/src -Ilibs/treestor/include -Ilibs/drawtext
libpath = libpath libs/dos
!else
-dosobj = src\dos\djdpmi.obj src\dos\gfx.obj src\dos\keyb.obj src\dos\logger.obj &
- src\dos\main.obj src\dos\timer.obj src\dos\vbe.obj src\dos\vga.obj src\dos\watdpmi.obj
+dosobj = src\dos\djdpmi.obj src\dos\gfx.obj src\dos\keyb.obj src\dos\main.obj &
+ src\dos\mouse.obj src\dos\vbe.obj src\dos\vga.obj src\dos\watdpmi.obj
appobj = src\app.obj src\cmesh.obj src\darray.obj src\font.obj src\logger.obj &
src\meshgen.obj src\meshload.obj src\options.obj src\rbtree.obj src\rt.obj &
- src\rtk.obj src\scene.obj src\scr_mod.obj src\scr_rend.obj src\util.obj
+ src\rtk.obj src\scene.obj src\scr_mod.obj src\scr_rend.obj src\util.obj &
+ src\util_s.obj src\cpuid.obj src\cpuid_s.obj
gawobj = src\gaw\gaw_sw.obj src\gaw\gawswtnl.obj src\gaw\polyclip.obj src\gaw\polyfill.obj
incpath = -Isrc -Isrc\dos -Ilibs -Ilibs\imago\src -Ilibs\treestor\include -Ilibs\drawtext
jpeglib/jidctint.obj jpeglib/jidctred.obj jpeglib/jmemmgr.obj jpeglib/jmemnobs.obj &
jpeglib/jquant1.obj jpeglib/jquant2.obj jpeglib/jutils.obj
obj = src/conv.obj src/filejpeg.obj src/filepng.obj src/fileppm.obj src/filergbe.obj &
- src/filetga.obj src/ftmodule.obj src/imago2.obj src/modules.obj &
- $(libpng) $(zlib) $(jpeglib)
+ src/filetga.obj src/filelbm.obj src/ftmodule.obj src/imago2.obj src/modules.obj &
+ src/byteord.obj $(libpng) $(zlib) $(jpeglib)
alib = ../../imago.lib
!else
jpeglib\jidctint.obj jpeglib\jidctred.obj jpeglib\jmemmgr.obj jpeglib\jmemnobs.obj &
jpeglib\jquant1.obj jpeglib\jquant2.obj jpeglib\jutils.obj
obj = src\conv.obj src\filejpeg.obj src\filepng.obj src\fileppm.obj src\filergbe.obj &
- src\filetga.obj src\ftmodule.obj src\imago2.obj src\modules.obj &
- $(libpng) $(zlib) $(jpeglib)
+ src\filetga.obj src\filelbm.obj src\ftmodule.obj src\imago2.obj src\modules.obj &
+ src\byteord.obj $(libpng) $(zlib) $(jpeglib)
alib = ..\..\imago.lib
!endif
char *start_scr_name;
static rtk_draw_ops guigfx = {gui_fill, gui_blit, gui_drawtext, gui_textrect};
- init_logger();
-
#if !defined(NDEBUG) && defined(DBG_FPEXCEPT)
printf("floating point exceptions enabled\n");
enable_fpexcept();
#include "scene.h"
enum {
+ KEY_BACKSP = 8,
KEY_ESC = 27,
KEY_DEL = 127,
- KEY_F1 = 256,
- KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7,
- KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12,
- KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT,
- KEY_PGUP, KEY_PGDOWN,
- KEY_HOME, KEY_END,
- KEY_INS
+
+ KEY_NUM_0 = 256, KEY_NUM_1, KEY_NUM_2, KEY_NUM_3, KEY_NUM_4,
+ KEY_NUM_5, KEY_NUM_6, KEY_NUM_7, KEY_NUM_8, KEY_NUM_9,
+ KEY_NUM_DOT, KEY_NUM_DIV, KEY_NUM_MUL, KEY_NUM_MINUS, KEY_NUM_PLUS, KEY_NUM_ENTER, KEY_NUM_EQUALS,
+ KEY_UP, KEY_DOWN, KEY_RIGHT, KEY_LEFT,
+ KEY_INS, KEY_HOME, KEY_END, KEY_PGUP, KEY_PGDN,
+ KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6,
+ KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12,
+ KEY_F13, KEY_F14, KEY_F15,
+ KEY_NUMLK, KEY_CAPSLK, KEY_SCRLK,
+ KEY_RSHIFT, KEY_LSHIFT, KEY_RCTRL, KEY_LCTRL, KEY_RALT, KEY_LALT,
+ KEY_RMETA, KEY_LMETA, KEY_LSUPER, KEY_RSUPER, KEY_MODE, KEY_COMPOSE,
+ KEY_HELP, KEY_PRINT, KEY_SYSRQ, KEY_BREAK
};
+#ifndef KEY_ANY
+#define KEY_ANY (-1)
+#define KEY_ALT (-2)
+#define KEY_CTRL (-3)
+#define KEY_SHIFT (-4)
+#endif
+
enum {
KEY_MOD_SHIFT = 1,
KEY_MOD_CTRL = 4,
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include "cpuid.h"
+
+static const char *cpuname(struct cpuid_info *cpu);
+static const char *cpuvendor(struct cpuid_info *cpu);
+
+struct cpuid_info cpuid;
+
+void print_cpuid(struct cpuid_info *cpu)
+{
+ int i, col, len;
+ static const char *featstr[32] = {
+ "fpu", "vme", "dbgext", "pse", "tsc", "msr", "pae", "mce",
+ "cx8", "apic", "?", "sep", "mtrr", "pge", "mca", "cmov",
+ "pat", "pse36", "psn", "clf", "?", "dtes", "acpi", "mmx",
+ "fxsr", "sse", "sse2", "ss", "htt", "tm1", "ia64", "pbe"};
+ static const char *feat2str[32] = {
+ "sse3", "pclmul", "dtes64", "monitor", "ds-cpl", "vmx", "smx", "est",
+ "tm2", "ssse3", "cid", "sdbg", "fma", "cx16", "etprd", "pdcm",
+ "?", "pcid", "dca", "sse41", "sse42", "x2apic", "movbe", "popcnt",
+ "?", "aes", "xsave", "osxsave", "avx", "f16c", "rdrand", "?"};
+
+ printf("CPU: %s - %s\n", cpuvendor(cpu), cpuname(cpu));
+ printf("features:\n ");
+ col = 3;
+ for(i=0; i<32; i++) {
+ if(cpu->feat & (1 << i)) {
+ len = strlen(featstr[i]) + 1;
+ if(col + len >= 80) {
+ fputs("\n ", stdout);
+ col = 3;
+ }
+ col += printf(" %s", featstr[i]);
+ }
+ }
+ for(i=0; i<32; i++) {
+ if(cpu->feat2 & (1 << i)) {
+ len = strlen(feat2str[i]) + 1;
+ if(col + len >= 80) {
+ fputs("\n ", stdout);
+ col = 3;
+ }
+ col += printf(" %s", feat2str[i]);
+ }
+ }
+ putchar('\n');
+}
+
+static const char *fam4_models[16] = {
+ "486 DX 25/33", "486 DX 50", "486 SX", "486 DX/2", "486 SL", "486 SX/2",
+ 0, "486 DX/2-WB", "486 DX/4", "486 DX/4-WB"
+};
+static const char *fam5_models[16] = {
+ "Pentium 60/66", "Pentium 60/66", "Pentium 75-200", "OverDrive", "Pentium MMX",
+ 0, 0, "Mobile Pentium 75-200", "Mobile Pentium MMX", "Quark"
+};
+static const char *fam6_models[16] = {
+ "Pentium Pro", "Pentium Pro", 0, "Pentium 2", "Pentium 2", "Pentium 2",
+ "Mobile Pentium 2", "Pentium 3", "Pentium 3", 0, "Pentium 3", "Pentium 3"
+};
+
+
+static const char *cpuname(struct cpuid_info *cpu)
+{
+ int model, family;
+ char *rd, *wr;
+
+ if(*cpu->brandstr) {
+ /* unwank the string */
+ rd = wr = cpu->brandstr;
+ while(*rd) {
+ if(rd[0] == '(' && rd[1] == 'T' && rd[2] == 'M' && rd[3] == ')')
+ rd += 4;
+ else if(rd[0] == '(' && rd[1] == 'R' && rd[2] == ')')
+ rd += 3;
+ if(rd != wr) *wr = *rd;
+ wr++;
+ rd++;
+ }
+ *wr = 0;
+ return cpu->brandstr;
+ }
+
+ if(CPUID_EXTMODEL(cpu->id)) {
+ /* processors new enough to have an extended model, should also provide
+ * a brand string. If we end up here, we don't know what it is
+ */
+ return "unknown";
+ }
+
+ model = CPUID_MODEL(cpu->id);
+ family = CPUID_FAMILY(cpu->id) | (CPUID_EXTFAMILY(cpu->id) << 4);
+
+ switch(family) {
+ case 3: return "386";
+ case 4: return fam4_models[model] ? fam4_models[model] : "486";
+ case 5: return fam5_models[model] ? fam5_models[model] : "Pentium";
+ case 6: return fam6_models[model] ? fam6_models[model] : "unknown";
+ case 15: return "Pentium 4";
+ default:
+ break;
+ }
+ return "unknown";
+}
+
+static const char *cpuvendor(struct cpuid_info *cpu)
+{
+ static char other[16];
+ static const struct { const char *wank, *vendor; } unwanktab[] = {
+ {"GenuineIntel", "intel"},
+ {"AuthenticAMD", "AMD"},
+ {"AMDisbetter!", "AMD"},
+ {"CentaurHauls", "IDT"},
+ {"CyrixInstead", "Cyrix"},
+ {"TransmetaCPU", "Transmeta"},
+ {"GenuineTMx86", "Transmeta"},
+ {"Geode by NSC", "NatSemi"},
+ {"NexGenDriven", "NexGen"},
+ {"RiseRiseRise", "Rise"},
+ {"SiS SiS SiS ", "SiS"},
+ {"UMC UMC UMC ", "UMC"},
+ {"VIA VIA VIA ", "VIA"},
+ {"Vortex86 SoC", "DM&P"},
+ {" Shanghai ", "Zhaoxin"},
+ {"HygonGenuine", "Hygon"},
+ {"E2K MACHINE", "MCST Elbrus"},
+ {"MiSTer A0486", "ao486"},
+ {"bhyve bhyve ", "bhyve"},
+ {" KVMKVMKVM ", "KVM"},
+ {"TCGTCGTCGTCG", "qemu"},
+ {"Microsoft Hv", "MS Hyper-V"},
+ {" lrpepyh vr", "Parallels"},
+ {"VMwareVMware", "VMware"},
+ {"XenVMMXenVMM", "Xen"},
+ {"ACRNACRNACRN", "ACRN"},
+ {" QNXQVMBSQG ", "QNX Hypervisor"},
+ {0, 0}
+ };
+
+ int i;
+ for(i=0; unwanktab[i].wank; i++) {
+ if(memcmp(cpu->vendor, unwanktab[i].wank, 12) == 0) {
+ return unwanktab[i].vendor;
+ }
+ }
+
+ memcpy(other, cpu->vendor, 12);
+ other[12] = 0;
+ return other;
+}
--- /dev/null
+#ifndef CPUID_H_
+#define CPUID_H_
+
+#include "inttypes.h"
+
+struct cpuid_info {
+ uint32_t maxidx; /* 0: eax */
+ char vendor[12]; /* 0: ebx, edx, ecx */
+ uint32_t id; /* 1: eax */
+ uint32_t rsvd0; /* 1: ebx */
+ uint32_t feat; /* 1: edx */
+ uint32_t feat2; /* 1: ecx */
+
+ char brandstr[48]; /* 80000002h-80000004h */
+};
+
+extern struct cpuid_info cpuid;
+
+#define CPU_HAVE_MMX (cpuid.feat & CPUID_FEAT_MMX)
+#define CPU_HAVE_MTRR (cpuid.feat & CPUID_FEAT_MTRR)
+
+#define CPUID_STEPPING(id) ((id) & 0xf)
+#define CPUID_MODEL(id) (((id) >> 4) & 0xf)
+#define CPUID_FAMILY(id) (((id) >> 8) & 0xf)
+#define CPUID_EXTMODEL(id) (((id) >> 16) & 0xf)
+#define CPUID_EXTFAMILY(id) (((id) >> 20) & 0xff)
+
+#define CPUID_FEAT_FPU 0x00000001
+#define CPUID_FEAT_VME 0x00000002
+#define CPUID_FEAT_DBGEXT 0x00000004
+#define CPUID_FEAT_PSE 0x00000008
+#define CPUID_FEAT_TSC 0x00000010
+#define CPUID_FEAT_MSR 0x00000020
+#define CPUID_FEAT_PAE 0x00000040
+#define CPUID_FEAT_MCE 0x00000080
+#define CPUID_FEAT_CX8 0x00000100
+#define CPUID_FEAT_APIC 0x00000200
+
+#define CPUID_FEAT_SEP 0x00000800
+#define CPUID_FEAT_MTRR 0x00001000
+#define CPUID_FEAT_PGE 0x00002000
+#define CPUID_FEAT_MCA 0x00004000
+#define CPUID_FEAT_CMOV 0x00008000
+#define CPUID_FEAT_PAT 0x00010000
+#define CPUID_FEAT_PSE36 0x00020000
+#define CPUID_FEAT_PSN 0x00040000
+#define CPUID_FEAT_CLF 0x00080000
+
+#define CPUID_FEAT_DTES 0x00200000
+#define CPUID_FEAT_ACPI 0x00400000
+#define CPUID_FEAT_MMX 0x00800000
+#define CPUID_FEAT_FXSR 0x01000000
+#define CPUID_FEAT_SSE 0x02000000
+#define CPUID_FEAT_SSE2 0x04000000
+#define CPUID_FEAT_SS 0x08000000
+#define CPUID_FEAT_HTT 0x10000000
+#define CPUID_FEAT_TM1 0x20000000
+#define CPUID_FEAT_IA64 0x40000000
+#define CPUID_FEAT_PBE 0x80000000
+
+#define CPUID_FEAT2_SSE3 0x00000001
+#define CPUID_FEAT2_PCLMUL 0x00000002
+#define CPUID_FEAT2_DTES64 0x00000004
+#define CPUID_FEAT2_MONITOR 0x00000008
+#define CPUID_FEAT2_DS_CPL 0x00000010
+#define CPUID_FEAT2_VMX 0x00000020
+#define CPUID_FEAT2_SMX 0x00000040
+#define CPUID_FEAT2_EST 0x00000080
+#define CPUID_FEAT2_TM2 0x00000100
+#define CPUID_FEAT2_SSSE3 0x00000200
+#define CPUID_FEAT2_CID 0x00000400
+#define CPUID_FEAT2_SDBG 0x00000800
+#define CPUID_FEAT2_FMA 0x00001000
+#define CPUID_FEAT2_CX16 0x00002000
+#define CPUID_FEAT2_ETPRD 0x00004000
+#define CPUID_FEAT2_PDCM 0x00008000
+
+#define CPUID_FEAT2_PCID 0x00020000
+#define CPUID_FEAT2_DCA 0x00040000
+#define CPUID_FEAT2_SSE41 0x00080000
+#define CPUID_FEAT2_SSE42 0x00100000
+#define CPUID_FEAT2_X2APIC 0x00200000
+#define CPUID_FEAT2_MOVBE 0x00400000
+#define CPUID_FEAT2_POPCNT 0x00800000
+
+#define CPUID_FEAT2_AES 0x02000000
+#define CPUID_FEAT2_XSAVE 0x04000000
+#define CPUID_FEAT2_OSXSAVE 0x08000000
+#define CPUID_FEAT2_AVX 0x10000000
+#define CPUID_FEAT2_F16C 0x20000000
+#define CPUID_FEAT2_RDRAND 0x40000000
+
+int read_cpuid(struct cpuid_info *info);
+void print_cpuid(struct cpuid_info *info);
+
+#endif /* CPUID_H_ */
--- /dev/null
+ section .text
+ bits 32
+; foo_ are watcom functions, _foo are djgpp functions
+
+F_ID equ 0x200000
+
+ global read_cpuid
+ global _read_cpuid
+ global read_cpuid_
+read_cpuid_:
+ push eax
+ call check_cpuid
+ pop eax
+ jnc read_cpuid_nocheck
+ mov eax, -1
+ ret
+
+_read_cpuid:
+read_cpuid:
+ call check_cpuid
+ mov eax, [esp + 4]
+ jnc read_cpuid_nocheck
+ mov eax, -1
+ ret
+
+ ; determine if cpuid is available. avail: cf=0, not avail: cf=1
+check_cpuid:
+ pushf
+ pop eax
+ mov edx, eax ; keep a copy of the original eflags in edx
+ xor eax, F_ID
+ push eax
+ popf
+ pushf
+ pop eax
+ cmp eax, edx
+ clc
+ jnz .noerr
+ stc
+.noerr: ret
+
+ ; enter with the cpuid_info structure pointer in eax
+read_cpuid_nocheck:
+ push ebp
+ mov ebp, esp
+ push ebx
+ push edi
+ push esi
+ push eax ; save the original struct pointer
+ sub esp, 8
+ mov edi, eax ; struct pointer -> edi
+
+ ; clear struct
+ cld
+ push edi
+ mov ecx, (32+48)/4
+ xor eax, eax
+ rep stosd
+ pop edi
+
+ xor eax, eax
+ mov [esp], eax ; current index
+ cpuid
+
+ mov [edi], eax ; maxidx
+ ; clamp to the size of our cpuid_info structure
+ cmp eax, 1
+ jbe .skipclamp
+ mov eax, 1
+.skipclamp:
+ mov [esp + 4], eax ; maximum index
+
+ mov [edi + 4], ebx ; vendor name
+ mov [edi + 8], edx
+ mov [edi + 12], ecx
+ add edi, 16
+
+.loop: mov eax, [esp]
+ inc eax
+ cmp eax, [esp + 4]
+ ja .loopend
+ mov [esp], eax
+ cpuid
+ mov [edi], eax
+ mov [edi + 4], ebx
+ mov [edi + 8], edx
+ mov [edi + 12], ecx
+ add edi, 16
+ jmp .loop
+.loopend:
+ ; try to retrieve the brand string (avail on P4 or newer)
+ mov eax, 80000000h
+ cpuid
+ test eax, 80000000h
+ jz .done ; no extended cpuid functions
+ cmp eax, 80000004h
+ jb .done ; no brand string available
+
+ ; brand string available
+ mov esi, esp ; save esp to esi
+ mov esp, [esp + 8] ; esp <- original struct pointer
+ add esp, 32+48 ; offset to end of brandstr
+ mov eax, 80000004h
+ cpuid
+ push edx
+ push ecx
+ push ebx
+ push eax
+ mov eax, 80000003h
+ cpuid
+ push edx
+ push ecx
+ push ebx
+ push eax
+ mov eax, 80000002h
+ cpuid
+ push edx
+ push ecx
+ push ebx
+ push eax
+ mov esp, esi ; done restore esp
+
+.done: add esp, 8
+ pop eax
+ pop esi
+ pop edi
+ pop ebx
+ pop ebp
+ xor eax, eax
+ ret
+
+; vi:ft=nasm:
#endif /* __DJGPP__ */
-#include "inttypes.h"
+#include "sizeint.h"
#include "util.h"
#pragma pack (push, 1)
void (*blit_frame)(void*, int);
-extern int dblsize;
-
static void blit_frame_lfb(void *pixels, int vsync);
static void blit_frame_banked(void *pixels, int vsync);
-static void blit_frame_lfb_2x(void *pixels, int vsync);
-static void blit_frame_banked_2x(void *pixels, int vsync);
static uint32_t calc_mask(int sz, int pos);
static void enable_wrcomb(uint32_t addr, int len);
vpgaddr[1] = 0;
}
- blit_frame = dblsize ? blit_frame_lfb_2x : blit_frame_lfb;
+ blit_frame = blit_frame_lfb;
/* only attempt to set up write combining if the CPU we're running on
* supports memory type range registers, and we're running on ring 0
vpgaddr[0] = VMEM_PTR;
vpgaddr[1] = 0;
- blit_frame = dblsize ? blit_frame_banked_2x : blit_frame_banked;
+ blit_frame = blit_frame_banked;
/* calculate window granularity shift */
vm->win_gran_shift = 0;
}
/* allocate main memory framebuffer */
+ /*
if(demo_resizefb(vm->xsz, vm->ysz, vm->bpp) == -1) {
fprintf(stderr, "failed to allocate %dx%d (%d bpp) framebuffer\n", vm->xsz,
vm->ysz, vm->bpp);
set_text_mode();
return 0;
}
+ */
fflush(stdout);
return vpgaddr[0];
static void blit_frame_lfb(void *pixels, int vsync)
{
- demo_post_draw(pixels);
-
if(vsync) wait_vsync();
- memcpy64(vpgaddr[frontidx], pixels, pgsize >> 3);
+ memcpy(vpgaddr[frontidx], pixels, pgsize);
}
static void blit_frame_banked(void *pixels, int vsync)
int sz, offs, pending;
unsigned char *pptr = pixels;
- demo_post_draw(pixels);
-
- if(vsync) wait_vsync();
-
- /* assume initial window offset at 0 */
- offs = 0;
- pending = pgsize;
- while(pending > 0) {
- sz = pending > 65536 ? 65536 : pending;
- /*memcpy64(VMEM_PTR, pptr, sz >> 3);*/
- memcpy(VMEM_PTR, pptr, sz);
- pptr += sz;
- pending -= sz;
- offs += curmode->win_64k_step;
- vbe_setwin(0, offs);
- }
- vbe_setwin(0, 0);
-}
-
-static void blit_frame_lfb_2x(void *pixels, int vsync)
-{
- demo_post_draw(pixels);
-
- if(vsync) wait_vsync();
- memcpy64(vpgaddr[frontidx], pixels, pgsize >> 3);
-}
-
-static void blit_frame_banked_2x(void *pixels, int vsync)
-{
- int sz, offs, pending;
- unsigned char *pptr = pixels;
-
- demo_post_draw(pixels);
-
if(vsync) wait_vsync();
/* assume initial window offset at 0 */
pending = pgsize;
while(pending > 0) {
sz = pending > 65536 ? 65536 : pending;
- /*memcpy64(VMEM_PTR, pptr, sz >> 3);*/
memcpy(VMEM_PTR, pptr, sz);
pptr += sz;
pending -= sz;
#include "keyb.h"
#include "scancode.h"
-#include "inttypes.h"
+#include "sizeint.h"
#include "dosutil.h"
-#define KB_INTR 0x9
-#define KB_PORT 0x60
+#define KEY_INTR 0x9
+#define KEY_PORT 0x60
#define PIC1_CMD_PORT 0x20
#define OCW2_EOI (1 << 5)
/* set our interrupt handler */
_disable();
#ifdef __WATCOMC__
- prev_handler = _dos_getvect(KB_INTR);
- _dos_setvect(KB_INTR, kbintr);
+ prev_handler = _dos_getvect(KEY_INTR);
+ _dos_setvect(KEY_INTR, kbintr);
#endif
#ifdef __DJGPP__
- _go32_dpmi_get_protected_mode_interrupt_vector(KB_INTR, &prev_intr);
+ _go32_dpmi_get_protected_mode_interrupt_vector(KEY_INTR, &prev_intr);
intr.pm_offset = (intptr_t)kbintr;
intr.pm_selector = _go32_my_cs();
_go32_dpmi_allocate_iret_wrapper(&intr);
- _go32_dpmi_set_protected_mode_interrupt_vector(KB_INTR, &intr);
+ _go32_dpmi_set_protected_mode_interrupt_vector(KEY_INTR, &intr);
#endif
_enable();
/* restore the original interrupt handler */
_disable();
#ifdef __WATCOMC__
- _dos_setvect(KB_INTR, prev_handler);
+ _dos_setvect(KEY_INTR, prev_handler);
#endif
#ifdef __DJGPP__
- _go32_dpmi_set_protected_mode_interrupt_vector(KB_INTR, &prev_intr);
+ _go32_dpmi_set_protected_mode_interrupt_vector(KEY_INTR, &prev_intr);
_go32_dpmi_free_iret_wrapper(&intr);
#endif
_enable();
int kb_isdown(int key)
{
switch(key) {
- case KB_ANY:
+ case KEY_ANY:
return num_pressed;
- case KB_ALT:
- return keystate[KB_LALT] + keystate[KB_RALT];
+ case KEY_ALT:
+ return keystate[KEY_LALT] + keystate[KEY_RALT];
- case KB_CTRL:
- return keystate[KB_LCTRL] + keystate[KB_RCTRL];
+ case KEY_CTRL:
+ return keystate[KEY_LCTRL] + keystate[KEY_RCTRL];
}
if(isalpha(key)) {
int key, c, press;
static int ext;
- code = inp(KB_PORT);
+ code = inp(KEY_PORT);
if(code == 0xe0) {
ext = 1;
ext = 0;
} else {
key = scantbl[code];
- c = (keystate[KB_LSHIFT] | keystate[KB_RSHIFT]) ? scantbl_shift[code] : key;
+ c = (keystate[KEY_LSHIFT] | keystate[KEY_RSHIFT]) ? scantbl_shift[code] : key;
}
if(press) {
+++ /dev/null
-#include <stdio.h>
-#include <string.h>
-#include <stdarg.h>
-#include <errno.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include "logger.h"
-#include "util.h"
-
-#ifdef __WATCOMC__
-#include <i86.h>
-#endif
-#ifdef __DJGPP__
-#include <pc.h>
-#endif
-
-void ser_putchar(int c);
-void ser_puts(const char *s);
-void ser_printf(const char *fmt, ...);
-
-static int setup_serial(int sdev);
-
-static int logfd = -1, orig_fd1 = -1;
-static int log_isfile;
-
-int init_logger(const char *fname)
-{
- int sdev;
-
- if(logfd != -1) return -1;
-
- log_isfile = 0;
- if(strcasecmp(fname, "CON") == 0) {
- return 0;
- }
-
- if((logfd = open(fname, O_CREAT | O_WRONLY | O_TRUNC, 0644)) == -1) {
- fprintf(stderr, "init_logger: failed to open %s: %s\n", fname, strerror(errno));
- return -1;
- }
-
- if(sscanf(fname, "COM%d", &sdev) == 1) {
- setup_serial(sdev - 1);
- } else {
- log_isfile = 1;
- }
-
- orig_fd1 = dup(1);
- close(1);
- close(2);
- dup(logfd);
- dup(logfd);
- return 0;
-}
-
-void stop_logger(void)
-{
- if(logfd >= 0) {
- close(logfd);
- logfd = -1;
- }
- if(orig_fd1 >= 0) {
- close(1);
- close(2);
- dup(orig_fd1);
- dup(orig_fd1);
- orig_fd1 = -1;
-
- freopen("CON", "w", stdout);
- freopen("CON", "w", stderr);
- }
-}
-
-int print_tail(const char *fname)
-{
- FILE *fp;
- char buf[512];
- long lineoffs[16];
- int c, nlines;
-
- if(!log_isfile) return 0;
-
- printf("demo_abort called. see demo.log for details. Last lines:\n\n");
-
- if(!(fp = fopen(fname, "rb"))) {
- return -1;
- }
- nlines = 0;
- lineoffs[nlines++] = 0;
- while(fgets(buf, sizeof buf, fp)) {
- lineoffs[nlines & 0xf] = ftell(fp);
- nlines++;
- }
-
- if(nlines > 16) {
- long offs = lineoffs[nlines & 0xf];
- fseek(fp, offs, SEEK_SET);
- }
- while((c = fgetc(fp)) != -1) {
- fputc(c, stdout);
- }
- fclose(fp);
- return 0;
-}
-
-#define UART1_BASE 0x3f8
-#define UART2_BASE 0x2f8
-
-#define UART_DATA 0
-#define UART_DIVLO 0
-#define UART_DIVHI 1
-#define UART_FIFO 2
-#define UART_LCTL 3
-#define UART_MCTL 4
-#define UART_LSTAT 5
-
-#define DIV_9600 (115200 / 9600)
-#define DIV_38400 (115200 / 38400)
-#define LCTL_8N1 0x03
-#define LCTL_DLAB 0x80
-#define FIFO_ENABLE_CLEAR 0x07
-#define MCTL_DTR_RTS_OUT2 0x0b
-#define LST_TRIG_EMPTY 0x20
-
-static unsigned int iobase;
-
-static int setup_serial(int sdev)
-{
- if(sdev < 0 || sdev > 1) {
- return -1;
- }
- iobase = sdev == 0 ? UART1_BASE : UART2_BASE;
-
- /* set clock divisor */
- outp(iobase | UART_LCTL, LCTL_DLAB);
- outp(iobase | UART_DIVLO, DIV_9600 & 0xff);
- outp(iobase | UART_DIVHI, DIV_9600 >> 8);
- /* set format 8n1 */
- outp(iobase | UART_LCTL, LCTL_8N1);
- /* assert RTS and DTR */
- outp(iobase | UART_MCTL, MCTL_DTR_RTS_OUT2);
- return 0;
-}
-
-void ser_putchar(int c)
-{
- if(c == '\n') {
- ser_putchar('\r');
- }
-
- while((inp(iobase | UART_LSTAT) & LST_TRIG_EMPTY) == 0);
- outp(iobase | UART_DATA, c);
-}
-
-void ser_puts(const char *s)
-{
- while(*s) {
- ser_putchar(*s++);
- }
-}
-
-void ser_printf(const char *fmt, ...)
-{
- va_list ap;
- char buf[512];
-
- va_start(ap, fmt);
- vsprintf(buf, fmt, ap);
- va_end(ap);
-
- ser_puts(buf);
-}
+++ /dev/null
-#ifndef LOGGER_H_
-#define LOGGER_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int init_logger(const char *fname);
-void stop_logger(void);
-
-int print_tail(const char *fname);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LOGGER_H_ */
#include "gfx.h"
#include "cdpmi.h"
#include "mouse.h"
+#include "logger.h"
#include "options.h"
+#include "cpuid.h"
static uint32_t *vmem;
static int quit, disp_pending;
__djgpp_nearptr_enable();
#endif
+ init_logger();
+
+ if(read_cpuid(&cpuid) == 0) {
+ print_cpuid(&cpuid);
+ }
+
kb_init(32);
if(!have_mouse()) {
set_mouse_limits(0, 0, 639, 479);
set_mouse(320, 240);
+ add_log_file("retroray.log");
+
if(init_video() == -1) {
return 1;
}
--- /dev/null
+; vi:set filetype=nasm:
+; foo_ are watcom functions, _foo are djgpp functions
+
+QUERY equ 0
+SHOW equ 1
+HIDE equ 2
+READ equ 3
+WRITE equ 4
+PIXRATE equ 15
+XLIM equ 7
+YLIM equ 8
+
+PUSHA_EAX_OFFS equ 28
+PUSHA_ECX_OFFS equ 20
+PUSHA_EDX_OFFS equ 16
+
+ section .text
+ bits 32
+
+; int have_mouse(void)
+ global have_mouse_
+ global _have_mouse
+have_mouse_:
+_have_mouse:
+ pusha
+ mov ax, QUERY
+ int 0x33
+ and eax, 0xffff
+ mov [esp + PUSHA_EAX_OFFS], eax
+ popa
+ ret
+
+; void show_mouse(int show)
+ global show_mouse_
+show_mouse_:
+ pusha
+ test ax, ax
+ mov ax, HIDE
+ jz .skip
+ mov ax, SHOW
+.skip: int 0x33
+ popa
+ ret
+
+ global _show_mouse
+_show_mouse:
+ push ebp
+ mov ebp, esp
+ push ebx
+ push esi
+ push edi
+ mov ax, [ebp + 8]
+ test ax, ax
+ mov ax, HIDE
+ jz .skip
+ mov ax, SHOW
+.skip: int 0x33
+ pop edi
+ pop esi
+ pop ebx
+ pop ebp
+ ret
+
+; int read_mouse(int *xp, int *yp)
+ global read_mouse_
+read_mouse_:
+ pusha
+ mov esi, eax ; xp
+ mov edi, edx ; yp
+ mov ax, READ
+ int 0x33
+ xor eax, eax
+ and ecx, 0xffff
+ and edx, 0xffff
+ mov ax, bx
+ mov [esp + PUSHA_EAX_OFFS], eax
+ mov [esi], ecx
+ mov [edi], edx
+ popa
+ ret
+
+ global _read_mouse
+_read_mouse:
+ push ebp
+ mov ebp, esp
+ push ebx
+ push esi
+ push edi
+ mov ax, READ
+ int 0x33
+ xor eax, eax
+ mov ax, bx
+ and ecx, 0xffff
+ mov ebx, [ebp + 8]
+ mov [ebx], ecx
+ and edx, 0xffff
+ mov ebx, [ebp + 12]
+ mov [ebx], edx
+ pop edi
+ pop esi
+ pop ebx
+ pop ebp
+ ret
+
+; void set_mouse(int x, int y)
+ global set_mouse_
+set_mouse_:
+ pusha
+ mov cx, ax
+ mov ax, WRITE
+ int 0x33
+ popa
+ ret
+
+ global _set_mouse
+_set_mouse:
+ push ebp
+ mov ebp, esp
+ push ebx
+ push esi
+ push edi
+ mov ax, WRITE
+ mov cx, [ebp + 8]
+ mov dx, [ebp + 12]
+ int 0x33
+ pop edi
+ pop esi
+ pop ebx
+ pop ebp
+ ret
+
+; void set_mouse_limits(int xmin, int ymin, int xmax, int ymax)
+ global set_mouse_limits_
+set_mouse_limits_:
+ pusha
+ mov cx, ax
+ mov dx, bx
+ mov ax, XLIM
+ int 0x33
+ mov ax, YLIM
+ mov cx, [esp + PUSHA_EDX_OFFS]
+ mov dx, [esp + PUSHA_ECX_OFFS]
+ int 0x33
+ popa
+ ret
+
+ global _set_mouse_limits
+_set_mouse_limits:
+ push ebp
+ mov ebp, esp
+ push ebx
+ push esi
+ push edi
+ mov ax, XLIM
+ mov cx, [ebp + 8]
+ mov dx, [ebp + 16]
+ int 0x33
+ mov ax, YLIM
+ mov cx, [ebp + 12]
+ mov dx, [ebp + 20]
+ int 0x33
+ pop edi
+ pop esi
+ pop ebx
+ pop ebp
+ ret
+
+; void set_mouse_rate(int xrate, int yrate)
+ global set_mouse_rate_
+set_mouse_rate_:
+ pusha
+ mov cx, ax
+ mov ax, PIXRATE
+ int 0x33
+ popa
+ ret
+
+ global _set_mouse_rate
+_set_mouse_rate:
+ push ebp
+ mov ebp, esp
+ push ebx
+ push esi
+ push edi
+ mov ax, PIXRATE
+ mov cx, [esp + 4]
+ mov dx, [esp + 8]
+ int 0x33
+ pop edi
+ pop esi
+ pop ebx
+ pop ebp
+ ret
/* table with rough translations from set 1 scancodes to ASCII-ish */
static int scantbl[] = {
- 0, KB_ESC, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '\b', /* 0 - e */
+ 0, KEY_ESC, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '\b', /* 0 - e */
'\t', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', /* f - 1c */
- KB_LCTRL, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`', /* 1d - 29 */
- KB_LSHIFT, '\\', 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', KB_RSHIFT, /* 2a - 36 */
- KB_NUM_MUL, KB_LALT, ' ', KB_CAPSLK, KB_F1, KB_F2, KB_F3, KB_F4, KB_F5, KB_F6, KB_F7, KB_F8, KB_F9, KB_F10, /* 37 - 44 */
- KB_NUMLK, KB_SCRLK, KB_NUM_7, KB_NUM_8, KB_NUM_9, KB_NUM_MINUS, KB_NUM_4, KB_NUM_5, KB_NUM_6, KB_NUM_PLUS, /* 45 - 4e */
- KB_NUM_1, KB_NUM_2, KB_NUM_3, KB_NUM_0, KB_NUM_DOT, KB_SYSRQ, 0, 0, KB_F11, KB_F12, /* 4d - 58 */
+ KEY_LCTRL, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`', /* 1d - 29 */
+ KEY_LSHIFT, '\\', 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', KEY_RSHIFT, /* 2a - 36 */
+ KEY_NUM_MUL, KEY_LALT, ' ', KEY_CAPSLK, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, /* 37 - 44 */
+ KEY_NUMLK, KEY_SCRLK, KEY_NUM_7, KEY_NUM_8, KEY_NUM_9, KEY_NUM_MINUS, KEY_NUM_4, KEY_NUM_5, KEY_NUM_6, KEY_NUM_PLUS, /* 45 - 4e */
+ KEY_NUM_1, KEY_NUM_2, KEY_NUM_3, KEY_NUM_0, KEY_NUM_DOT, KEY_SYSRQ, 0, 0, KEY_F11, KEY_F12, /* 4d - 58 */
0, 0, 0, 0, 0, 0, 0, /* 59 - 5f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 60 - 6f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* 70 - 7f */
};
static int scantbl_shift[] = {
- 0, KB_ESC, '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '\b', /* 0 - e */
+ 0, KEY_ESC, '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '\b', /* 0 - e */
'\t', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', '\n', /* f - 1c */
- KB_LCTRL, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"', '~', /* 1d - 29 */
- KB_LSHIFT, '|', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?', KB_RSHIFT, /* 2a - 36 */
- KB_NUM_MUL, KB_LALT, ' ', KB_CAPSLK, KB_F1, KB_F2, KB_F3, KB_F4, KB_F5, KB_F6, KB_F7, KB_F8, KB_F9, KB_F10, /* 37 - 44 */
- KB_NUMLK, KB_SCRLK, KB_NUM_7, KB_NUM_8, KB_NUM_9, KB_NUM_MINUS, KB_NUM_4, KB_NUM_5, KB_NUM_6, KB_NUM_PLUS, /* 45 - 4e */
- KB_NUM_1, KB_NUM_2, KB_NUM_3, KB_NUM_0, KB_NUM_DOT, KB_SYSRQ, 0, 0, KB_F11, KB_F12, /* 4d - 58 */
+ KEY_LCTRL, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"', '~', /* 1d - 29 */
+ KEY_LSHIFT, '|', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?', KEY_RSHIFT, /* 2a - 36 */
+ KEY_NUM_MUL, KEY_LALT, ' ', KEY_CAPSLK, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, /* 37 - 44 */
+ KEY_NUMLK, KEY_SCRLK, KEY_NUM_7, KEY_NUM_8, KEY_NUM_9, KEY_NUM_MINUS, KEY_NUM_4, KEY_NUM_5, KEY_NUM_6, KEY_NUM_PLUS, /* 45 - 4e */
+ KEY_NUM_1, KEY_NUM_2, KEY_NUM_3, KEY_NUM_0, KEY_NUM_DOT, KEY_SYSRQ, 0, 0, KEY_F11, KEY_F12, /* 4d - 58 */
0, 0, 0, 0, 0, 0, 0, /* 59 - 5f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 60 - 6f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* 70 - 7f */
/* extended scancodes, after the 0xe0 prefix */
static int scantbl_ext[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0 - f */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '\r', KB_RCTRL, 0, 0, /* 10 - 1f */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '\r', KEY_RCTRL, 0, 0, /* 10 - 1f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 20 - 2f */
- 0, 0, 0, 0, 0, KB_NUM_MINUS, 0, KB_SYSRQ, KB_RALT, 0, 0, 0, 0, 0, 0, 0, /* 30 - 3f */
- 0, 0, 0, 0, 0, 0, 0, KB_HOME, KB_UP, KB_PGUP, 0, KB_LEFT, 0, KB_RIGHT, 0, KB_END, /* 40 - 4f */
- KB_DOWN, KB_PGDN, KB_INSERT, KB_DEL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 50 - 5f */
+ 0, 0, 0, 0, 0, KEY_NUM_MINUS, 0, KEY_SYSRQ, KEY_RALT, 0, 0, 0, 0, 0, 0, 0, /* 30 - 3f */
+ 0, 0, 0, 0, 0, 0, 0, KEY_HOME, KEY_UP, KEY_PGUP, 0, KEY_LEFT, 0, KEY_RIGHT, 0, KEY_END, /* 40 - 4f */
+ KEY_DOWN, KEY_PGDN, KEY_INS, KEY_DEL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 50 - 5f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 60 - 6f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 70 - 7f */
};
+++ /dev/null
-/* for sound we use MIDAS, which takes over the PIT and we can't use it
- * therefore only compile this file for NO_SOUND builds.
- */
-#ifdef NO_SOUND
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <conio.h>
-#include <dos.h>
-
-#ifdef __WATCOMC__
-#include <i86.h>
-#endif
-
-#ifdef __DJGPP__
-#include <dpmi.h>
-#include <go32.h>
-#include <pc.h>
-#endif
-
-#include "pit8254.h"
-#include "inttypes.h"
-#include "util.h"
-#include "dosutil.h"
-
-#define PIT_TIMER_INTR 8
-#define DOS_TIMER_INTR 0x1c
-
-/* macro to divide and round to the nearest integer */
-#define DIV_ROUND(a, b) \
- ((a) / (b) + ((a) % (b)) / ((b) / 2))
-
-static void set_timer_reload(int reload_val);
-static void cleanup(void);
-
-#ifdef __WATCOMC__
-#define INTERRUPT __interrupt __far
-
-static void INTERRUPT dos_timer_intr();
-
-static void (INTERRUPT *prev_timer_intr)();
-#endif
-
-#ifdef __DJGPP__
-#define INTERRUPT
-
-static _go32_dpmi_seginfo intr, prev_intr;
-#endif
-
-static void INTERRUPT timer_irq();
-
-static volatile unsigned long ticks;
-static unsigned long tick_interval, ticks_per_dos_intr;
-static int inum;
-
-void init_timer(int res_hz)
-{
- _disable();
-
- if(res_hz > 0) {
- int reload_val = DIV_ROUND(OSC_FREQ_HZ, res_hz);
- set_timer_reload(reload_val);
-
- tick_interval = DIV_ROUND(1000, res_hz);
- ticks_per_dos_intr = DIV_ROUND(65535L, reload_val);
-
- inum = PIT_TIMER_INTR;
-#ifdef __WATCOMC__
- prev_timer_intr = _dos_getvect(inum);
- _dos_setvect(inum, timer_irq);
-#endif
-#ifdef __DJGPP__
- _go32_dpmi_get_protected_mode_interrupt_vector(inum, &prev_intr);
- intr.pm_offset = (intptr_t)timer_irq;
- intr.pm_selector = _go32_my_cs();
- _go32_dpmi_allocate_iret_wrapper(&intr);
- _go32_dpmi_set_protected_mode_interrupt_vector(inum, &intr);
-#endif
- } else {
- tick_interval = 55;
-
- inum = DOS_TIMER_INTR;
-#ifdef __WATCOMC__
- prev_timer_intr = _dos_getvect(inum);
- _dos_setvect(inum, dos_timer_intr);
-#endif
-#ifdef __DJGPP__
- assert(0);
-#endif
- }
- _enable();
-
- atexit(cleanup);
-}
-
-static void cleanup(void)
-{
- if(!inum) {
- return; /* init hasn't ran, there's nothing to cleanup */
- }
-
- _disable();
- if(inum == PIT_TIMER_INTR) {
- /* restore the original timer frequency */
- set_timer_reload(65535);
- }
-
- /* restore the original interrupt handler */
-#ifdef __WATCOMC__
- _dos_setvect(inum, prev_timer_intr);
-#endif
-#ifdef __DJGPP__
- _go32_dpmi_set_protected_mode_interrupt_vector(inum, &prev_intr);
- _go32_dpmi_free_iret_wrapper(&intr);
-#endif
-
- _enable();
-}
-
-void reset_timer(void)
-{
- ticks = 0;
-}
-
-unsigned long get_msec(void)
-{
- return ticks * tick_interval;
-}
-
-void sleep_msec(unsigned long msec)
-{
- unsigned long wakeup_time = ticks + msec / tick_interval;
- while(ticks < wakeup_time) {
-#ifdef USE_HLT
- halt();
-#endif
- }
-}
-
-static void set_timer_reload(int reload_val)
-{
- outp(PORT_CMD, CMD_CHAN0 | CMD_ACCESS_BOTH | CMD_OP_SQWAVE);
- outp(PORT_DATA0, reload_val & 0xff);
- outp(PORT_DATA0, (reload_val >> 8) & 0xff);
-}
-
-#ifdef __WATCOMC__
-static void INTERRUPT dos_timer_intr()
-{
- ticks++;
- _chain_intr(prev_timer_intr); /* DOES NOT RETURN */
-}
-#endif
-
-/* first PIC command port */
-#define PIC1_CMD 0x20
-/* end of interrupt control word */
-#define OCW2_EOI (1 << 5)
-
-static void INTERRUPT timer_irq()
-{
- static unsigned long dos_ticks;
-
- ticks++;
-
-#ifdef __WATCOMC__
- if(++dos_ticks >= ticks_per_dos_intr) {
- /* I suppose the dos irq handler does the EOI so I shouldn't
- * do it if I am to call the previous function
- */
- dos_ticks = 0;
- _chain_intr(prev_timer_intr); /* XXX DOES NOT RETURN */
- return; /* just for clarity */
- }
-#endif
-
- /* send EOI to the PIC */
- outp(PIC1_CMD, OCW2_EOI);
-}
-
-#endif /* NO_SOUND */
#if defined(__MSDOS__) || defined(MSDOS)
static int setup_serial(int sdev);
+
+void ser_putchar(int c);
+void ser_puts(const char *s);
+void ser_printf(const char *fmt, ...);
#else
#define USE_STD
#endif
case LOG_FILE:
case LOG_STREAM:
fputs(buf, outputs[i].out.fp);
+ fflush(outputs[i].out.fp);
break;
#if defined(MSDOS) || defined(__MSDOS__)
#if defined(MSDOS) || defined(__MSDOS__)
+#include <conio.h>
+
#define UART1_BASE 0x3f8
#define UART2_BASE 0x2f8
#include <assert.h>
#include "miniglut.h"
#include "app.h"
+#include "logger.h"
static void reshape(int x, int y);
static void keydown(unsigned char key, int x, int y);
win_height = glutGet(GLUT_WINDOW_HEIGHT);
win_aspect = (float)win_width / win_height;
+ init_logger();
+
if(app_init() == -1) {
return 1;
}
#include <alloca.h>
#endif
+#ifdef __GNUC__
+#define PACKED __attribute__((packed))
+#else
+#define PACKED
+#endif
+
+unsigned int get_cs(void);
+#define get_cpl() ((int)(get_cs() & 3))
+
+void get_msr(uint32_t msr, uint32_t *low, uint32_t *high);
+void set_msr(uint32_t msr, uint32_t low, uint32_t high);
+
+
/* Non-failing versions of malloc/calloc/realloc. They never return 0, they call
* demo_abort on failure. Use the macros, don't call the *_impl functions.
*/
--- /dev/null
+ section .text
+ bits 32
+; foo_ are watcom functions, _foo are djgpp functions
+
+ global get_cs
+ global _get_cs
+ global get_cs_
+get_cs:
+_get_cs:
+get_cs_:
+ xor eax, eax
+ mov ax, cs
+ ret
+
+ global get_msr
+ global _get_msr
+get_msr:
+_get_msr:
+ push ebp
+ mov ebp, esp
+ push ebx
+ mov ecx, [ebp + 8]
+ rdmsr
+ mov ebx, [ebp + 12]
+ mov [ebx], eax
+ mov ebx, [ebp + 16]
+ mov [ebx], edx
+ pop ebx
+ pop ebp
+ ret
+
+ global get_msr_
+get_msr_:
+ push ebx
+ push edx
+ mov ecx, eax
+ rdmsr
+ pop ebx
+ mov [ebx], eax
+ pop ebx
+ mov [ebx], edx
+ ret
+
+ global set_msr
+ global _set_msr
+set_msr:
+_set_msr:
+ mov ecx, [esp + 4]
+ mov eax, [esp + 8]
+ mov edx, [esp + 12]
+ rdmsr
+ ret
+
+ global set_msr_
+set_msr_:
+ mov ecx, eax
+ mov eax, edx
+ mov edx, ebx
+ wrmsr
+ ret
+
+
+; vi:ft=nasm: