Factor out common parts of system_dei/deo.
This commit is contained in:
parent
c77799dac2
commit
646d79fff5
1
build.sh
1
build.sh
|
@ -14,6 +14,7 @@ then
|
||||||
echo "Formatting.."
|
echo "Formatting.."
|
||||||
clang-format -i src/uxn.h
|
clang-format -i src/uxn.h
|
||||||
clang-format -i src/uxn.c
|
clang-format -i src/uxn.c
|
||||||
|
clang-format -i src/devices/system.h
|
||||||
clang-format -i src/devices/system.c
|
clang-format -i src/devices/system.c
|
||||||
clang-format -i src/devices/screen.h
|
clang-format -i src/devices/screen.h
|
||||||
clang-format -i src/devices/screen.c
|
clang-format -i src/devices/screen.c
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "../uxn.h"
|
#include "../uxn.h"
|
||||||
|
#include "system.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
@ -27,3 +28,25 @@ uxn_halt(Uxn *u, Uint8 error, Uint16 addr)
|
||||||
fprintf(stderr, "Halted: %s#%04x, at 0x%04x\n", errors[error], u->ram[addr], addr);
|
fprintf(stderr, "Halted: %s#%04x, at 0x%04x\n", errors[error], u->ram[addr], addr);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* IO */
|
||||||
|
|
||||||
|
Uint8
|
||||||
|
system_dei(Device *d, Uint8 port)
|
||||||
|
{
|
||||||
|
switch(port) {
|
||||||
|
case 0x2: return d->u->wst.ptr;
|
||||||
|
case 0x3: return d->u->rst.ptr;
|
||||||
|
default: return d->dat[port];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
system_deo(Device *d, Uint8 port)
|
||||||
|
{
|
||||||
|
switch(port) {
|
||||||
|
case 0x2: d->u->wst.ptr = d->dat[port]; break;
|
||||||
|
case 0x3: d->u->rst.ptr = d->dat[port]; break;
|
||||||
|
default: system_deo_special(d, port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
/*
|
||||||
|
Copyright (c) 2022 Devine Lu Linvega, Andrew Alderwick
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
Uint8 system_dei(Device *d, Uint8 port);
|
||||||
|
void system_deo(Device *d, Uint8 port);
|
||||||
|
void system_deo_special(Device *d, Uint8 port);
|
21
src/uxncli.c
21
src/uxncli.c
|
@ -3,6 +3,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "uxn.h"
|
#include "uxn.h"
|
||||||
|
#include "devices/system.h"
|
||||||
#include "devices/file.h"
|
#include "devices/file.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -45,26 +46,12 @@ inspect(Stack *s, char *name)
|
||||||
|
|
||||||
#pragma mark - Devices
|
#pragma mark - Devices
|
||||||
|
|
||||||
static Uint8
|
void
|
||||||
system_dei(Device *d, Uint8 port)
|
system_deo_special(Device *d, Uint8 port)
|
||||||
{
|
{
|
||||||
switch(port) {
|
if(port == 0xe) {
|
||||||
case 0x2: return d->u->wst.ptr;
|
|
||||||
case 0x3: return d->u->rst.ptr;
|
|
||||||
default: return d->dat[port];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
system_deo(Device *d, Uint8 port)
|
|
||||||
{
|
|
||||||
switch(port) {
|
|
||||||
case 0x2: d->u->wst.ptr = d->dat[port]; break;
|
|
||||||
case 0x3: d->u->rst.ptr = d->dat[port]; break;
|
|
||||||
case 0xe:
|
|
||||||
inspect(&d->u->wst, "Working-stack");
|
inspect(&d->u->wst, "Working-stack");
|
||||||
inspect(&d->u->rst, "Return-stack");
|
inspect(&d->u->rst, "Return-stack");
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
19
src/uxnemu.c
19
src/uxnemu.c
|
@ -8,6 +8,7 @@
|
||||||
#pragma GCC diagnostic ignored "-Wpedantic"
|
#pragma GCC diagnostic ignored "-Wpedantic"
|
||||||
#pragma clang diagnostic ignored "-Wtypedef-redefinition"
|
#pragma clang diagnostic ignored "-Wtypedef-redefinition"
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
#include "devices/system.h"
|
||||||
#include "devices/screen.h"
|
#include "devices/screen.h"
|
||||||
#include "devices/audio.h"
|
#include "devices/audio.h"
|
||||||
#include "devices/file.h"
|
#include "devices/file.h"
|
||||||
|
@ -169,23 +170,9 @@ init(void)
|
||||||
|
|
||||||
#pragma mark - Devices
|
#pragma mark - Devices
|
||||||
|
|
||||||
static Uint8
|
void
|
||||||
system_dei(Device *d, Uint8 port)
|
system_deo_special(Device *d, Uint8 port)
|
||||||
{
|
{
|
||||||
switch(port) {
|
|
||||||
case 0x2: return d->u->wst.ptr;
|
|
||||||
case 0x3: return d->u->rst.ptr;
|
|
||||||
default: return d->dat[port];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
system_deo(Device *d, Uint8 port)
|
|
||||||
{
|
|
||||||
switch(port) {
|
|
||||||
case 0x2: d->u->wst.ptr = d->dat[port]; break;
|
|
||||||
case 0x3: d->u->rst.ptr = d->dat[port]; break;
|
|
||||||
}
|
|
||||||
if(port > 0x7 && port < 0xe)
|
if(port > 0x7 && port < 0xe)
|
||||||
screen_palette(&uxn_screen, &d->dat[0x8]);
|
screen_palette(&uxn_screen, &d->dat[0x8]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue