mirror of
https://github.com/kevinbentley/Descent3.git
synced 2025-01-22 11:28:56 +00:00
Convert 2dlib to use new logging facility
This commit is contained in:
parent
30f8fefa0b
commit
a3324dc06e
@ -17,6 +17,7 @@ target_link_libraries(2dlib PRIVATE
|
|||||||
cfile
|
cfile
|
||||||
mem
|
mem
|
||||||
misc
|
misc
|
||||||
|
plog::plog
|
||||||
)
|
)
|
||||||
target_include_directories(2dlib PUBLIC
|
target_include_directories(2dlib PUBLIC
|
||||||
$<BUILD_INTERFACE:
|
$<BUILD_INTERFACE:
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Descent 3
|
* Descent 3
|
||||||
* Copyright (C) 2024 Parallax Software
|
* Copyright (C) 2024 Parallax Software
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
@ -122,8 +122,8 @@
|
|||||||
#include "bitmap.h"
|
#include "bitmap.h"
|
||||||
#include "cfile.h"
|
#include "cfile.h"
|
||||||
#include "gr.h"
|
#include "gr.h"
|
||||||
|
#include "log.h"
|
||||||
#include "mem.h"
|
#include "mem.h"
|
||||||
#include "mono.h"
|
|
||||||
#include "pserror.h"
|
#include "pserror.h"
|
||||||
#include "renderer.h"
|
#include "renderer.h"
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ static inline int READ_FONT_INT(FONTFILE ffile);
|
|||||||
static inline int16_t READ_FONT_SHORT(FONTFILE ffile);
|
static inline int16_t READ_FONT_SHORT(FONTFILE ffile);
|
||||||
static inline uint8_t READ_FONT_BYTE(FONTFILE ffile);
|
static inline uint8_t READ_FONT_BYTE(FONTFILE ffile);
|
||||||
static inline int READ_FONT_DATA(FONTFILE ffile, void *buf, int size, int nelem);
|
static inline int READ_FONT_DATA(FONTFILE ffile, void *buf, int size, int nelem);
|
||||||
static inline FONTFILE OPEN_FONT(char *filename, bool &success);
|
static inline FONTFILE OPEN_FONT(const char *filename, bool &success);
|
||||||
static inline void CLOSE_FONT(FONTFILE ffile);
|
static inline void CLOSE_FONT(FONTFILE ffile);
|
||||||
|
|
||||||
#define BITS_TO_BYTES(_c) (((_c) + 7) >> 3)
|
#define BITS_TO_BYTES(_c) (((_c) + 7) >> 3)
|
||||||
@ -167,7 +167,7 @@ inline int READ_FONT_DATA(FONTFILE ffile, void *buf, int size, int nelem) {
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline FONTFILE OPEN_FONT(char *filename, bool &success) {
|
inline FONTFILE OPEN_FONT(const char *filename, bool &success) {
|
||||||
FONTFILE fp;
|
FONTFILE fp;
|
||||||
int file_id;
|
int file_id;
|
||||||
|
|
||||||
@ -219,7 +219,7 @@ void grFont::close_system() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// we should free any fonts currently allocated here.
|
// we should free any fonts currently allocated here.
|
||||||
mprintf(0, "Freeing cached fonts...");
|
LOG_DEBUG << "Freeing cached fonts...";
|
||||||
for (int i = 0; i < MAX_FONTS; i++) {
|
for (int i = 0; i < MAX_FONTS; i++) {
|
||||||
gr_font_record *ft;
|
gr_font_record *ft;
|
||||||
if (grFont::m_FontList[i].references) {
|
if (grFont::m_FontList[i].references) {
|
||||||
@ -389,8 +389,6 @@ void grFont::load(char *filename, int slot) {
|
|||||||
Error("Illegal font file: %s.\n", filename);
|
Error("Illegal font file: %s.\n", filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
mprintf(0, "%s font.\n", grFont::m_FontList[slot].name);
|
|
||||||
|
|
||||||
ft->width = READ_FONT_SHORT(ff);
|
ft->width = READ_FONT_SHORT(ff);
|
||||||
ft->height = READ_FONT_SHORT(ff);
|
ft->height = READ_FONT_SHORT(ff);
|
||||||
ft->flags = READ_FONT_SHORT(ff);
|
ft->flags = READ_FONT_SHORT(ff);
|
||||||
@ -399,8 +397,6 @@ void grFont::load(char *filename, int slot) {
|
|||||||
ft->max_ascii = READ_FONT_BYTE(ff);
|
ft->max_ascii = READ_FONT_BYTE(ff);
|
||||||
READ_FONT_DATA(ff, fontname, 32, 1);
|
READ_FONT_DATA(ff, fontname, 32, 1);
|
||||||
|
|
||||||
mprintf(0, " <ht %d>::<min %d>::<max %d>::<base %d>", ft->height, ft->min_ascii, ft->max_ascii, ft->baseline);
|
|
||||||
|
|
||||||
num_char = ft->max_ascii - ft->min_ascii + 1;
|
num_char = ft->max_ascii - ft->min_ascii + 1;
|
||||||
|
|
||||||
// Read in all widths
|
// Read in all widths
|
||||||
@ -408,7 +404,6 @@ void grFont::load(char *filename, int slot) {
|
|||||||
ft->char_widths = new int16_t[num_char];
|
ft->char_widths = new int16_t[num_char];
|
||||||
for (i = 0; i < num_char; i++)
|
for (i = 0; i < num_char; i++)
|
||||||
ft->char_widths[i] = READ_FONT_SHORT(ff);
|
ft->char_widths[i] = READ_FONT_SHORT(ff);
|
||||||
mprintf(0, "::proportional");
|
|
||||||
} else {
|
} else {
|
||||||
ft->char_widths = NULL;
|
ft->char_widths = NULL;
|
||||||
}
|
}
|
||||||
@ -427,7 +422,6 @@ void grFont::load(char *filename, int slot) {
|
|||||||
|
|
||||||
if (ft->flags & FT_COLOR) {
|
if (ft->flags & FT_COLOR) {
|
||||||
int off = 0;
|
int off = 0;
|
||||||
mprintf(0, "::color");
|
|
||||||
for (i = 0; i < num_char; i++) {
|
for (i = 0; i < num_char; i++) {
|
||||||
ft->char_data[i] = ft->raw_data + off;
|
ft->char_data[i] = ft->raw_data + off;
|
||||||
if (ft->flags & FT_PROPORTIONAL)
|
if (ft->flags & FT_PROPORTIONAL)
|
||||||
@ -437,7 +431,6 @@ void grFont::load(char *filename, int slot) {
|
|||||||
}
|
}
|
||||||
} else { // Monochrome
|
} else { // Monochrome
|
||||||
uint8_t *ptr = ft->raw_data;
|
uint8_t *ptr = ft->raw_data;
|
||||||
mprintf(0, "::mono");
|
|
||||||
for (i = 0; i < num_char; i++) {
|
for (i = 0; i < num_char; i++) {
|
||||||
ft->char_data[i] = ptr;
|
ft->char_data[i] = ptr;
|
||||||
if (ft->flags & FT_PROPORTIONAL)
|
if (ft->flags & FT_PROPORTIONAL)
|
||||||
@ -452,8 +445,9 @@ void grFont::load(char *filename, int slot) {
|
|||||||
|
|
||||||
// Then read in
|
// Then read in
|
||||||
CLOSE_FONT(ff);
|
CLOSE_FONT(ff);
|
||||||
|
LOG_DEBUG.printf("%s font: <ht %d>::<min %d>::<max %d>::<base %d>::<proportional %d>::<color %d>",
|
||||||
mprintf(0, "\n");
|
grFont::m_FontList[slot].name, ft->height, ft->min_ascii, ft->max_ascii, ft->baseline,
|
||||||
|
ft->flags & FT_PROPORTIONAL, ft->flags & FT_COLOR);
|
||||||
|
|
||||||
grFont::m_FontList[slot].font = fnt;
|
grFont::m_FontList[slot].font = fnt;
|
||||||
|
|
||||||
|
@ -73,6 +73,7 @@
|
|||||||
|
|
||||||
#include "bitmap.h"
|
#include "bitmap.h"
|
||||||
#include "lib2d.h"
|
#include "lib2d.h"
|
||||||
|
#include "log.h"
|
||||||
#include "mem.h"
|
#include "mem.h"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -172,7 +173,7 @@ bool gr_mem_surf_Create(ddgr_surface *sf) {
|
|||||||
|
|
||||||
bm->data = (char *)mem_malloc(bm->rowsize * sf->h);
|
bm->data = (char *)mem_malloc(bm->rowsize * sf->h);
|
||||||
if (!bm->data) {
|
if (!bm->data) {
|
||||||
mprintf(0, "mem_Create malloc fail <%s>\n", sf->name);
|
LOG_WARNING.printf("mem_Create malloc fail <%s>\n", sf->name);
|
||||||
delete bm;
|
delete bm;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -745,8 +745,6 @@ void grSurface::add_to_list(ddgr_surface *sf) {
|
|||||||
node->prev = grSurface::surf_list_cur;
|
node->prev = grSurface::surf_list_cur;
|
||||||
grSurface::surf_list_cur = node;
|
grSurface::surf_list_cur = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
// mprintf(0, "Allocated surface %s [%d].\n", sf->name, DDData.surfs_alloc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void grSurface::remove_from_list(ddgr_surface *sf) {
|
void grSurface::remove_from_list(ddgr_surface *sf) {
|
||||||
@ -776,6 +774,4 @@ void grSurface::remove_from_list(ddgr_surface *sf) {
|
|||||||
node = node->prev;
|
node = node->prev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// mprintf(0, "Freed surface %s [%d].\n", sf->name, DDData.surfs_alloc);
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user