Skip to content

Commit

Permalink
console.h isolation
Browse files Browse the repository at this point in the history
  • Loading branch information
ogamespec committed Jul 20, 2023
1 parent 62f17ca commit 254f960
Show file tree
Hide file tree
Showing 11 changed files with 146 additions and 187 deletions.
40 changes: 0 additions & 40 deletions src/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1188,46 +1188,6 @@ static int command_misc(char *p,char *tp)
return(1);
}

void command_fkey(int a)
{
switch(a)
{
case KEY_F1:
view_changed(VIEW_RESIZE);
// view.shrink^=1;
view.showhelp^=1;
break;
case KEY_F2:
view.active=WIN_DATA;
break;
case KEY_F3:
view.active=WIN_CODE;
break;
case KEY_F4:
view.active=WIN_CONS;
break;
case KEY_F5:
command("go");
break;
case KEY_F6:
command("regs");
break;
case KEY_F7:
command("f 1");
break;
case KEY_F8:
command("s 1");
break;
case KEY_F9:
command("n");
break;
case KEY_F12:
print("3dfx screen flipped.\n");
rdp_togglefullscreen();
break;
}
}

void command(char *cmd)
{
char *tp,*p,*cs,*cd;
Expand Down
3 changes: 0 additions & 3 deletions src/cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@
// execute a command, ';' acts as a command separator for multiple commands
// quotes etc are not supported, so ';' inside a quote is still a separator!
void command(char* cmd);

// execute commands bound to a function key (keycodes as in console.h)
void command_fkey(int key);
5 changes: 5 additions & 0 deletions src/console.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// Win32 Console code is not exported externally, but is entirely dependent on the console implementation of debugui.
// This is done so that debugui can be ported to other engines, like imgui.

#pragma once

void con_init(void);
void con_initdummy(void);
void con_deinit(void);
Expand Down
2 changes: 1 addition & 1 deletion src/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ void cpu_keys(int dopad)
st.pause=0;
stopnow=1;
}
else if(key && dopad) pad_misckey(key);
else if(key && dopad) debugui_misckey(key);
}

if(stopnow==1)
Expand Down
2 changes: 0 additions & 2 deletions src/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,6 @@ typedef struct
char savepath[MAXFILE]; // default path for saves
char rompath[MAXFILE]; // default path for rom search

int oldkeyb;

int viewportwid;
int viewporthig;
} Init;
Expand Down
131 changes: 131 additions & 0 deletions src/debugui.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "stdsdk.h"
#include "console.h"
extern HWND hwndStatus;
extern char szBuffer[];

Expand Down Expand Up @@ -957,6 +958,47 @@ void conkey(int a)
view_changed(VIEW_CONS);
}

// execute commands bound to a function key (keycodes as in console.h)
void command_fkey(int a)
{
switch(a)
{
case KEY_F1:
view_changed(VIEW_RESIZE);
// view.shrink^=1;
view.showhelp^=1;
break;
case KEY_F2:
view.active=WIN_DATA;
break;
case KEY_F3:
view.active=WIN_CODE;
break;
case KEY_F4:
view.active=WIN_CONS;
break;
case KEY_F5:
command("go");
break;
case KEY_F6:
command("regs");
break;
case KEY_F7:
command("f 1");
break;
case KEY_F8:
command("s 1");
break;
case KEY_F9:
command("n");
break;
case KEY_F12:
print("3dfx screen flipped.\n");
rdp_togglefullscreen();
break;
}
}

void debugui_key(int a)
{
int flag=1;
Expand Down Expand Up @@ -985,6 +1027,95 @@ void breakcommand(char *cmd)
cpu_nicebreak();
}

void debugui_misckey(int key)
{ // called from cpu.c user interface check
int down;

if(key&KEY_RELEASE) down=0; else down=1;
key&=0xfff;
if(key>32 && key<256) key=toupper(key);

if((!rdp_gfxactive() || st.keyboarddisable) && key!=KEY_F12) return;

if(init.showconsole) switch(key)
{
case 'W': if(down)
{
showwire^=1;
} break;
case 'Q': if(down)
{
showinfo^=1;
} break;
case 'E': if(down)
{
showtest++;
if(showtest>3) showtest=0;
} break;
case 'R': if(down)
{
showtest2++;
if(showtest2>7) showtest2=0;
} break;
case KEY_F10:
case KEY_F11:
case KEY_F12:
if(down)
{
rdp_togglefullscreen();
} break;
case KEY_F6:
if(st.pause) st.pause=0;
if(down)
{
breakcommand("save;go");
}
break;
case KEY_F8:
if(down)
{
st.pause^=1;
if(st.pause)
{
if(st2.audioon)
{
st2.audioon=0;
sound_stop();
}
}
}
break;
case KEY_F9:
if(st.pause) st.pause=0;
if(down)
{
breakcommand("load;go");
}
if(st.pause) st.pause=0;
break;
case KEY_F3:
case KEY_F4:
if(down)
{
if(key==KEY_F3)
{
joyactive^=1;
if(joyactive) mouseactive=0;
}
else
{
mouseactive^=1;
if(mouseactive) joyactive=0;
}
mousedisablecnt=0;
print("Joystick (F5) %s, Mouse (F6) %s\n",
joyactive?"enabled ":"disabled",
mouseactive?"enabled ":"disabled");
flushdisplay();
} break;
}
}

/****************************************************************************
** Main loop
*/
Expand Down
1 change: 1 addition & 0 deletions src/debugui.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,4 @@ void flushdisplay(void); // redraw debug console
void debugui(void); // main debugui-loop

void breakcommand(char* cmd); // breaks nicely at next retrace, and then executes
void debugui_misckey(int key); // tell a key has been pressed (keycodes as in console.h)
4 changes: 0 additions & 4 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ void help(void)
" of just flipping screen (for Banshee)\n"
"-n no file mapping for preflipped roms (load whole rom)\n"
"-c show console\n"
"-k use old keyboard code (ONLY WORKS WITH CONSOLE!)\n"
,"UltraHLE",MB_OK);
}
}
Expand Down Expand Up @@ -372,9 +371,6 @@ void main_startup(void)
case 'c':
init.showconsole=1;
break;
case 'k':
init.oldkeyb=1;
break;
case 'n':
init.nomemmap=1;
break;
Expand Down
Loading

0 comments on commit 254f960

Please sign in to comment.