Moved devices in their own folders

This commit is contained in:
neauoire 2021-05-11 11:42:12 -07:00
parent a206ed0b10
commit 7f5c4e25e4
9 changed files with 65 additions and 63 deletions

View File

@ -3,18 +3,18 @@
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/ppu.h clang-format -i src/devices/ppu.h
clang-format -i src/ppu.c clang-format -i src/devices/ppu.c
clang-format -i src/apu.h clang-format -i src/devices/apu.h
clang-format -i src/apu.c clang-format -i src/devices/apu.c
clang-format -i src/mpu.h clang-format -i src/devices/mpu.h
clang-format -i src/mpu.c clang-format -i src/devices/mpu.c
clang-format -i src/assembler.c clang-format -i src/assembler.c
clang-format -i src/emulator.c clang-format -i src/emulator.c
clang-format -i src/debugger.c clang-format -i src/debugger.c
echo "Cleaning.." echo "Cleaning.."
rm -f ./bin/assembler rm -f ./bin/uxnasm
rm -f ./bin/emulator rm -f ./bin/emulator
rm -f ./bin/debugger rm -f ./bin/debugger
rm -f ./bin/boot.rom rm -f ./bin/boot.rom
@ -24,17 +24,17 @@ mkdir -p bin
if [ "${1}" = '--debug' ]; if [ "${1}" = '--debug' ];
then then
echo "[debug]" echo "[debug]"
cc -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/assembler.c -o bin/assembler cc -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/assembler.c -o bin/uxnasm
cc -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/ppu.c src/apu.c src/mpu.c src/emulator.c -L/usr/local/lib -lSDL2 -lportmidi -o bin/emulator cc -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/ppu.c src/devices/apu.c src/devices/mpu.c src/emulator.c -L/usr/local/lib -lSDL2 -lportmidi -o bin/emulator
cc -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/debugger.c -o bin/debugger cc -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/debugger.c -o bin/debugger
else else
cc src/assembler.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -o bin/assembler cc src/assembler.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -o bin/uxnasm
cc src/uxn.c src/debugger.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -o bin/debugger cc src/uxn.c src/debugger.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -o bin/debugger
cc src/uxn.c src/ppu.c src/apu.c src/mpu.c src/emulator.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -L/usr/local/lib -lSDL2 -lportmidi -o bin/emulator cc src/uxn.c src/devices/ppu.c src/devices/apu.c src/devices/mpu.c src/emulator.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -L/usr/local/lib -lSDL2 -lportmidi -o bin/emulator
fi fi
echo "Assembling.." echo "Assembling.."
./bin/assembler projects/demos/piano.usm bin/boot.rom ./bin/uxnasm projects/demos/piano.usm bin/boot.rom
echo "Running.." echo "Running.."
if [ "${2}" = '--cli' ]; if [ "${2}" = '--cli' ];

View File

