diff options
author | qwx <devnull@localhost> | 2018-05-13 07:01:47 +0200 |
---|---|---|
committer | qwx <devnull@localhost> | 2018-05-13 07:01:47 +0200 |
commit | 88537cfe9b483846ccd7367c81fde5dcfe16a4d5 (patch) | |
tree | 29277160129a844585f281045b368cd64776d8a2 | |
parent | abf8c8bf2cd27541d6a102f7c0385c3fe281f578 (diff) |
demote libemu to common code
- too small, nothing else that won't be under /games will use it
- "libemu" as a name doesn't make sense here
44 files changed, 75 insertions, 192 deletions
diff --git a/sys/man/2/emu b/sys/man/2/emu deleted file mode 100644 index 68026416b..000000000 --- a/sys/man/2/emu +++ /dev/null @@ -1,137 +0,0 @@ -.TH EMU 2 -.SH NAME -initemu, regkeyfn, flushmouse, flushscreen, flushaudio, screenwipe \- graphical emulator-like software scaffolding -.SH SYNOPSIS -.nf -.ft L -#include <u.h> -#include <libc.h> -#include <emu.h> -.PP -.ta +\w'\fLvoid fP'u -.B -void flushmouse(int discard); -.PP -.B -void flushscreen(void); -.PP -.B -void flushaudio(int (*fn)(void)); -.PP -.B -void regkeyfn(Rune r, void (*fn)(void)); -.PP -.B -void regkey(char *joyk, Rune r, int k); -.PP -.B -void initemu(int dx, int dy, int bpp, ulong chan, -.B - int dokey, void(*kproc)(void*)); -.SH DESCRIPTION -.I Libemu -implements common user interfaces for programs controlled -with a joypad or a limited number of keys. -.PP -.B initemu -initializes the display for the given internal screen size -.B dx -by -.B dy -and -.B bpp -bit depth. -.B Chan -is an -.B Image -pixel format descriptor to be used for an internal framebuffer (see -.IR draw (2)). -.PP -If -.B dokey -is true, -a keyboard process is started which sets a 64-bit wide bit vector for input keys. -.PP -Keys are set via -.B regkey. -Pressing the key corresponding to the -.B r -rune, or writing -.B joyk -to standard in will -.L OR -.B k -with the key bit vector. -.PP -.B Regkeyfn -registers an additional rune and a callback for the keyboard process. -.PP -Normally, a joypad process is also started, and parses standard input for key presses. -If -.B dokey -is false, only the joypad process will be started. -If -.B kproc -is a valid function pointer, -it will be used for keyboard processing instead of the library-provided one, -and no joypad process will be started. -.PP -.IP -.EX -.ta 6n -uchar *pic; -.EE -.PP -Once -.B initemu -is called, a framebuffer of the specifized size is allocated, -and may be accessed via -.BR pic . -.L Libemu -scales the framebuffer to fit the greatest multiple of the framebuffer's -width in the window. -The scaling is horizontal only and needs to be taken into account for drawing -within the program. -.PP -Typically, mouse event handling is followed by drawing the final image from the -internal framebuffer render and writing a constant amount of audio samples, -thereby synchronizing the program's framerate to the audio writes. -.IP -.EX -.ta 6n -Mouse m; -extern Mousectl *mc; - -flushmouse(0); -while(nbrecv(mc->c, &m) > 0){ - ... -} -flushscreen(); -flushaudio(audioout); -.EE -.PP -Besides window resizing, mouse events are discarded by default. -If -.B discard -is false -.B flushmouse -will let the user program handle mouse events prior to flushing the screen (see -.BR event (2)). -.PP -.B Flushscreen -handles re-scaling and re-allocating the buffers used, as well as drawing to -the screen, either directly, or by duplicating pre-scaled scanlines. -.SH SOURCE -.B /sys/src/libemu -.SH "SEE ALSO" -.IR draw (2), -.IR event (2) -.SH BUGS -The semantics for -.B initemu -input selection are confusing. -.PP -A greater effort should be made to simplify automatic scaling for user programs. -.SH HISTORY -.I Libemu -first appeared in 9front in May, 2018. diff --git a/sys/src/games/2600/2600.c b/sys/src/games/2600/2600.c index 38d7c856f..728401d89 100644 --- a/sys/src/games/2600/2600.c +++ b/sys/src/games/2600/2600.c @@ -3,7 +3,7 @@ #include <thread.h> #include <draw.h> #include <keyboard.h> -#include <emu.h> +#include "../eui.h" #include "dat.h" #include "fns.h" diff --git a/sys/src/games/2600/cpu.c b/sys/src/games/2600/cpu.c index 4dedfb9eb..66842f292 100644 --- a/sys/src/games/2600/cpu.c +++ b/sys/src/games/2600/cpu.c @@ -1,6 +1,6 @@ #include <u.h> #include <libc.h> -#include <emu.h> +#include "../eui.h" #include "dat.h" #include "fns.h" diff --git a/sys/src/games/2600/mem.c b/sys/src/games/2600/mem.c index be24a17e1..c521915b2 100644 --- a/sys/src/games/2600/mem.c +++ b/sys/src/games/2600/mem.c @@ -1,6 +1,6 @@ #include <u.h> #include <libc.h> -#include <emu.h> +#include "../eui.h" #include "dat.h" #include "fns.h" diff --git a/sys/src/games/2600/mkfile b/sys/src/games/2600/mkfile index df08bd2d8..1b1657e07 100644 --- a/sys/src/games/2600/mkfile +++ b/sys/src/games/2600/mkfile @@ -8,7 +8,10 @@ OFILES=\ cpu.$O\ mem.$O\ tia.$O\ + eui.$O\ HFILES=dat.h fns.h </sys/src/cmd/mkone +eui.$O: ../eui.c + $CC $CFLAGS ../eui.c diff --git a/sys/src/games/2600/tia.c b/sys/src/games/2600/tia.c index 3819fedaa..8c4902761 100644 --- a/sys/src/games/2600/tia.c +++ b/sys/src/games/2600/tia.c @@ -1,6 +1,6 @@ #include <u.h> #include <libc.h> -#include <emu.h> +#include "../eui.h" #include "dat.h" #include "fns.h" diff --git a/sys/src/games/c64/c64.c b/sys/src/games/c64/c64.c index 9b4e0504b..2ca976fe7 100644 --- a/sys/src/games/c64/c64.c +++ b/sys/src/games/c64/c64.c @@ -4,7 +4,7 @@ #include <draw.h> #include <mouse.h> #include <keyboard.h> -#include <emu.h> +#include "../eui.h" #include "dat.h" #include "fns.h" diff --git a/sys/src/games/c64/cpu.c b/sys/src/games/c64/cpu.c index cafd8e333..3a24e7783 100644 --- a/sys/src/games/c64/cpu.c +++ b/sys/src/games/c64/cpu.c @@ -1,6 +1,6 @@ #include <u.h> #include <libc.h> -#include <emu.h> +#include "../eui.h" #include "dat.h" #include "fns.h" diff --git a/sys/src/games/c64/mem.c b/sys/src/games/c64/mem.c index 8e00bec4b..6d0682b7a 100644 --- a/sys/src/games/c64/mem.c +++ b/sys/src/games/c64/mem.c @@ -1,7 +1,7 @@ #include <u.h> #include <libc.h> #include <thread.h> -#include <emu.h> +#include "../eui.h" #include "dat.h" #include "fns.h" diff --git a/sys/src/games/c64/mkfile b/sys/src/games/c64/mkfile index af2ff2913..27d7f2641 100644 --- a/sys/src/games/c64/mkfile +++ b/sys/src/games/c64/mkfile @@ -7,7 +7,10 @@ OFILES=\ cpu.$O\ mem.$O\ vic.$O\ - + eui.$O\ + HFILES=dat.h fns.h </sys/src/cmd/mkone +eui.$O: ../eui.c + $CC $CFLAGS ../eui.c diff --git a/sys/src/games/c64/vic.c b/sys/src/games/c64/vic.c index c181b2446..eba617843 100644 --- a/sys/src/games/c64/vic.c +++ b/sys/src/games/c64/vic.c @@ -1,7 +1,7 @@ #include <u.h> #include <libc.h> #include <thread.h> -#include <emu.h> +#include "../eui.h" #include "dat.h" #include "fns.h" diff --git a/sys/src/libemu/emu.c b/sys/src/games/eui.c index 908727b75..d462c76d8 100644 --- a/sys/src/libemu/emu.c +++ b/sys/src/games/eui.c @@ -4,7 +4,7 @@ #include <draw.h> #include <keyboard.h> #include <mouse.h> -#include <emu.h> +#include "eui.h" typedef struct Kfn Kfn; diff --git a/sys/src/games/eui.h b/sys/src/games/eui.h new file mode 100644 index 000000000..949cf7cb2 --- /dev/null +++ b/sys/src/games/eui.h @@ -0,0 +1,19 @@ +enum{ + MILLION = 1000000, + BILLION = 1000000000, +}; + +extern u64int keys, keys2; +extern int trace, paused; +extern int savereq, loadreq; +extern QLock pauselock; +extern int scale, warp10; +extern uchar *pic; + +void* emalloc(ulong); +void flushmouse(int); +void flushscreen(void); +void flushaudio(int(*)(void)); +void regkeyfn(Rune, void(*)(void)); +void regkey(char*, Rune, int); +void initemu(int, int, int, ulong, int, void(*)(void*)); diff --git a/sys/src/games/gb/apu.c b/sys/src/games/gb/apu.c index dc78992ac..900f7e793 100644 --- a/sys/src/games/gb/apu.c +++ b/sys/src/games/gb/apu.c @@ -1,7 +1,7 @@ #include <u.h> #include <libc.h> #include <thread.h> -#include <emu.h> +#include "../eui.h" #include "dat.h" #include "fns.h" diff --git a/sys/src/games/gb/cpu.c b/sys/src/games/gb/cpu.c index 81c45a034..bff692d02 100644 --- a/sys/src/games/gb/cpu.c +++ b/sys/src/games/gb/cpu.c @@ -1,7 +1,7 @@ #include <u.h> #include <libc.h> #include <thread.h> -#include <emu.h> +#include "../eui.h" #include "dat.h" #include "fns.h" diff --git a/sys/src/games/gb/gb.c b/sys/src/games/gb/gb.c index 55ced730a..b82729023 100644 --- a/sys/src/games/gb/gb.c +++ b/sys/src/games/gb/gb.c @@ -3,7 +3,7 @@ #include <thread.h> #include <draw.h> #include <keyboard.h> -#include <emu.h> +#include "../eui.h" #include "dat.h" #include "fns.h" diff --git a/sys/src/games/gb/mem.c b/sys/src/games/gb/mem.c index a6c6c7599..44a10820c 100644 --- a/sys/src/games/gb/mem.c +++ b/sys/src/games/gb/mem.c @@ -1,7 +1,7 @@ #include <u.h> #include <libc.h> #include <thread.h> -#include <emu.h> +#include "../eui.h" #include "dat.h" #include "fns.h" diff --git a/sys/src/games/gb/mkfile b/sys/src/games/gb/mkfile index b9e767497..80f1d0110 100644 --- a/sys/src/games/gb/mkfile +++ b/sys/src/games/gb/mkfile @@ -10,7 +10,10 @@ OFILES=\ ev.$O\ state.$O\ apu.$O\ + eui.$O\ HFILES=dat.h fns.h </sys/src/cmd/mkone +eui.$O: ../eui.c + $CC $CFLAGS ../eui.c diff --git a/sys/src/games/gb/ppu.c b/sys/src/games/gb/ppu.c index 389581621..433c12270 100644 --- a/sys/src/games/gb/ppu.c +++ b/sys/src/games/gb/ppu.c @@ -1,7 +1,7 @@ #include <u.h> #include <libc.h> #include <thread.h> -#include <emu.h> +#include "../eui.h" #include "dat.h" #include "fns.h" diff --git a/sys/src/games/gba/apu.c b/sys/src/games/gba/apu.c index 4858aced9..31c0f7682 100644 --- a/sys/src/games/gba/apu.c +++ b/sys/src/games/gba/apu.c @@ -1,7 +1,7 @@ #include <u.h> #include <libc.h> #include <thread.h> -#include <emu.h> +#include "../eui.h" #include "dat.h" #include "fns.h" diff --git a/sys/src/games/gba/cpu.c b/sys/src/games/gba/cpu.c index a8354324f..e4f42542e 100644 --- a/sys/src/games/gba/cpu.c +++ b/sys/src/games/gba/cpu.c @@ -1,7 +1,7 @@ #include <u.h> #include <libc.h> #include <thread.h> -#include <emu.h> +#include "../eui.h" #include "dat.h" #include "fns.h" diff --git a/sys/src/games/gba/gba.c b/sys/src/games/gba/gba.c index 06e90b998..ec8c1bc7a 100644 --- a/sys/src/games/gba/gba.c +++ b/sys/src/games/gba/gba.c @@ -3,7 +3,7 @@ #include <thread.h> #include <draw.h> #include <keyboard.h> -#include <emu.h> +#include "../eui.h" #include "dat.h" #include "fns.h" diff --git a/sys/src/games/gba/mem.c b/sys/src/games/gba/mem.c index 032f35eae..c5a56abbb 100644 --- a/sys/src/games/gba/mem.c +++ b/sys/src/games/gba/mem.c @@ -1,7 +1,7 @@ #include <u.h> #include <libc.h> #include <thread.h> -#include <emu.h> +#include "../eui.h" #include "dat.h" #include "fns.h" diff --git a/sys/src/games/gba/mkfile b/sys/src/games/gba/mkfile index b519b2376..0d12ae943 100644 --- a/sys/src/games/gba/mkfile +++ b/sys/src/games/gba/mkfile @@ -10,7 +10,10 @@ OFILES=\ ev.$O\ apu.$O\ state.$O\ + eui.$O\ HFILES=dat.h fns.h </sys/src/cmd/mkone +eui.$O: ../eui.c + $CC $CFLAGS ../eui.c diff --git a/sys/src/games/gba/ppu.c b/sys/src/games/gba/ppu.c index 7de5a1e7b..b70aba8fb 100644 --- a/sys/src/games/gba/ppu.c +++ b/sys/src/games/gba/ppu.c @@ -1,7 +1,7 @@ #include <u.h> #include <libc.h> #include <thread.h> -#include <emu.h> +#include "../eui.h" #include "dat.h" #include "fns.h" diff --git a/sys/src/games/md/cpu.c b/sys/src/games/md/cpu.c index 1a0325f52..6a223c3b1 100644 --- a/sys/src/games/md/cpu.c +++ b/sys/src/games/md/cpu.c @@ -1,7 +1,7 @@ #include <u.h> #include <libc.h> #include <thread.h> -#include <emu.h> +#include "../eui.h" #include "dat.h" #include "fns.h" diff --git a/sys/src/games/md/md.c b/sys/src/games/md/md.c index 557668dc7..2c0ed3fda 100644 --- a/sys/src/games/md/md.c +++ b/sys/src/games/md/md.c @@ -3,7 +3,7 @@ #include <thread.h> #include <draw.h> #include <keyboard.h> -#include <emu.h> +#include "../eui.h" #include "dat.h" #include "fns.h" diff --git a/sys/src/games/md/mem.c b/sys/src/games/md/mem.c index 083abaa29..323632d12 100644 --- a/sys/src/games/md/mem.c +++ b/sys/src/games/md/mem.c @@ -1,7 +1,7 @@ #include <u.h> #include <libc.h> #include <thread.h> -#include <emu.h> +#include "../eui.h" #include "dat.h" #include "fns.h" diff --git a/sys/src/games/md/mkfile b/sys/src/games/md/mkfile index b8363745a..7cad014fc 100644 --- a/sys/src/games/md/mkfile +++ b/sys/src/games/md/mkfile @@ -9,7 +9,10 @@ OFILES=\ vdp.$O\ z80.$O\ ym.$O\ + eui.$O\ HFILES=dat.h fns.h </sys/src/cmd/mkone +eui.$O: ../eui.c + $CC $CFLAGS ../eui.c diff --git a/sys/src/games/md/vdp.c b/sys/src/games/md/vdp.c index 51d5f20a1..b3b7553f8 100644 --- a/sys/src/games/md/vdp.c +++ b/sys/src/games/md/vdp.c @@ -1,7 +1,7 @@ #include <u.h> #include <libc.h> #include <thread.h> -#include <emu.h> +#include "../eui.h" #include "dat.h" #include "fns.h" diff --git a/sys/src/games/md/ym.c b/sys/src/games/md/ym.c index ca3988433..6d6031958 100644 --- a/sys/src/games/md/ym.c +++ b/sys/src/games/md/ym.c @@ -1,7 +1,7 @@ #include <u.h> #include <libc.h> #include <thread.h> -#include <emu.h> +#include "../eui.h" #include "dat.h" #include "fns.h" diff --git a/sys/src/games/nes/apu.c b/sys/src/games/nes/apu.c index 52e8e36b5..1db370fde 100644 --- a/sys/src/games/nes/apu.c +++ b/sys/src/games/nes/apu.c @@ -2,7 +2,7 @@ #include <libc.h> #include <thread.h> #include <draw.h> -#include <emu.h> +#include "../eui.h" #include "dat.h" #include "fns.h" diff --git a/sys/src/games/nes/mem.c b/sys/src/games/nes/mem.c index 52e3162ba..cfa71a987 100644 --- a/sys/src/games/nes/mem.c +++ b/sys/src/games/nes/mem.c @@ -2,7 +2,7 @@ #include <libc.h> #include <thread.h> #include <draw.h> -#include <emu.h> +#include "../eui.h" #include "dat.h" #include "fns.h" diff --git a/sys/src/games/nes/mkfile b/sys/src/games/nes/mkfile index 98c8a14e0..d658229b4 100644 --- a/sys/src/games/nes/mkfile +++ b/sys/src/games/nes/mkfile @@ -9,7 +9,10 @@ OFILES=\ ppu.$O\ state.$O\ apu.$O\ + eui.$O\ HFILES=dat.h fns.h </sys/src/cmd/mkone +eui.$O: ../eui.c + $CC $CFLAGS ../eui.c diff --git a/sys/src/games/nes/nes.c b/sys/src/games/nes/nes.c index 2b4988aec..38984efff 100644 --- a/sys/src/games/nes/nes.c +++ b/sys/src/games/nes/nes.c @@ -3,7 +3,7 @@ #include <draw.h> #include <thread.h> #include <keyboard.h> -#include <emu.h> +#include "../eui.h" #include "dat.h" #include "fns.h" diff --git a/sys/src/games/nes/ppu.c b/sys/src/games/nes/ppu.c index 498c20082..0f7010198 100644 --- a/sys/src/games/nes/ppu.c +++ b/sys/src/games/nes/ppu.c @@ -3,7 +3,7 @@ #include <thread.h> #include <draw.h> #include <mouse.h> -#include <emu.h> +#include "../eui.h" #include "dat.h" #include "fns.h" diff --git a/sys/src/games/snes/cpu.c b/sys/src/games/snes/cpu.c index dbec220a4..7bdc95df9 100644 --- a/sys/src/games/snes/cpu.c +++ b/sys/src/games/snes/cpu.c @@ -1,7 +1,7 @@ #include <u.h> #include <libc.h> #include <thread.h> -#include <emu.h> +#include "../eui.h" #include "dat.h" #include "fns.h" diff --git a/sys/src/games/snes/dsp.c b/sys/src/games/snes/dsp.c index 991c45316..d3a03028f 100644 --- a/sys/src/games/snes/dsp.c +++ b/sys/src/games/snes/dsp.c @@ -1,7 +1,7 @@ #include <u.h> #include <libc.h> #include <thread.h> -#include <emu.h> +#include "../eui.h" #include "dat.h" #include "fns.h" diff --git a/sys/src/games/snes/mem.c b/sys/src/games/snes/mem.c index 885713a85..6afb3a9ef 100644 --- a/sys/src/games/snes/mem.c +++ b/sys/src/games/snes/mem.c @@ -1,7 +1,7 @@ #include <u.h> #include <libc.h> #include <thread.h> -#include <emu.h> +#include "../eui.h" #include "dat.h" #include "fns.h" diff --git a/sys/src/games/snes/mkfile b/sys/src/games/snes/mkfile index 6171c70ac..6cd40ba38 100644 --- a/sys/src/games/snes/mkfile +++ b/sys/src/games/snes/mkfile @@ -10,7 +10,10 @@ OFILES=\ spc.$O\ dsp.$O\ state.$O\ + eui.$O\ HFILES=dat.h fns.h </sys/src/cmd/mkone +eui.$O: ../eui.c + $CC $CFLAGS ../eui.c diff --git a/sys/src/games/snes/ppu.c b/sys/src/games/snes/ppu.c index 5819e032c..cc1a82af8 100644 --- a/sys/src/games/snes/ppu.c +++ b/sys/src/games/snes/ppu.c @@ -1,7 +1,7 @@ #include <u.h> #include <libc.h> #include <thread.h> -#include <emu.h> +#include "../eui.h" #include "dat.h" #include "fns.h" diff --git a/sys/src/games/snes/snes.c b/sys/src/games/snes/snes.c index 3e43b631d..769ecb473 100644 --- a/sys/src/games/snes/snes.c +++ b/sys/src/games/snes/snes.c @@ -4,7 +4,7 @@ #include <draw.h> #include <keyboard.h> #include <mouse.h> -#include <emu.h> +#include "../eui.h" #include "dat.h" #include "fns.h" diff --git a/sys/src/games/snes/spc.c b/sys/src/games/snes/spc.c index a5fc7ab8a..d00d58efa 100644 --- a/sys/src/games/snes/spc.c +++ b/sys/src/games/snes/spc.c @@ -1,7 +1,7 @@ #include <u.h> #include <libc.h> #include <thread.h> -#include <emu.h> +#include "../eui.h" #include "dat.h" #include "fns.h" diff --git a/sys/src/libemu/mkfile b/sys/src/libemu/mkfile deleted file mode 100644 index f436124a2..000000000 --- a/sys/src/libemu/mkfile +++ /dev/null @@ -1,20 +0,0 @@ -</$objtype/mkfile - -LIB=/$objtype/lib/libemu.a - -OFILES=\ - emu.$O\ - -HFILES=\ - /sys/include/draw.h\ - /sys/include/emu.h\ - /sys/include/mouse.h\ - /sys/include/keyboard.h - -UPDATE=\ - mkfile\ - $HFILES\ - ${OFILES:%.$O=%.c}\ - ${LIB:/$objtype/%=/386/%}\ - -</sys/src/cmd/mksyslib |