fix include errors, include correct libraries
include 🐛 are finally gone yay it was just a matter of using the right libraries
This commit is contained in:
@@ -7,14 +7,11 @@
|
|||||||
//#define __UNIX
|
//#define __UNIX
|
||||||
|
|
||||||
/* universal libraries */
|
/* universal libraries */
|
||||||
#include <stdio.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <signal.h>
|
||||||
#include <string.h>
|
|
||||||
#include <signal.h>
|
|
||||||
|
|
||||||
/* unix only libraries */
|
/* unix only libraries */
|
||||||
// FIXME: solve include errors
|
|
||||||
#ifdef __UNIX
|
#ifdef __UNIX
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@@ -24,11 +21,16 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/termios.h>
|
#include <sys/termios.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
/* windows only */
|
||||||
|
#else
|
||||||
|
#include <Windows.h>
|
||||||
|
#include <conio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TRUE 1
|
#define TRUE 1
|
||||||
#define FALSE 0
|
#define FALSE 0
|
||||||
|
|
||||||
|
HANDLE hStdin = INVALID_HANDLE_VALUE;
|
||||||
|
|
||||||
/* memory mapped register tables */
|
/* memory mapped register tables */
|
||||||
enum mmr {
|
enum mmr {
|
||||||
@@ -168,7 +170,6 @@ void mem_write(uint16_t address, uint16_t val) {
|
|||||||
memory[address] = val;
|
memory[address] = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void mem_read(uint16_t address) {
|
void mem_read(uint16_t address) {
|
||||||
if(address == MMR_KSR) {
|
if(address == MMR_KSR) {
|
||||||
if(check_key()) {
|
if(check_key()) {
|
||||||
@@ -196,9 +197,36 @@ void mem_read(uint16_t address) {
|
|||||||
tcsetattr(STDIN_FILENO, TCSANOW, &original_tio);
|
tcsetattr(STDIN_FILENO, TCSANOW, &original_tio);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
DWORD fdwMode, fdwOldMode;
|
||||||
|
|
||||||
|
void disable_input_buffering()
|
||||||
|
{
|
||||||
|
hStdin = GetStdHandle(STD_INPUT_HANDLE);
|
||||||
|
GetConsoleMode(hStdin, &fdwOldMode); // save old mode
|
||||||
|
fdwMode = fdwOldMode
|
||||||
|
^ ENABLE_ECHO_INPUT // no input echo
|
||||||
|
^ ENABLE_LINE_INPUT; // return when one or more characters are available
|
||||||
|
SetConsoleMode(hStdin, fdwMode); // set new mode
|
||||||
|
FlushConsoleInputBuffer(hStdin); // clear buffer
|
||||||
|
}
|
||||||
|
|
||||||
|
void restore_input_buffering()
|
||||||
|
{
|
||||||
|
SetConsoleMode(hStdin, fdwOldMode);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __UNIX
|
||||||
|
void handle_interrupt(int signal) {
|
||||||
|
restore_input_buffering();
|
||||||
|
printf("\n");
|
||||||
|
exit(-2);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, const char* argv[]) {
|
int main(int argc, const char* argv[]) {
|
||||||
|
|
||||||
if(argc < 2) {
|
if(argc < 2) {
|
||||||
|
|||||||
Reference in New Issue
Block a user