Started file, fixed issue with mouse

This commit is contained in:
neauoire 2022-03-27 10:01:06 -07:00
parent ea1ce67d05
commit c58fecb85e
8 changed files with 31 additions and 14 deletions

View File

@ -7,7 +7,7 @@ An emulator for the [Uxn stack-machine](https://wiki.xxiivv.com/site/uxn.html),
All you need is X11.
```
gcc src/uxn.c src/devices/system.c src/devices/screen.c src/devices/controller.c src/devices/mouse.c src/devices/datetime.c src/uxn11.c -DNDEBUG -Os -g0 -s -o bin/uxn11 -lX11
gcc src/uxn.c src/devices/system.c src/devices/screen.c src/devices/controller.c src/devices/mouse.c src/devices/file.c src/devices/datetime.c src/uxn11.c -DNDEBUG -Os -g0 -s -o bin/uxn11 -lX11
```
## Terminal

View File

@ -9,10 +9,10 @@ echo "Building.."
mkdir -p bin
# Build(debug)
gcc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined src/uxn.c src/devices/system.c src/devices/screen.c src/devices/controller.c src/devices/mouse.c src/devices/datetime.c src/uxn11.c -o bin/uxn11 -lX11
gcc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined src/uxn.c src/devices/system.c src/devices/screen.c src/devices/controller.c src/devices/mouse.c src/devices/file.c src/devices/datetime.c src/uxn11.c -o bin/uxn11 -lX11
# Build(release)
# gcc src/uxn.c src/devices/system.c src/devices/screen.c src/devices/controller.c src/devices/mouse.c src/devices/datetime.c src/uxn11.c -o bin/uxn11 -lX11
# gcc src/uxn.c src/devices/system.c src/devices/screen.c src/devices/controller.c src/devices/mouse.c src/devices/file.c src/devices/datetime.c src/uxn11.c -o bin/uxn11 -lX11
echo "Running.."
bin/uxn11 etc/controller.rom
bin/uxn11 etc/mouse.rom

BIN
etc/mouse.rom Normal file

Binary file not shown.

Binary file not shown.

View File

@ -1,3 +1,9 @@
#include <stdio.h>
#include <dirent.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include "../uxn.h"
#include "file.h"
@ -13,12 +19,6 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE.
*/
#include <stdio.h>
#include <dirent.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
typedef struct {
FILE *f;
DIR *dir;

View File

@ -1,8 +1,8 @@
#include <stdio.h>
#include "../uxn.h"
#include "system.h"
#include <stdio.h>
/*
Copyright (c) 2022 Devine Lu Linvega, Andrew Alderwick

View File

@ -7,6 +7,7 @@
#include "devices/screen.h"
#include "devices/controller.h"
#include "devices/mouse.h"
#include "devices/file.h"
#include "devices/datetime.h"
static XImage *ximage;
@ -33,6 +34,14 @@ system_deo_special(Device *d, Uint8 port)
screen_palette(&uxn_screen, &d->dat[0x8]);
}
static int
console_input(Uxn *u, char c)
{
Device *d = &u->dev[1];
d->dat[0x2] = c;
return uxn_eval(u, GETVECTOR(d));
}
static void
console_deo(Device *d, Uint8 port)
{
@ -129,11 +138,11 @@ processEvent(void)
} break;
case ButtonPress: {
XButtonPressedEvent *e = (XButtonPressedEvent *)&ev;
mouse_down(devmouse, e->button);
mouse_down(devmouse, 0x1 << e->button - 1);
} break;
case ButtonRelease: {
XButtonPressedEvent *e = (XButtonPressedEvent *)&ev;
mouse_up(devmouse, e->button);
mouse_up(devmouse, 0x1 << e->button - 1);
} break;
case MotionNotify: {
XMotionEvent *e = (XMotionEvent *)&ev;
@ -192,12 +201,20 @@ int
main(int argc, char **argv)
{
Uxn u;
int i;
if(argc < 2)
return error("Usage", "uxncli game.rom args");
if(!start(&u, argv[1]))
return error("Start", "Failed");
if(!init())
return error("Init", "Failed");
/* console vector */
for(i = 2; i < argc; i++) {
char *p = argv[i];
while(*p) console_input(&u, *p++);
console_input(&u, '\n');
}
/* main loop */
while(1) {
processEvent();
uxn_eval(&u, GETVECTOR(devscreen));