Gered
62af8575c6
- rename standard integer types to a more familiar (u)int(8/16/32) - many function/struct renames. i don't _really_ know if what i've done for this is better, but it "feels" better to me. many draw/blit function names are shorter which is nice, at least. kinda important to me because i develop this on a real DOS machine in 80x50 text mode. - add 'extern "C"' blocks to headers for C++ compiler usage - draw/pixel color value arguments for functions should all have been changed to be uint8 instead of a full 32-bit int. feels right, but maybe should've left alone... - small fix to keyboard handler. noticed a problem on one thinkpad laptop. was a result of what i think was a typo in a constant value used during the part of the interrupt handler that tells the keyboard controller the key event was processed - fix uncommon potential crash function return in draw_filled_rect - renamed low-level "direct" assembly functions to "lowlevel_xxx" to be a little bit more explicit about what they are - add some convenience event helper functions for determining event types - add fixed point atan2 - fixed some tabs/spaces inconsistences (should all be spaces now?) - maybe some other minor things i've forgotten
74 lines
2.5 KiB
C
Executable file
74 lines
2.5 KiB
C
Executable file
#include "dgl.h"
|
|
#include "dglkbrd.h"
|
|
#include "dglmouse.h"
|
|
#include "dglgfx.h"
|
|
#include "dglevent.h"
|
|
#include <stdlib.h>
|
|
|
|
static DGL_ERROR _last_error = DGL_NONE;
|
|
|
|
DGL_ERROR dgl_last_error(void) {
|
|
DGL_ERROR err = _last_error;
|
|
_last_error = DGL_NONE;
|
|
return err;
|
|
}
|
|
|
|
const char* dgl_last_error_message(void) {
|
|
switch (_last_error) {
|
|
case DGL_NONE:
|
|
return "";
|
|
case DGL_ALREADY_INIT:
|
|
return "DGL is already initialized.";
|
|
case DGL_NEARPTR_ENABLE_FAILURE:
|
|
return "Failed to enable DJGPP near pointers.";
|
|
case DGL_VIDEO_ALREADY_INITIALIZED:
|
|
return "Video subsystem is already initialized.";
|
|
case DGL_VIDEO_MODE_13H_INIT_FAILURE:
|
|
return "Failed to set VGA mode 13h.";
|
|
case DGL_VIDEO_TEXT_MODE_INIT_FAILURE:
|
|
return "Failed to set text mode.";
|
|
case DGL_KEYBOARD_ALREADY_INITIALIZED:
|
|
return "Keyboard subsystem is already initialized.";
|
|
case DGL_KEYBOARD_IRQ_INSTALL_FAILURE:
|
|
return "Failed to install IRQ handler for keyboard.";
|
|
case DGL_KEYBOARD_IRQ_RESTORE_FAILURE:
|
|
return "Failed to restore original keyboard IRQ handler.";
|
|
case DGL_KEYBOARD_UPDATE_LED_FAILURE:
|
|
return "Failed to update keyboard LED state.";
|
|
case DGL_MOUSE_ALREADY_INITIALIZED:
|
|
return "Mouse subsystem is already initialized.";
|
|
case DGL_MOUSE_ALLOCATE_CALLBACK_FAILURE:
|
|
return "Failed to allocate mouse handler callback.";
|
|
case DGL_MOUSE_FREE_CALLBACK_FAILURE:
|
|
return "Failed to free mouse handler callback.";
|
|
case DGL_MOUSE_INT_CALLBACK_SET_FAILURE:
|
|
return "Failed to set mouse interrupt handler callback.";
|
|
case DGL_MOUSE_INT_CALLBACK_RESTORE_FAILURE:
|
|
return "Failed to restore original mouse interrupt handler callback.";
|
|
case DGL_EVENTS_ALREADY_INITIALIZED:
|
|
return "Input device events subsystem is already initialized.";
|
|
case DGL_IO_ERROR:
|
|
return "File IO error.";
|
|
case DGL_PCX_BAD_FORMAT:
|
|
return "PCX file unsupported format or bad file.";
|
|
default:
|
|
return "Unknown error.";
|
|
}
|
|
}
|
|
|
|
void dgl_set_error(DGL_ERROR error) {
|
|
_last_error = error;
|
|
}
|
|
|
|
void dgl_init(void) {
|
|
atexit(dgl_close);
|
|
}
|
|
|
|
void dgl_close(void) {
|
|
events_shutdown();
|
|
mouse_shutdown();
|
|
keyboard_shutdown();
|
|
gfx_shutdown();
|
|
}
|
|
|