tidies up dossys a little

This commit is contained in:
Dethrace Labs 2025-05-28 13:18:47 +12:00
parent effccaa8d2
commit 32fe0eab12
8 changed files with 12 additions and 224 deletions

View File

@ -170,8 +170,6 @@ target_sources(dethrace_obj PRIVATE
# pc-win95/win95sys.c
# pc-win95/ssdx.c
# pc-win95/ssdx.h
# todo remove from normal compile
pc-win95/dinput.h
# original dos sys and network
#pc-dos/dosnet.c

View File

@ -333,7 +333,7 @@ void PDShutdownSystem(void) {
}
dr_dprintf("Destroying window...");
gHarness_platform.DestroyWindow(NULL);
gHarness_platform.DestroyWindow();
dr_dprintf("End of PDShutdownSystem().");
CloseDiagnostics();
}

View File

@ -24,15 +24,7 @@
#include <sys/stat.h>
#include <time.h>
// This code comes from DOS, so small changes need to be made to run correctly on windowed systems.
// Generally the pc-win95 does the same thing
#define PLAY_NICE_WITH_GUI 1
#ifdef PLAY_NICE_WITH_GUI
#define MOUSE_SPEED_MULTIPLIER 1
#else
#define MOUSE_SPEED_MULTIPLIER 0.25f
#endif
// Based on VOODOO2C.EXE
int gDOSGfx_initialized;
int gExtra_mem;
@ -40,7 +32,6 @@ int gReplay_override;
tGraf_spec gGraf_specs[2] = {
{ 8, 1, 0, 320, 200, 0, 0, "32X20X8", "MCGA,W:320,H:200,B:8", 320, 320, 200, NULL },
{ 8, 1, 0, 640, 480, 0, 0, "64X48X8", "VESA,W:640,H:480,B:8", 640, 640, 480, NULL }
// { 8, 1, 0, 1920, 1080, 0, 0, "64X48X8", "VESA,W:640,H:480,B:8", 640, 1920, 1080, NULL }
};
int gASCII_table[128];
tU32 gKeyboard_bits[8];
@ -71,9 +62,6 @@ tU8 gScan_code[123][2];
int gForce_voodoo_rush_mode;
int gForce_voodoo_mode;
br_device_gl_callback_procs gl_callbacks;
br_device_virtualfb_callback_procs virtualfb_callbacks;
// forward declare for `PDInitialiseSystem`
int InitJoysticks(void);
@ -242,11 +230,6 @@ void PDSetKeyArray(int* pKeys, int pMark) {
tS32 joyY;
LOG_TRACE10("(%p, %d)", pKeys, pMark);
#ifdef PLAY_NICE_WITH_GUI
// Required in some cases like a tight loop waiting for a keypress
gHarness_platform.ProcessWindowMessages(NULL);
#endif
gKeys_pressed = 0;
for (i = 0; i < COUNT_OF(gScan_code); i++) {
if (KeyDown(gScan_code[i][0]) || KeyDown(gScan_code[i][1])) {
@ -280,9 +263,7 @@ void PDFatalError(char* pThe_str) {
}
printf("FATAL ERROR: %s\n", pThe_str);
dr_dprintf("FATAL ERROR: %s\n", pThe_str);
#ifdef PLAY_NICE_WITH_GUI
gHarness_platform.ShowErrorMessage("Carmageddon Fatal Error", pThe_str);
#endif
if (gBrZb_initialized) {
gBrZb_initialized = 0;
BrZbEnd();
@ -290,11 +271,9 @@ void PDFatalError(char* pThe_str) {
if (gBr_initialized) {
gBr_initialized = 0;
}
#ifndef PLAY_NICE_WITH_GUI
// There is no window to receive keyboard events from
while (PDAnyKeyDown() == -1) {
}
#endif
QuitGame();
}
@ -418,27 +397,8 @@ void PDAllocateScreenAndBack(void) {
gScreen = NULL;
// added by dethrace. We default to software mode unless we explicitly ask for 3dfx opengl mode
if (harness_game_config.opengl_3dfx_mode) {
if (gGraf_spec_index != 0 && !gNo_voodoo) {
#ifdef PLAY_NICE_WITH_GUI
gl_callbacks.get_proc_address = gHarness_platform.GL_GetProcAddress;
gl_callbacks.swap_buffers = gHarness_platform.Swap;
gl_callbacks.get_viewport = gHarness_platform.GetViewport;
gHarness_platform.CreateWindow_("Carmageddon", gGraf_specs[gGraf_spec_index].phys_width, gGraf_specs[gGraf_spec_index].phys_height, eWindow_type_opengl);
BrDevBeginVar(&gScreen, "glrend",
BRT_WIDTH_I32, gGraf_specs[gGraf_spec_index].phys_width,
BRT_HEIGHT_I32, gGraf_specs[gGraf_spec_index].phys_height,
BRT_OPENGL_CALLBACKS_P, &gl_callbacks,
BRT_PIXEL_TYPE_U8, BR_PMT_RGB_565,
BR_NULL_TOKEN);
#else
BrDevBegin(&gScreen, "3dfx_dos,w:640,h:480,b:16");
#endif
}
if (gGraf_spec_index != 0 && !gNo_voodoo) {
BrDevBegin(&gScreen, "3dfx_dos,w:640,h:480,b:16");
}
if (gScreen != NULL) {
@ -468,19 +428,7 @@ void PDAllocateScreenAndBack(void) {
gInterpolate_textures = 1;
gExceptions_general_file = "SOFTWARE";
#ifdef PLAY_NICE_WITH_GUI
// Render framebuffer to memory and call hooks when swapping or palette changing
virtualfb_callbacks.palette_changed = gHarness_platform.PaletteChanged;
virtualfb_callbacks.swap_buffers = gHarness_platform.Swap;
gHarness_platform.CreateWindow_("Carmageddon", gGraf_specs[gGraf_spec_index].phys_width, gGraf_specs[gGraf_spec_index].phys_height, eWindow_type_software);
BrDevBeginVar(&gScreen, "virtualframebuffer",
BRT_WIDTH_I32, gGraf_specs[gGraf_spec_index].phys_width,
BRT_HEIGHT_I32, gGraf_specs[gGraf_spec_index].phys_height,
BRT_VIRTUALFB_CALLBACKS_P, &virtualfb_callbacks,
BR_NULL_TOKEN);
#else
gScreen = BrDevBeginOld(gGraf_specs[gGraf_spec_index].gfx_init_string);
#endif
gDOSGfx_initialized = 1;
}
gScreen->origin_x = 0;
@ -758,8 +706,8 @@ void PDGetMousePosition(int* pX_coord, int* pY_coord) {
delta_x = mouse_x - gMouse_last_x_coord;
delta_y = mouse_y - gMouse_last_y_coord;
*pX_coord = gMouse_last_x_coord + (MOUSE_SPEED_MULTIPLIER * delta_x);
*pY_coord = gMouse_last_y_coord + (MOUSE_SPEED_MULTIPLIER * delta_y);
*pX_coord = gMouse_last_x_coord + (0.25f * delta_x);
*pY_coord = gMouse_last_y_coord + (0.25f * delta_y);
}
}
@ -770,11 +718,6 @@ int PDGetTotalTime(void) {
// IDA: int __usercall PDServiceSystem@<EAX>(tU32 pTime_since_last_call@<EAX>)
int PDServiceSystem(tU32 pTime_since_last_call) {
#ifdef PLAY_NICE_WITH_GUI
// Added by dethrace. Win95 code does the same
gHarness_platform.ProcessWindowMessages(NULL);
#endif
return 0;
}

View File

@ -1,153 +0,0 @@
/****************************************************************************
*
* DirectInput keyboard scan codes
*
****************************************************************************/
#define DIK_ESCAPE 0x01
#define DIK_1 0x02
#define DIK_2 0x03
#define DIK_3 0x04
#define DIK_4 0x05
#define DIK_5 0x06
#define DIK_6 0x07
#define DIK_7 0x08
#define DIK_8 0x09
#define DIK_9 0x0A
#define DIK_0 0x0B
#define DIK_MINUS 0x0C /* - on main keyboard */
#define DIK_EQUALS 0x0D
#define DIK_BACK 0x0E /* backspace */
#define DIK_TAB 0x0F
#define DIK_Q 0x10
#define DIK_W 0x11
#define DIK_E 0x12
#define DIK_R 0x13
#define DIK_T 0x14
#define DIK_Y 0x15
#define DIK_U 0x16
#define DIK_I 0x17
#define DIK_O 0x18
#define DIK_P 0x19
#define DIK_LBRACKET 0x1A
#define DIK_RBRACKET 0x1B
#define DIK_RETURN 0x1C /* Enter on main keyboard */
#define DIK_LCONTROL 0x1D
#define DIK_A 0x1E
#define DIK_S 0x1F
#define DIK_D 0x20
#define DIK_F 0x21
#define DIK_G 0x22
#define DIK_H 0x23
#define DIK_J 0x24
#define DIK_K 0x25
#define DIK_L 0x26
#define DIK_SEMICOLON 0x27
#define DIK_APOSTROPHE 0x28
#define DIK_GRAVE 0x29 /* accent grave */
#define DIK_LSHIFT 0x2A
#define DIK_BACKSLASH 0x2B
#define DIK_Z 0x2C
#define DIK_X 0x2D
#define DIK_C 0x2E
#define DIK_V 0x2F
#define DIK_B 0x30
#define DIK_N 0x31
#define DIK_M 0x32
#define DIK_COMMA 0x33
#define DIK_PERIOD 0x34 /* . on main keyboard */
#define DIK_SLASH 0x35 /* / on main keyboard */
#define DIK_RSHIFT 0x36
#define DIK_MULTIPLY 0x37 /* * on numeric keypad */
#define DIK_LMENU 0x38 /* left Alt */
#define DIK_SPACE 0x39
#define DIK_CAPITAL 0x3A
#define DIK_F1 0x3B
#define DIK_F2 0x3C
#define DIK_F3 0x3D
#define DIK_F4 0x3E
#define DIK_F5 0x3F
#define DIK_F6 0x40
#define DIK_F7 0x41
#define DIK_F8 0x42
#define DIK_F9 0x43
#define DIK_F10 0x44
#define DIK_NUMLOCK 0x45
#define DIK_SCROLL 0x46 /* Scroll Lock */
#define DIK_NUMPAD7 0x47
#define DIK_NUMPAD8 0x48
#define DIK_NUMPAD9 0x49
#define DIK_SUBTRACT 0x4A /* - on numeric keypad */
#define DIK_NUMPAD4 0x4B
#define DIK_NUMPAD5 0x4C
#define DIK_NUMPAD6 0x4D
#define DIK_ADD 0x4E /* + on numeric keypad */
#define DIK_NUMPAD1 0x4F
#define DIK_NUMPAD2 0x50
#define DIK_NUMPAD3 0x51
#define DIK_NUMPAD0 0x52
#define DIK_DECIMAL 0x53 /* . on numeric keypad */
#define DIK_OEM_102 0x56 /* <> or \| on RT 102-key keyboard (Non-U.S.) */
#define DIK_F11 0x57
#define DIK_F12 0x58
#define DIK_F13 0x64 /* (NEC PC98) */
#define DIK_F14 0x65 /* (NEC PC98) */
#define DIK_F15 0x66 /* (NEC PC98) */
#define DIK_KANA 0x70 /* (Japanese keyboard) */
#define DIK_ABNT_C1 0x73 /* /? on Brazilian keyboard */
#define DIK_CONVERT 0x79 /* (Japanese keyboard) */
#define DIK_NOCONVERT 0x7B /* (Japanese keyboard) */
#define DIK_YEN 0x7D /* (Japanese keyboard) */
#define DIK_ABNT_C2 0x7E /* Numpad . on Brazilian keyboard */
#define DIK_NUMPADEQUALS 0x8D /* = on numeric keypad (NEC PC98) */
#define DIK_PREVTRACK 0x90 /* Previous Track (DIK_CIRCUMFLEX on Japanese keyboard) */
#define DIK_AT 0x91 /* (NEC PC98) */
#define DIK_COLON 0x92 /* (NEC PC98) */
#define DIK_UNDERLINE 0x93 /* (NEC PC98) */
#define DIK_KANJI 0x94 /* (Japanese keyboard) */
#define DIK_STOP 0x95 /* (NEC PC98) */
#define DIK_AX 0x96 /* (Japan AX) */
#define DIK_UNLABELED 0x97 /* (J3100) */
#define DIK_NEXTTRACK 0x99 /* Next Track */
#define DIK_NUMPADENTER 0x9C /* Enter on numeric keypad */
#define DIK_RCONTROL 0x9D
#define DIK_MUTE 0xA0 /* Mute */
#define DIK_CALCULATOR 0xA1 /* Calculator */
#define DIK_PLAYPAUSE 0xA2 /* Play / Pause */
#define DIK_MEDIASTOP 0xA4 /* Media Stop */
#define DIK_VOLUMEDOWN 0xAE /* Volume - */
#define DIK_VOLUMEUP 0xB0 /* Volume + */
#define DIK_WEBHOME 0xB2 /* Web home */
#define DIK_NUMPADCOMMA 0xB3 /* , on numeric keypad (NEC PC98) */
#define DIK_DIVIDE 0xB5 /* / on numeric keypad */
#define DIK_SYSRQ 0xB7
#define DIK_RMENU 0xB8 /* right Alt */
#define DIK_PAUSE 0xC5 /* Pause */
#define DIK_HOME 0xC7 /* Home on arrow keypad */
#define DIK_UP 0xC8 /* UpArrow on arrow keypad */
#define DIK_PRIOR 0xC9 /* PgUp on arrow keypad */
#define DIK_LEFT 0xCB /* LeftArrow on arrow keypad */
#define DIK_RIGHT 0xCD /* RightArrow on arrow keypad */
#define DIK_END 0xCF /* End on arrow keypad */
#define DIK_DOWN 0xD0 /* DownArrow on arrow keypad */
#define DIK_NEXT 0xD1 /* PgDn on arrow keypad */
#define DIK_INSERT 0xD2 /* Insert on arrow keypad */
#define DIK_DELETE 0xD3 /* Delete on arrow keypad */
/*
* Alternate names for keys, to facilitate transition from DOS.
*/
#define DIK_BACKSPACE DIK_BACK /* backspace */
#define DIK_NUMPADSTAR DIK_MULTIPLY /* * on numeric keypad */
#define DIK_LALT DIK_LMENU /* left Alt */
#define DIK_CAPSLOCK DIK_CAPITAL /* CapsLock */
#define DIK_NUMPADMINUS DIK_SUBTRACT /* - on numeric keypad */
#define DIK_NUMPADPLUS DIK_ADD /* + on numeric keypad */
#define DIK_NUMPADPERIOD DIK_DECIMAL /* . on numeric keypad */
#define DIK_NUMPADSLASH DIK_DIVIDE /* / on numeric keypad */
#define DIK_RALT DIK_RMENU /* right Alt */
#define DIK_UPARROW DIK_UP /* UpArrow on arrow keypad */
#define DIK_PGUP DIK_PRIOR /* PgUp on arrow keypad */
#define DIK_LEFTARROW DIK_LEFT /* LeftArrow on arrow keypad */
#define DIK_RIGHTARROW DIK_RIGHT /* RightArrow on arrow keypad */
#define DIK_DOWNARROW DIK_DOWN /* DownArrow on arrow keypad */
#define DIK_PGDN DIK_NEXT /* PgDn on arrow keypad */

View File

@ -20,7 +20,7 @@ typedef struct tHarness_platform {
// Get mouse position
int (*GetMousePosition)(int* pX, int* pY);
// Close specified window
void (*DestroyWindow)(void* window);
void (*DestroyWindow)(void);
// Process window messages, return any WM_QUIT message
void (*ProcessWindowMessages)(void);
// Set position of a window

View File

@ -7,7 +7,7 @@ static int null_set_window_pos(void* hWnd, int x, int y, int nWidth, int nHeight
return 0;
}
static void null_destroy_window(void* hWnd) {
static void null_destroy_window(void) {
null_time += 1;
}

View File

@ -128,7 +128,7 @@ static int SDL1_Harness_SetWindowPos(void* hWnd, int x, int y, int nWidth, int n
return 0;
}
static void SDL1_Harness_DestroyWindow(void* hWnd) {
static void SDL1_Harness_DestroyWindow() {
SDL1_FreeSurface(screen);
SDL1_Quit();
screen = NULL;

View File

@ -104,7 +104,7 @@ static int SDL2_Harness_SetWindowPos(void* hWnd, int x, int y, int nWidth, int n
return 0;
}
static void SDL2_Harness_DestroyWindow(void* hWnd) {
static void SDL2_Harness_DestroyWindow(void) {
// SDL2_GL_DeleteContext(context);
if (window != NULL) {
SDL2_DestroyWindow(window);