@ -47,10 +47,10 @@
#0f25 .System/b DEO2 #0f25 .System/b DEO2
( vectors ) ( vectors )
;on-frame .Screen/vector DEO2
;on-control .Controller/vector DEO2 ;on-control .Controller/vector DEO2
;on-mouse .Mouse/vector DEO2 ;on-mouse .Mouse/vector DEO2
;on-midi .Midi/vector DEO2 ;on-midi .Midi/vector DEO2
;on-frame .Screen/vector DEO2
( load waveform ) ( load waveform )
;piano-path .File/name DEO2 #0100 .File/length DEO2 WAVEFORM .File/load DEO2 ;piano-path .File/name DEO2 #0100 .File/length DEO2 WAVEFORM .File/load DEO2
@ -113,6 +113,52 @@ BRK
BRK BRK
@on-control ( -> )
( clear last cursor )
#fff8 .Screen/addr DEO2
.pointer/x LDZ2 .Screen/x DEO2
.pointer/y LDZ2 .Screen/y DEO2
#30 .Screen/color DEO
.Controller/key DEI
DUP #61 ! ,&no-c JCN
#00 .last-note STZ ;notes LDA ;play JSR2 &no-c
DUP #73 ! ,&no-d JCN
#01 .last-note STZ ;notes #0001 ++ LDA ;play JSR2 &no-d
DUP #64 ! ,&no-e JCN
#02 .last-note STZ ;notes #0002 ++ LDA ;play JSR2 &no-e
DUP #66 ! ,&no-f JCN
#03 .last-note STZ ;notes #0003 ++ LDA ;play JSR2 &no-f
DUP #67 ! ,&no-g JCN
#04 .last-note STZ ;notes #0004 ++ LDA ;play JSR2 &no-g
DUP #68 ! ,&no-a JCN
#05 .last-note STZ ;notes #0005 ++ LDA ;play JSR2 &no-a
DUP #6a ! ,&no-b JCN
#06 .last-note STZ ;notes #0006 ++ LDA ;play JSR2 &no-b
DUP #6b ! ,&no-c2 JCN
#07 .last-note STZ ;notes #0007 ++ LDA ;play JSR2 &no-c2
POP
( release )
#00 .Controller/key DEO
.Controller/button DEI #f0 AND
DUP #04 SFT #01 AND #01 ! ,&no-up JCN
( move ) .Audio0/addr DEI2 #0001 -- .Audio0/addr DEO2 &no-up
DUP #05 SFT #01 AND #01 ! ,&no-down JCN
( move ) .Audio0/addr DEI2 #0001 ++ .Audio0/addr DEO2 &no-down
DUP #06 SFT #01 AND #01 ! ,&no-left JCN
( move ) .Audio0/addr DEI2 #0010 -- .Audio0/addr DEO2 &no-left
DUP #07 SFT #01 AND #01 ! ,&no-right JCN
( move ) .Audio0/addr DEI2 #0010 ++ .Audio0/addr DEO2 &no-right
POP
;draw-octave JSR2
;draw-wave JSR2
BRK
@on-midi ( -> ) @on-midi ( -> )
.Midi/note DEI #00 ! #01 JCN [ BRK ] .Midi/note DEI #00 ! #01 JCN [ BRK ]
@ -204,49 +250,6 @@ BRK
BRK BRK
@on-control ( -> )
( clear last cursor )
#fff8 .Screen/addr DEO2
.pointer/x LDZ2 .Screen/x DEO2
.pointer/y LDZ2 .Screen/y DEO2
#30 .Screen/color DEO
.Controller/key DEI
DUP #61 ! ,&no-c JCN
#00 .last-note STZ ;notes LDA ;play JSR2 &no-c
DUP #73 ! ,&no-d JCN
#01 .last-note STZ ;notes #0001 ++ LDA ;play JSR2 &no-d
DUP #64 ! ,&no-e JCN
#02 .last-note STZ ;notes #0002 ++ LDA ;play JSR2 &no-e
DUP #66 ! ,&no-f JCN
#03 .last-note STZ ;notes #0003 ++ LDA ;play JSR2 &no-f
DUP #67 ! ,&no-g JCN
#04 .last-note STZ ;notes #0004 ++ LDA ;play JSR2 &no-g
DUP #68 ! ,&no-a JCN
#05 .last-note STZ ;notes #0005 ++ LDA ;play JSR2 &no-a
DUP #6a ! ,&no-b JCN
#06 .last-note STZ ;notes #0006 ++ LDA ;play JSR2 &no-b
DUP #6b ! ,&no-c2 JCN
#07 .last-note STZ ;notes #0007 ++ LDA ;play JSR2 &no-c2
POP
.Controller/button DEI #f0 AND
DUP #04 SFT #01 AND #01 ! ,&no-up JCN
( move ) .Audio0/addr DEI2 #0001 -- .Audio0/addr DEO2 &no-up
DUP #05 SFT #01 AND #01 ! ,&no-down JCN
( move ) .Audio0/addr DEI2 #0001 ++ .Audio0/addr DEO2 &no-down
DUP #06 SFT #01 AND #01 ! ,&no-left JCN
( move ) .Audio0/addr DEI2 #0010 -- .Audio0/addr DEO2 &no-left
DUP #07 SFT #01 AND #01 ! ,&no-right JCN
( move ) .Audio0/addr DEI2 #0010 ++ .Audio0/addr DEO2 &no-right
POP
;draw-octave JSR2
;draw-wave JSR2
BRK
@play ( pitch -- ) @play ( pitch -- )
DUP .octave LDZ #0c * + .Audio0/pitch DEO DUP .octave LDZ #0c * + .Audio0/pitch DEO

View File

@ -10,7 +10,7 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE. WITH REGARD TO THIS SOFTWARE.
*/ */
#include "uxn.h" #include "../uxn.h"
#include "apu.h" #include "apu.h"
#define NOTE_PERIOD 0x10000 #define NOTE_PERIOD 0x10000

View File

@ -14,9 +14,9 @@ WITH REGARD TO THIS SOFTWARE.
*/ */
#include "uxn.h" #include "uxn.h"
#include "ppu.h" #include "devices/ppu.h"
#include "apu.h" #include "devices/apu.h"
#include "mpu.h" #include "devices/mpu.h"
static SDL_AudioDeviceID audio_id; static SDL_AudioDeviceID audio_id;
static SDL_Window *gWindow; static SDL_Window *gWindow;
@ -328,11 +328,10 @@ start(Uxn *u)
quit(); quit();
break; break;
case SDL_TEXTINPUT: case SDL_TEXTINPUT:
if(event.text.text[0] >= ' ' || event.text.text[0] <= '~')
devctrl->dat[3] = event.text.text[0];
break;
case SDL_KEYDOWN: case SDL_KEYDOWN:
case SDL_KEYUP: case SDL_KEYUP:
if(event.text.text[0] >= ' ' || event.text.text[0] <= '~')
devctrl->dat[3] = event.text.text[0];
doctrl(u, &event, event.type == SDL_KEYDOWN); doctrl(u, &event, event.type == SDL_KEYDOWN);
evaluxn(u, mempeek16(devctrl->dat, 0)); evaluxn(u, mempeek16(devctrl->dat, 0));
devctrl->dat[3] = 0; devctrl->dat[3] = 0;