Files
pasm/api.c
ALittlePatate a97fde9f86 first commit of the recode
70% of the code was re-writter from scratch
2024-01-18 16:01:04 +01:00

33 lines
672 B
C

#include "api.h"
#include "interpreter_states.h"
#ifdef _WIN32 //windows only apis
#include <Windows.h>
#endif
#include <stdio.h>
void api_put() {
int mode = state->STACK[state->STACK_IDX--]; // 1 for char, 2 for num
if (mode != 1 && mode != 2) return;
if (mode == 1) {
char c = state->STACK[state->STACK_IDX--];
if (c == '\0') c = ' ';
printf("%c", c); //using printf and not write because of the buffer
}
else {
printf("%d", state->STACK[state->STACK_IDX--]);
}
}
void api_getasynckeystate() {
#ifdef _WIN32
eax = GetAsyncKeyState(state->STACK[STACK_IDX--]);
#else
state->STACK_IDX--;
state->registers->eax = 1;
#endif
}