From 8150e1fcc669d060f8adbd8c72b171c62e70d349 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Sun, 25 Aug 2024 14:49:47 -0700 Subject: [PATCH] (m291) Init --- .gitignore | 1 + gui/m291/makefile | 27 +++++++++ gui/m291/src/m291.tal | 81 ++++++++++++++++++++++++++ gui/m291/src/mp3.tal | 131 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 240 insertions(+) create mode 100644 gui/m291/makefile create mode 100644 gui/m291/src/m291.tal create mode 100644 gui/m291/src/mp3.tal diff --git a/.gitignore b/.gitignore index 1972ba4..9d4c34e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ *jpg *png *bmp +*.mp3 */bin/ *nametable *.rom diff --git a/gui/m291/makefile b/gui/m291/makefile new file mode 100644 index 0000000..d615beb --- /dev/null +++ b/gui/m291/makefile @@ -0,0 +1,27 @@ +ID=m291 +DIR=~/roms +ASM=uxncli ${DIR}/drifblim.rom +LIN=uxncli ${DIR}/uxnlin.rom +EMU=uxn11 +ROM=bin/${ID}.rom + +all: ${ROM} + +lint: + @ ${LIN} ${ID}.tal +run: all + @ ${EMU} ${ROM} +clean: + @ rm -f ${ROM} ${ROM}.sym +install: ${ROM} + @ cp ${ROM} ${DIR} +uninstall: + @ rm -f ${DIR}/${ID}.rom +archive: all + @ cp ${ID}.tal ../../../oscean/etc/${ID}.tal.txt + +.PHONY: all clean lint run install uninstall archive + +${ROM}: src/${ID}.tal + @ mkdir -p bin + @ ${ASM} src/${ID}.tal ${ROM} diff --git a/gui/m291/src/m291.tal b/gui/m291/src/m291.tal new file mode 100644 index 0000000..fe7dfef --- /dev/null +++ b/gui/m291/src/m291.tal @@ -0,0 +1,81 @@ +( mp3.tal ) + +@Console [ + |10 &vector $2 |12 + &read $1 |15 &live + $1 |15 &exit $1 + |17 &type $1 |18 + &write $1 |19 &error + $1 |1c &addr $2 + |1e &mode $1 |1f + &exec $1 ] + +|100 + +@on-reset ( -> ) + ( | initialize buffer ) + ;buffer ;buffer/pos STA2 + ( | run mpg123 ) + ;on-console .Console/vector DEO2 + ;program .Console/addr DEO2 + ( cmd addr ) #03 .Console/mode DEO + ( cmd mode ) #01 .Console/exec DEO + ( exec ) ;cmd1 print ;cmd2 print BRK + +@printerr ( s* -> ) + LDAk ?{ + #0a .Console/error DEO + POP2 JMP2r } + LDAk .Console/error DEO + INC2 !printerr + +@print ( s* -> ) + LDAk ?{ POP2 JMP2r } + LDAk .Console/write DEO + INC2 !print + +@on-console ( -> brk ) + .Console/type DEI #01 EQU ?{ BRK } + .Console/read DEI #0a EQU ?&newline + ;buffer/pos LDA2k STH2k .Console/read DEI STH2r STA + INC2 SWP2 STA2 + BRK + &newline #00 ;buffer/pos LDA2 STA + on-line ;buffer ;buffer/pos STA2 + BRK + +@on-line ( -> ) + ;buffer LDAk LIT "@ EQU ?{ POP2 JMP2r } + INC2k LDA LIT "F EQU ?on-frame + !printerr + +@on-frame ( buf* -> ) + POP2 JMP2r + +@on-help ( buf* -> ) + POP2r JMP2r + +@on-id3 ( buf* -> ) + POP2 JMP2r + +@on-paused ( buf* -> ) + POP2 JMP2r + +@on-revision ( buf* -> ) + POP2 JMP2r + +@on-status ( buf* -> ) + POP2 JMP2r + +@on-tag ( buf* -> ) + POP2 JMP2r + +@program "mpg123 20 "-R 00 + +@cmd1 "loadpaused 20 "always_wrong.mp3 0a 00 + +@cmd2 "pause 0a 00 + +@buffer $200 &pos $2 + ( input buffer ) + diff --git a/gui/m291/src/mp3.tal b/gui/m291/src/mp3.tal new file mode 100644 index 0000000..66574ec --- /dev/null +++ b/gui/m291/src/mp3.tal @@ -0,0 +1,131 @@ +( mp3.tal ) + +( commands are ended by newlines: ) +( ) +( help show all these commands ) +( load FILE load FILE and start playing ) +( loadpaused FILE load FILE without playing ) +( pause pause, or unpause, playback ) +( stop stops playback, unloads file ) +( seek # seeks to sample # ) +( seek +N | seek -N seeks forward, or back, N samples ) +( seek +Ns | seek -Ns seeks forward, or back, N seconds ) +( jump # jumps to MPEG frame # ) +( jump +N | jump -N jumps forward, or back, N frames ) +( jump +Ns | jump -Ns jumps forward, or back, N seconds ) +( volume P set volume to P percent, 0-100 ) +( mute mute playback ) +( unmute unmute playback ) +( tag print all ID3 data; seeking back may remove tag data ) + +@Console [ + |10 &vector $2 + |12 &read $1 + ( 13 - 14 padding ) + |15 &live $1 + |15 &exit $1 + |17 &type $1 + |18 &write $1 + |19 &error $1 + ( 1a - 1b padding ) + |1c &addr $2 + |1e &mode $1 + |1f &exec $1 +] + +|0100 + ( initialize buffer ) + ;buffer ;buffer/pos STA2 + + ( run mpg123 ) + ;on-console .Console/vector DEO2 + ;program .Console/addr DEO2 ( cmd addr ) + #03 .Console/mode DEO ( cmd mode ) + #01 .Console/exec DEO ( exec ) + + ;cmd1 print + ;cmd2 print + + BRK + +@printerr ( s* -> ) + LDAk ?{ #0a .Console/error DEO POP2 JMP2r } + LDAk .Console/error DEO INC2 !printerr + +@print ( s* -> ) + LDAk ?{ POP2 JMP2r } + LDAk .Console/write DEO INC2 !print + +@on-console ( -> brk ) + .Console/type DEI #01 EQU ?{ BRK } ( ) + .Console/read DEI #0a EQU ?&newline ( ) + ;buffer/pos LDA2k STH2k ( pos* buf* [buf*] ) + .Console/read DEI STH2r STA ( pos* buf ; buf<-c ) + INC2 SWP2 STA2 BRK ( ; pos<-buf+1 ) + &newline ( ) + #00 ;buffer/pos LDA2 STA on-line ( ; buf<-0, run on-line ) + ;buffer ;buffer/pos STA2 BRK ( ) + + +( called when a newline is reached ) +( buffer is guaranteed to be null-terminated ) +( newline is implied but not included ) +@on-line ( -> ) + ;buffer LDAk LIT "@ EQU ?{ POP2 JMP2r } + INC2k LDA LIT "F EQU ?on-frame + ( INC2k LDA LIT "H EQU ?on-help ) + ( INC2k LDA LIT "I EQU ?on-id3 ) + ( INC2k LDA LIT "P EQU ?on-paused ) + ( INC2k LDA LIT "R EQU ?on-revision ) + ( INC2k LDA LIT "S EQU ?on-status ) + ( INC2k LDA LIT "T EQU ?on-tag ) + !printerr + +( e.g. "@F 184 8713 4.81 227.60" ) +( seen when playing ) +( the fields here are: ) +( @F ) +@on-frame ( buf* -> ) + POP2 JMP2r + +( e.g. "@H HELP/H: command listing (LONG/SHORT forms), command case insensitve" ) +( seen in response to the "help" command ) +@on-help ( buf* -> ) + POP2r JMP2r + +( e.g. "@I ID3v2.artist:Chipzel" ) +( seen when loading a track ) +@on-id3 ( buf* -> ) + POP2 JMP2r + +( e.g. "@P 0" or "@P 1" ) +( seen when pausing or unpausing ) +@on-paused ( buf* -> ) + POP2 JMP2r + +( e.g. "@R MPG123 (ThOr) v10" ) +( seen on start up ) +@on-revision ( buf* -> ) + POP2 JMP2r + +( e.g. "@S 1.0 3 44100 Joint-Stereo 0 1044 2 0 0 0 320 0 1" ) +( seen when playback starts ) +@on-status ( buf* -> ) + POP2 JMP2r + +( e.g. "@T ID3v2.TPE1:" ) +( seen in response to the "tag" command for extended tag info ) +@on-tag ( buf* -> ) + POP2 JMP2r + +@program + "mpg123 20 "-R 00 + +@cmd1 + "loadpaused 20 "always_wrong.mp3 0a 00 + +@cmd2 + "pause 0a 00 + + +@buffer $200 &pos $2 ( input buffer )