*.LIB
retroray
*.cfg
+*.conf
data/
*.exe
config.mk
*.LNK
*.map
*.MAP
+*.LOG
+*.zip
+core
static rtk_draw_ops guigfx = {gui_fill, gui_blit, gui_drawtext, gui_textrect};
#if !defined(NDEBUG) && defined(DBG_FPEXCEPT)
- printf("floating point exceptions enabled\n");
+ infomsg("floating point exceptions enabled\n");
enable_fpexcept();
#endif
int numpix = x * y;
int prev_numpix = win_width * win_height;
- printf("reshape(%d, %d)\n", x, y);
+ dbgmsg("reshape(%d, %d)\n", x, y);
if(!framebuf || numpix > prev_numpix) {
void *tmp;
#include <stdio.h>
#include <string.h>
#include "cpuid.h"
+#include "logger.h"
static const char *cpuname(struct cpuid_info *cpu);
static const char *cpuvendor(struct cpuid_info *cpu);
"?", "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 ");
+ infomsg("CPU: %s - %s\n", cpuvendor(cpu), cpuname(cpu));
+ infomsg("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);
+ infomsg("\n ");
col = 3;
}
- col += printf(" %s", featstr[i]);
+ infomsg(" %s", featstr[i]);
+ col += strlen(featstr[i]) + 1;
}
}
for(i=0; i<32; i++) {
if(cpu->feat2 & (1 << i)) {
len = strlen(feat2str[i]) + 1;
if(col + len >= 80) {
- fputs("\n ", stdout);
+ infomsg("\n ");
col = 3;
}
- col += printf(" %s", feat2str[i]);
+ infomsg(" %s", feat2str[i]);
+ col += strlen(feat2str[i]) + 1;
}
}
- putchar('\n');
+ infomsg("\n");
}
static const char *fam4_models[16] = {
#include "vga.h"
#include "util.h"
#include "cpuid.h"
+#include "logger.h"
#ifdef __DJGPP__
#define VMEM_PTR ((void*)(0xa0000 + __djgpp_conventional_base))
struct video_mode *vmptr;
if(vbe_info(&vbe) == -1) {
- fprintf(stderr, "failed to retrieve VBE information\n");
+ errormsg("failed to retrieve VBE information\n");
return -1;
}
vbe_print_info(stdout, &vbe);
num_vmodes = 0;
max_modes = 64;
if(!(vmodes = malloc(max_modes * sizeof *vmodes))) {
- fprintf(stderr, "failed to allocate video modes list\n");
+ errormsg("failed to allocate video modes list\n");
return -1;
}
if(num_vmodes >= max_modes) {
int newmax = max_modes ? (max_modes << 1) : 16;
if(!(vmptr = realloc(vmodes, newmax * sizeof *vmodes))) {
- fprintf(stderr, "failed to grow video mode list (%d)\n", newmax);
+ errormsg("failed to grow video mode list (%d)\n", newmax);
free(vmodes);
return -1;
}
vmptr->max_pages = minf.num_img_pages;
vmptr->win_gran = minf.win_gran;
- printf("%04x: ", vbe.modes[i]);
+ infomsg("%04x: ", vbe.modes[i]);
vbe_print_mode_info(stdout, &minf);
}
- fflush(stdout);
+ /*fflush(stdout);*/
vbe_init_ver = VBE_VER_MAJOR(vbe.ver);
return 0;
}
if(best == -1) {
- fprintf(stderr, "failed to find video mode %dx%d %d bpp)\n", xsz, ysz, bpp);
+ errormsg("failed to find video mode %dx%d %d bpp)\n", xsz, ysz, bpp);
return -1;
}
return best;
if(curmode == vm) return vpgaddr[0];
- printf("setting video mode %x (%dx%d %d bpp)\n", (unsigned int)vm->mode,
+ infomsg("setting video mode %x (%dx%d %d bpp)\n", (unsigned int)vm->mode,
vm->xsz, vm->ysz, vm->bpp);
- fflush(stdout);
+ /*fflush(stdout);*/
mode = vm->mode | VBE_MODE_LFB;
if(vbe_setmode(mode) == -1) {
+ infomsg("Warning: failed to get a linear framebuffer. falling back to banked mode\n");
mode = vm->mode;
if(vbe_setmode(mode) == -1) {
- fprintf(stderr, "failed to set video mode %x\n", (unsigned int)vm->mode);
+ errormsg("failed to set video mode %x\n", (unsigned int)vm->mode);
return 0;
}
- printf("Warning: failed to get a linear framebuffer. falling back to banked mode\n");
}
/* unmap previous video memory mapping, if there was one (switching modes) */
fbsize = pgcount * pgsize;
if(vm->bpp > 8) {
- printf("rgb mask: %x %x %x\n", (unsigned int)vm->rmask,
+ infomsg("rgb mask: %x %x %x\n", (unsigned int)vm->rmask,
(unsigned int)vm->gmask, (unsigned int)vm->bmask);
- printf("rgb shift: %d %d %d\n", vm->rshift, vm->gshift, vm->bshift);
+ infomsg("rgb shift: %d %d %d\n", vm->rshift, vm->gshift, vm->bshift);
}
- printf("pgcount: %d, pgsize: %d, fbsize: %d\n", pgcount, pgsize, fbsize);
+ infomsg("pgcount: %d, pgsize: %d, fbsize: %d\n", pgcount, pgsize, fbsize);
if(vm->fb_addr) {
- printf("phys addr: %p\n", (void*)vm->fb_addr);
+ infomsg("phys addr: %p\n", (void*)vm->fb_addr);
}
- fflush(stdout);
+ /*fflush(stdout);*/
if(vm->fb_addr) {
vpgaddr[0] = (void*)dpmi_mmap(vm->fb_addr, fbsize);
if(!vpgaddr[0]) {
- fprintf(stderr, "failed to map framebuffer (phys: %lx, size: %d)\n",
+ errormsg("failed to map framebuffer (phys: %lx, size: %d)\n",
(unsigned long)vm->fb_addr, fbsize);
set_text_mode();
return 0;
if(CPU_HAVE_MTRR) {
int cpl = get_cpl();
if(cpl > 0) {
- fprintf(stderr, "Can't set framebuffer range to write-combining, running in ring %d\n", cpl);
+ errormsg("Can't set framebuffer range to write-combining, running in ring %d\n", cpl);
} else {
uint32_t len = (uint32_t)vbe.vmem_blk << 16;
* mtrr
*/
if(!len || len > 0x10000000) {
- printf("reported vmem too large or overflowed, using fbsize for wrcomb setup\n");
+ infomsg("reported vmem too large or overflowed, using fbsize for wrcomb setup\n");
len = fbsize;
}
print_mtrr();
vm->win_64k_step = 1 << vm->win_gran_shift;
}
- printf("granularity: %dk (step: %d)\n", vm->win_gran, vm->win_64k_step);
+ infomsg("granularity: %dk (step: %d)\n", vm->win_gran, vm->win_64k_step);
}
- /* 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);
+ /*fflush(stdout);*/
return vpgaddr[0];
}
uint32_t def, mask;
if(len <= 0 || (addr | (uint32_t)len) & 0xfff) {
- fprintf(stderr, "failed to enable write combining, unaligned range: %p/%x\n",
+ errormsg("failed to enable write combining, unaligned range: %p/%x\n",
(void*)addr, (unsigned int)len);
return;
}
get_msr(MSR_MTRRCAP, &rlow, &rhigh);
num_ranges = rlow & 0xff;
- printf("enable_wrcomb: addr=%p len=%x\n", (void*)addr, (unsigned int)len);
+ infomsg("enable_wrcomb: addr=%p len=%x\n", (void*)addr, (unsigned int)len);
if(!(rlow & MTRRCAP_HAVE_WC)) {
- fprintf(stderr, "failed to enable write combining, processor doesn't support it\n");
+ errormsg("failed to enable write combining, processor doesn't support it\n");
return;
}
}
if((mtrr = alloc_mtrr(num_ranges)) == -1) {
- fprintf(stderr, "failed to enable write combining, no free MTRRs\n");
+ errormsg("failed to enable write combining, no free MTRRs\n");
return;
}
mask |= mask >> 16;
mask = ~mask & 0xfffff000;
- printf(" ... mask: %08x\n", (unsigned int)mask);
+ infomsg(" ... mask: %08x\n", (unsigned int)mask);
_disable();
get_msr(MSR_MTRRDEFTYPE, &def, &rhigh);
get_msr(MSR_MTRRMASK(i), &mask, &rhigh);
if(mask & MTRRMASK_VALID) {
- printf("mtrr%d: base %p, mask %08x type %s\n", i, (void*)(base & 0xfffff000),
+ infomsg("mtrr%d: base %p, mask %08x type %s\n", i, (void*)(base & 0xfffff000),
(unsigned int)(mask & 0xfffff000), mtrr_type_name(base & 0xff));
} else {
- printf("mtrr%d unused (%08x/%08x)\n", i, (unsigned int)base,
+ infomsg("mtrr%d unused (%08x/%08x)\n", i, (unsigned int)base,
(unsigned int)mask);
}
}
- fflush(stdout);
+ /*fflush(stdout);*/
}
#include <assert.h>
#include "vbe.h"
#include "cdpmi.h"
+#include "logger.h"
#define FIXPTR(ptr) \
static int cur_pitch;
/* TODO update cur_pitch on mode-change and on setscanlen */
-
int vbe_info(struct vbe_info *info)
{
void *lowbuf;
dpmi_int(0x10, ®s);
if((regs.eax & 0xffff) != 0x4f) {
- fprintf(stderr, "vbe_get_info (4f00) failed\n");
+ errormsg("vbe_get_info (4f00) failed\n");
dpmi_free(sel);
return -1;
}
dpmi_int(0x10, ®s);
if((regs.eax & 0xffff) != 0x4f) {
- fprintf(stderr, "vbe_mode_info (4f01) failed\n");
+ errormsg("vbe_mode_info (4f01) failed\n");
dpmi_free(sel);
return -1;
}
void vbe_print_info(FILE *fp, struct vbe_info *vinf)
{
- fprintf(fp, "vbe version: %u.%u\n", VBE_VER_MAJOR(vinf->ver), VBE_VER_MINOR(vinf->ver));
+ infomsg("vbe version: %u.%u\n", VBE_VER_MAJOR(vinf->ver), VBE_VER_MINOR(vinf->ver));
if(VBE_VER_MAJOR(vinf->ver) >= 2) {
- fprintf(fp, "%s - %s (%s)\n", vinf->vendor, vinf->product, vinf->revstr);
+ infomsg("%s - %s (%s)\n", vinf->vendor, vinf->product, vinf->revstr);
if(vinf->caps & VBE_ACCEL) {
- fprintf(fp, "vbe/af %d.%d\n", VBE_VER_MAJOR(vinf->accel_ver), VBE_VER_MINOR(vinf->accel_ver));
+ infomsg("vbe/af %d.%d\n", VBE_VER_MAJOR(vinf->accel_ver), VBE_VER_MINOR(vinf->accel_ver));
}
} else {
- fprintf(fp, "oem: %s\n", vinf->oem_name);
+ infomsg("oem: %s\n", vinf->oem_name);
}
- fprintf(fp, "video memory: %dkb\n", vinf->vmem_blk * 64);
+ infomsg("video memory: %dkb\n", vinf->vmem_blk * 64);
if(vinf->caps) {
- fprintf(fp, "caps:");
- if(vinf->caps & VBE_8BIT_DAC) fprintf(fp, " dac8");
- if(vinf->caps & VBE_NON_VGA) fprintf(fp, " non-vga");
- if(vinf->caps & VBE_DAC_BLANK) fprintf(fp, " dac-blank");
- if(vinf->caps & VBE_ACCEL) fprintf(fp, " af");
- if(vinf->caps & VBE_MUSTLOCK) fprintf(fp, " af-lock");
- if(vinf->caps & VBE_HWCURSOR) fprintf(fp, " af-curs");
- if(vinf->caps & VBE_HWCLIP) fprintf(fp, " af-clip");
- if(vinf->caps & VBE_TRANSP_BLT) fprintf(fp, " af-tblt");
- fprintf(fp, "\n");
- }
-
- fprintf(fp, "%d video modes available\n", NMODES(vinf));
+ infomsg("caps:");
+ if(vinf->caps & VBE_8BIT_DAC) infomsg(" dac8");
+ if(vinf->caps & VBE_NON_VGA) infomsg(" non-vga");
+ if(vinf->caps & VBE_DAC_BLANK) infomsg(" dac-blank");
+ if(vinf->caps & VBE_ACCEL) infomsg(" af");
+ if(vinf->caps & VBE_MUSTLOCK) infomsg(" af-lock");
+ if(vinf->caps & VBE_HWCURSOR) infomsg(" af-curs");
+ if(vinf->caps & VBE_HWCLIP) infomsg(" af-clip");
+ if(vinf->caps & VBE_TRANSP_BLT) infomsg(" af-tblt");
+ infomsg("\n");
+ }
+
+ infomsg("%d video modes available\n", NMODES(vinf));
if(vinf->caps & VBE_ACCEL) {
- fprintf(fp, "%d accelerated (VBE/AF) modes available\n", NACCMODES(vinf));
+ infomsg("%d accelerated (VBE/AF) modes available\n", NACCMODES(vinf));
}
- fflush(fp);
+ /*fflush(fp);*/
}
void vbe_print_mode_info(FILE *fp, struct vbe_mode_info *minf)
{
- fprintf(fp, "%dx%d %dbpp", minf->xres, minf->yres, minf->bpp);
+ infomsg("%dx%d %dbpp", minf->xres, minf->yres, minf->bpp);
switch(minf->mem_model) {
case VBE_TYPE_DIRECT:
- fprintf(fp, " (rgb");
+ infomsg(" (rgb");
if(0) {
case VBE_TYPE_YUV:
- fprintf(fp, " (yuv");
+ infomsg(" (yuv");
}
- fprintf(fp, " %d%d%d)", minf->rsize, minf->gsize, minf->bsize);
+ infomsg(" %d%d%d)", minf->rsize, minf->gsize, minf->bsize);
break;
case VBE_TYPE_PLANAR:
- fprintf(fp, " (%d planes)", minf->num_planes);
+ infomsg(" (%d planes)", minf->num_planes);
break;
case VBE_TYPE_PACKED:
- fprintf(fp, " (packed)");
+ infomsg(" (packed)");
break;
case VBE_TYPE_TEXT:
- fprintf(fp, " (%dx%d cells)", minf->xcharsz, minf->ycharsz);
+ infomsg(" (%dx%d cells)", minf->xcharsz, minf->ycharsz);
break;
case VBE_TYPE_CGA:
- fprintf(fp, " (CGA)");
+ infomsg(" (CGA)");
break;
case VBE_TYPE_UNCHAIN:
- fprintf(fp, " (unchained-%d)", minf->num_planes);
+ infomsg(" (unchained-%d)", minf->num_planes);
break;
}
- fprintf(fp, " %dpg", minf->num_img_pages);
+ infomsg(" %dpg", minf->num_img_pages);
if(minf->attr & VBE_ATTR_LFB) {
- fprintf(fp, " lfb@%lx", (unsigned long)minf->fb_addr);
+ infomsg(" lfb@%lx", (unsigned long)minf->fb_addr);
} else {
- fprintf(fp, " (%dk gran)", (int)minf->win_gran);
- }
-
- fprintf(fp, " [");
- if(minf->attr & VBE_ATTR_AVAIL) fprintf(fp, " avail");
- if(minf->attr & VBE_ATTR_OPTINFO) fprintf(fp, " opt");
- if(minf->attr & VBE_ATTR_TTY) fprintf(fp, " tty");
- if(minf->attr & VBE_ATTR_COLOR) fprintf(fp, " color");
- if(minf->attr & VBE_ATTR_GFX) fprintf(fp, " gfx");
- if(minf->attr & VBE_ATTR_NOTVGA) fprintf(fp, " non-vga");
- if(minf->attr & VBE_ATTR_BANKED) fprintf(fp, " banked");
- if(minf->attr & VBE_ATTR_LFB) fprintf(fp, " lfb");
- if(minf->attr & VBE_ATTR_DBLSCAN) fprintf(fp, " dblscan");
- if(minf->attr & VBE_ATTR_ILACE) fprintf(fp, " ilace");
- if(minf->attr & VBE_ATTR_TRIPLEBUF) fprintf(fp, " trplbuf");
- if(minf->attr & VBE_ATTR_STEREO) fprintf(fp, " stereo");
- if(minf->attr & VBE_ATTR_STEREO_2FB) fprintf(fp, " stdual");
- fprintf(fp, " ]\n");
- fflush(fp);
+ infomsg(" (%dk gran)", (int)minf->win_gran);
+ }
+
+ infomsg(" [");
+ if(minf->attr & VBE_ATTR_AVAIL) infomsg(" avail");
+ if(minf->attr & VBE_ATTR_OPTINFO) infomsg(" opt");
+ if(minf->attr & VBE_ATTR_TTY) infomsg(" tty");
+ if(minf->attr & VBE_ATTR_COLOR) infomsg(" color");
+ if(minf->attr & VBE_ATTR_GFX) infomsg(" gfx");
+ if(minf->attr & VBE_ATTR_NOTVGA) infomsg(" non-vga");
+ if(minf->attr & VBE_ATTR_BANKED) infomsg(" banked");
+ if(minf->attr & VBE_ATTR_LFB) infomsg(" lfb");
+ if(minf->attr & VBE_ATTR_DBLSCAN) infomsg(" dblscan");
+ if(minf->attr & VBE_ATTR_ILACE) infomsg(" ilace");
+ if(minf->attr & VBE_ATTR_TRIPLEBUF) infomsg(" trplbuf");
+ if(minf->attr & VBE_ATTR_STEREO) infomsg(" stereo");
+ if(minf->attr & VBE_ATTR_STEREO_2FB) infomsg(" stdual");
+ infomsg(" ]\n");
+ /*fflush(fp);*/
}
int vbe_setmode(uint16_t mode)
static void logmsg(int type, const char *fmt, va_list ap)
{
- static char *buf;
- static int bufsz;
- int i, ret, newsz;
- char *tmp;
-
- while((ret = vsnprintf(buf, bufsz, fmt, ap)) > bufsz || ret < 0) {
- if(ret > bufsz) {
- newsz = ret + 1;
- } else {
- newsz = bufsz ? bufsz * 2 : 256;
- }
- if(!(tmp = realloc(buf, newsz))) {
- if(buf) {
- buf[bufsz - 1] = 0;
- }
- break;
- }
- buf = tmp;
- bufsz = newsz;
- }
+ static char buf[2048];
+ int i;
- if(!buf) return;
+ vsnprintf(buf, sizeof buf, fmt, ap);
for(i=0; i<num_outputs; i++) {
switch(outputs[i].type) {
#include <errno.h>
#include "options.h"
#include "treestor.h"
+#include "logger.h"
#define DEF_XRES 640
#define DEF_YRES 480
if(!(cfg = ts_load(fname))) {
return -1;
}
- printf("loaded config: %s\n", fname);
+ infomsg("loaded config: %s\n", fname);
opt.xres = ts_lookup_int(cfg, "options.video.xres", DEF_XRES);
opt.yres = ts_lookup_int(cfg, "options.video.yres", DEF_YRES);
act_settool(TOOL_SCALE);
break;
+ case KEY_F6:
+ act_settool(TOOL_REND_AREA);
+ break;
+
case KEY_DEL:
act_rmobj();
break;
static cgm_vec3 lookup_marble2d(const struct texture *btex, const struct rayhit *hit);
static cgm_vec3 lookup_marble3d(const struct texture *btex, const struct rayhit *hit);
-static const cgm_vec3 (*lookup[])(const struct texture*, const struct rayhit*) = {
+static cgm_vec3 (*lookup[])(const struct texture*, const struct rayhit*) = {
lookup_pixmap,
lookup_chess,
lookup_fbm2d,