Starting a debugging device
This commit is contained in:
parent
6a6a2ec383
commit
ee4308196a
6
build.sh
6
build.sh
|
@ -60,6 +60,8 @@ then
|
||||||
clang-format -i src/devices/controller.c
|
clang-format -i src/devices/controller.c
|
||||||
clang-format -i src/devices/datetime.h
|
clang-format -i src/devices/datetime.h
|
||||||
clang-format -i src/devices/datetime.c
|
clang-format -i src/devices/datetime.c
|
||||||
|
clang-format -i src/devices/debug.h
|
||||||
|
clang-format -i src/devices/debug.c
|
||||||
clang-format -i src/uxnasm.c
|
clang-format -i src/uxnasm.c
|
||||||
clang-format -i src/uxnemu.c
|
clang-format -i src/uxnemu.c
|
||||||
clang-format -i src/uxncli.c
|
clang-format -i src/uxncli.c
|
||||||
|
@ -98,8 +100,8 @@ fi
|
||||||
|
|
||||||
echo "Building.."
|
echo "Building.."
|
||||||
${CC} ${CFLAGS} src/uxnasm.c -o bin/uxnasm
|
${CC} ${CFLAGS} src/uxnasm.c -o bin/uxnasm
|
||||||
${CC} ${CFLAGS} ${CORE} src/devices/system.c src/devices/file.c src/devices/datetime.c src/devices/mouse.c src/devices/controller.c src/devices/screen.c src/devices/audio.c src/uxnemu.c ${UXNEMU_LDFLAGS} -o bin/uxnemu
|
${CC} ${CFLAGS} ${CORE} src/devices/system.c src/devices/file.c src/devices/datetime.c src/devices/debug.c src/devices/mouse.c src/devices/controller.c src/devices/screen.c src/devices/audio.c src/uxnemu.c ${UXNEMU_LDFLAGS} -o bin/uxnemu
|
||||||
${CC} ${CFLAGS} ${CORE} src/devices/system.c src/devices/file.c src/devices/datetime.c src/uxncli.c -o bin/uxncli
|
${CC} ${CFLAGS} ${CORE} src/devices/system.c src/devices/file.c src/devices/datetime.c src/devices/debug.c src/uxncli.c -o bin/uxncli
|
||||||
|
|
||||||
if [ -d "$HOME/bin" ]
|
if [ -d "$HOME/bin" ]
|
||||||
then
|
then
|
||||||
|
|
7
mkfile
7
mkfile
|
@ -9,6 +9,7 @@ HFILES=\
|
||||||
src/devices/audio.h\
|
src/devices/audio.h\
|
||||||
src/devices/controller.h\
|
src/devices/controller.h\
|
||||||
src/devices/datetime.h\
|
src/devices/datetime.h\
|
||||||
|
src/devices/debug.h\
|
||||||
src/devices/file.h\
|
src/devices/file.h\
|
||||||
src/devices/mouse.h\
|
src/devices/mouse.h\
|
||||||
src/devices/screen.h\
|
src/devices/screen.h\
|
||||||
|
@ -33,19 +34,19 @@ bin:
|
||||||
%.rom:Q: %.tal bin/uxnasm
|
%.rom:Q: %.tal bin/uxnasm
|
||||||
bin/uxnasm $stem.tal $target >/dev/null
|
bin/uxnasm $stem.tal $target >/dev/null
|
||||||
|
|
||||||
bin/uxncli: file.$O datetime.$O system.$O uxncli.$O uxn.$O
|
bin/uxncli: file.$O datetime.$O debug.$O system.$O uxncli.$O uxn.$O
|
||||||
$LD $LDFLAGS -o $target $prereq
|
$LD $LDFLAGS -o $target $prereq
|
||||||
|
|
||||||
bin/uxnasm: uxnasm.$O
|
bin/uxnasm: uxnasm.$O
|
||||||
$LD $LDFLAGS -o $target $prereq
|
$LD $LDFLAGS -o $target $prereq
|
||||||
|
|
||||||
bin/uxnemu: audio.$O controller.$O datetime.$O file.$O mouse.$O screen.$O system.$O uxn.$O uxnemu.$O
|
bin/uxnemu: audio.$O controller.$O datetime.$O debug.$O file.$O mouse.$O screen.$O system.$O uxn.$O uxnemu.$O
|
||||||
$LD $LDFLAGS -o $target $prereq
|
$LD $LDFLAGS -o $target $prereq
|
||||||
|
|
||||||
(uxnasm|uxncli|uxnemu|uxn)\.$O:R: src/\1.c
|
(uxnasm|uxncli|uxnemu|uxn)\.$O:R: src/\1.c
|
||||||
$CC $CFLAGS -Isrc -o $target src/$stem1.c
|
$CC $CFLAGS -Isrc -o $target src/$stem1.c
|
||||||
|
|
||||||
(audio|controller|datetime|file|mouse|screen|system)\.$O:R: src/devices/\1.c
|
(audio|controller|datetime|debug|file|mouse|screen|system)\.$O:R: src/devices/\1.c
|
||||||
$CC $CFLAGS -Isrc -o $target src/devices/$stem1.c
|
$CC $CFLAGS -Isrc -o $target src/devices/$stem1.c
|
||||||
|
|
||||||
nuke:V: clean
|
nuke:V: clean
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "../uxn.h"
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
Copyright (c) 2021 Devine Lu Linvega
|
||||||
|
Copyright (c) 2021 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
inspect(Stack *s, char *name)
|
||||||
|
{
|
||||||
|
Uint8 x, y;
|
||||||
|
fprintf(stderr, "\n%s\n", name);
|
||||||
|
for(y = 0; y < 0x04; y++) {
|
||||||
|
for(x = 0; x < 0x08; x++) {
|
||||||
|
Uint8 p = y * 0x08 + x;
|
||||||
|
fprintf(stderr,
|
||||||
|
p == s->ptr ? "[%02x]" : " %02x ",
|
||||||
|
s->dat[p]);
|
||||||
|
}
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* IO */
|
||||||
|
|
||||||
|
Uint8
|
||||||
|
debug_dei(Device *d, Uint8 port)
|
||||||
|
{
|
||||||
|
DebugDevice *debug = (DebugDevice *)d;
|
||||||
|
return d->dat[port];
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
debug_deo(Device *d, Uint8 port)
|
||||||
|
{
|
||||||
|
(void)d;
|
||||||
|
(void)port;
|
||||||
|
inspect(&d->u->wst, "Working-stack");
|
||||||
|
inspect(&d->u->rst, "Return-stack");
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
/*
|
||||||
|
Copyright (c) 2021 Devine Lu Linvega
|
||||||
|
Copyright (c) 2021 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct DebugDevice {
|
||||||
|
Device device;
|
||||||
|
struct UxnScreen *screen;
|
||||||
|
} DebugDevice;
|
||||||
|
|
||||||
|
Uint8 debug_dei(Device *d, Uint8 port);
|
||||||
|
void debug_deo(Device *d, Uint8 port);
|
|
@ -37,7 +37,7 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct Device {
|
typedef struct Device {
|
||||||
struct Uxn *u;
|
struct Uxn *u;
|
||||||
Uint8 dat[16], *mem;
|
Uint8 dat[16];
|
||||||
Uint8 (*dei)(struct Device *d, Uint8);
|
Uint8 (*dei)(struct Device *d, Uint8);
|
||||||
void (*deo)(struct Device *d, Uint8);
|
void (*deo)(struct Device *d, Uint8);
|
||||||
} Device;
|
} Device;
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "devices/system.h"
|
#include "devices/system.h"
|
||||||
#include "devices/file.h"
|
#include "devices/file.h"
|
||||||
#include "devices/datetime.h"
|
#include "devices/datetime.h"
|
||||||
|
#include "devices/debug.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2021 Devine Lu Linvega
|
Copyright (c) 2021 Devine Lu Linvega
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "devices/controller.h"
|
#include "devices/controller.h"
|
||||||
#include "devices/mouse.h"
|
#include "devices/mouse.h"
|
||||||
#include "devices/datetime.h"
|
#include "devices/datetime.h"
|
||||||
|
#include "devices/debug.h"
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
|
|
||||||
|
@ -279,11 +280,9 @@ start(Uxn *u, char *rom)
|
||||||
/* unused */ uxn_port(u, 0xc, nil_dei, nil_deo);
|
/* unused */ uxn_port(u, 0xc, nil_dei, nil_deo);
|
||||||
/* unused */ uxn_port(u, 0xd, nil_dei, nil_deo);
|
/* unused */ uxn_port(u, 0xd, nil_dei, nil_deo);
|
||||||
/* unused */ uxn_port(u, 0xe, nil_dei, nil_deo);
|
/* unused */ uxn_port(u, 0xe, nil_dei, nil_deo);
|
||||||
/* unused */ uxn_port(u, 0xf, nil_dei, nil_deo);
|
/* unused */ uxn_port(u, 0xf, debug_dei, debug_deo);
|
||||||
|
|
||||||
if(!uxn_eval(u, PAGE_PROGRAM))
|
if(!uxn_eval(u, PAGE_PROGRAM))
|
||||||
return error("Boot", "Failed to start rom.");
|
return error("Boot", "Failed to start rom.");
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue