TriOS-alt/zubehör/startracker/source/regnatix-code/stplay.spin

574 lines
43 KiB
Plaintext
Raw Normal View History

<EFBFBD><EFBFBD>{{
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Autor: Ingo Kripahle %
% Copyright (c) 2010 Ingo Kripahle %
% See end of file for terms of use. %
% Die Nutzungsbedingungen befinden sich am Ende der Datei %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Informationen : hive-project.de
Kontakt : drohne235@googlemail.com
System : TriOS
Name : StarTracker
Chip : Regnatix
Typ : Programm
Version : 1
Subversion : 1
Funktion : HSS-Player mit LCARS-Oberfl<00>che, wiedergabe von allen Moduldateien im gleichen Verzeichnis
Installation : Folgende Dateien m<00>ssen in das Verzeichnis mit den HSS-Dateien kopiert werden:
stplay.bin Regnatix-Code, Startdatei
stint.bel Bellatrix-Code des Players
Komponenten : Bellatrix-Code basiert auf einer Idee und dem Testprogramm "lcars_xga_test" von Rayman.
Infos zum Programm von Rayman:
http://forums.parallax.com/forums/default.aspx?f=25&m=257204&p=1&ord=a
http://rayslogic.com/
Assimilation zum Multiprop-Code: drohne235
Regnatix-Code stplay.spin Regnatix-Code
Regnatix-Code ios.spin Systeminterface
Bellatrix-Code stint.spin Bellatrix-Code
Bellatrix-Code stkeyb.spin
Bellatrix-Code stvga.spin
COG's : 1 Cog
Logbuch :
31.01.2009 - aus play.spin eine erste lauff<00>hige version mit startreck-interface erstellt
01.02.2009 - tastenfunktionen
08.08.2009 - anpassung an module welche endflag setzen (player bieb dabei h<00>ngen)
- ursache: sync wartet obwohl player gestopt hat
17.04.2010 - anpassung an trios
- jetzt verwendung einer std.-ios
- funktioniert jetzt auch im unterverzeichnis
- kosmetische <00>nderungen
Kommandoliste :
Notizen :
}}
OBJ
ios: "ios"
CON
_CLKMODE = XTAL1 + PLL16X
_XINFREQ = 5_000_000
OS_TIBLEN = 64 'gr<00><00>e des inputbuffers
'definition der interfaceelemente
title = 0
footer = 1
button1 = 2
button2 = 3
button3 = 4
button4 = 5
button5 = 6
button6 = 7
button7 = 8
button8 = 9
button9 = 10
corner_topleft = 11
corner_topright = 12
corner_bottomLeft = 13
endcap_med_left = 14
endcap_med_right = 15
endcap_small_left = 16
endcap_small_right = 17
VAR
long lcnt 'zeiger f<00>r dateiliste
byte fn[12] 'puffer f<00>r dateinamen
byte gcol 'grundfarbe
byte cmdstat 'aktuelles kommandobutton
byte cmdreload
byte cmdnext
byte cmdps
PUB main | wflag
wflag := ios.start 'ios initialisieren
'mu<00> auskommentiert werden f<00>r bin-datei
'ios.startram 'testcode f<00>r ramupload
ios.belload(string("stint.bel")) 'grafiktreiber laden
ios.admsetsyssnd(0)
ios.sline(0)
frame1 'interface zeichnen
cmdstat := 0
cmdps := 0
cmdreload := 0
cmdnext := 0
command
repeat
playint 'playliste abspielen
repeat
ios.hss_stop
if ios.keystat > 0
command
while cmdps 'warten solange stopmodus
PUB playint | fnadr,len,fcnt,i 'alle songs auf der sd-card abspielen
ios.curhome
ios.sddir 'kommando: verzeichnis <00>ffnen
startlist 'zum listenanfang
fcnt := 0 'z<00>hler f<00>r dateianzahl
repeat while (fnadr := ios.sdnext) 'dateiliste einlesen
if str_find(fnadr,@ext1)
printmcnt(++fcnt)
wrfn(fnadr)
startlist 'zum listenanfang
if fcnt
repeat i from 0 to fcnt-1 'dateiliste abspielen
rdfn(@fn)
playsong(@fn)
if cmdnext==0 AND cmdps==0 AND cmdreload==0 'ausblenden nur bei playliste
fadeout
else
cmdnext := 0
ios.hss_stop
if cmdreload
cmdreload := 0
quit
if cmdps
quit
PUB str_find(string1, string2) : buffer | counter 'sys: string suchen
repeat strsize(string1--)
if(byte[++string1] == byte[string2])
repeat counter from 0 to (strsize(string2) - 1)
if(byte[string1][counter] <> byte[string2][counter])
buffer~~
ifnot(buffer~)
return string1
PUB playsong(stradr) | n,i,note,vol,rep,cc1,cc2,cc3,cc4,eflag'spielt einen song ab
printsong(stradr)
ios.hss_stop
ios.hss_playfile(stradr)
cc1 := 0
cc2 := 0
cc3 := 0
cc4 := 0
repeat
sync 'synchronisation mit beat
rep := ios.hss_intreg(ios#iRepeat) 'loopz<00>hler auslesen
eflag := ios.hss_intreg(ios#iEndFlag) 'endflag abfragen
printrep(rep) 'z<00>hler auf screen aktualisieren
' printeflag(eflag) 'endflag anzeigen
if ios.keystat > 0 'tasteneingabe?
command
repeat i from 1 to 4 'schleife f<00>r die vier kan<00>le
at(33,2+i,5)
note := ios.hss_intreg(i*5+ios#iNote)
vol := ios.hss_intreg(i*5+ios#iVolume)
printnote(note) 'note
n := ios.hss_intreg(i*5+ios#iOktave)
'----------------------------------------
ios.setcolor(0)
if n
ios.printhex(n,1) 'oktave
else
ios.printchar("-")
ios.printchar(" ")
'----------------------------------------
ios.setcolor(1)
n := ios.hss_intreg(i*5+ios#iVolume)
if n
ios.printhex(n,1) 'volume
else
ios.printchar("-")
ios.printchar(" ")
'----------------------------------------
ios.setcolor(2)
n := ios.hss_intreg(i*5+ios#iEffekt)
if n
ios.printhex(n,1) 'effekt
else
ios.printchar("-")
ios.printchar(" ")
'----------------------------------------
ios.setcolor(3)
n := ios.hss_intreg(i*5+ios#iInstrument)
if n
ios.printhex(n,1) 'instrument
else
ios.printchar("-")
ios.printchar(" ")
'----------------------------------------
if note > 0 'bei note bargraph triggern
case i
1: cc1 := 1
2: cc2 := 1
3: cc3 := 1
4: cc4 := 1
'----------------------------------------
case i 'numerischen pegelwert ausgeben
1: ios.printhex(cc1,2)
2: ios.printhex(cc2,2)
3: ios.printhex(cc3,2)
4: ios.printhex(cc4,2)
if rep == 3
cc1 := 10
cc2 := 10
cc3 := 10
cc4 := 10
bar(8,5 ,button1,0,cc1) 'bargraphen zeichen
bar(8,8 ,button2,1,cc2)
bar(8,11,button3,2,cc3)
bar(8,14,button4,3,cc4)
if cc1 < 10 'pegel absenken
cc1++
if cc2 < 10
cc2++
if cc3 < 10
cc3++
if cc4 < 10
cc4++
until rep == 3 OR cmdnext OR cmdreload OR cmdps OR eflag == 1 'drei loops, endflag oder kommandos brechen ab
PUB command | k 'tastatur abfragen
k := ios.key
case k
194: if cmdstat > 0 'pfeil hoch
cmdstat--
else
cmdstat := 3
195: if cmdstat < 3 'pfeil runter
cmdstat++
else
cmdstat := 0
13: case cmdstat 'eingabetaste
0: if cmdps == 1
cmdps := 0
else
cmdps := 1
1: cmdreload := 1
2: cmdnext := 1
3: ios.printcls
ios.hss_stop 'hss-player stoppen
ios.ram_write(0,ios#SIFLAG) 'screeninit f<00>r cli aktivieren
ios.admsetsyssnd(1) 'systemkl<00>nge wieder anschalten
ios.sddmact(ios#DM_ROOT) 'suche in root
ios.belload(string("bel.sys")) 'systemgrafiktreiber laden
ios.stop 'programm beenden
case cmdstat 'led-buttons neu zeichen
0: button(8,22,13,button6,1,0,0)
button(8,25,13,button7,2,0,0)
button(8,28,13,button8,2,0,0)
button(8,31,13,button9,2,0,0)
1: button(8,22,13,button6,2,0,0)
button(8,25,13,button7,1,0,0)
button(8,28,13,button8,2,0,0)
button(8,31,13,button9,2,0,0)
2: button(8,22,13,button6,2,0,0)
button(8,25,13,button7,2,0,0)
button(8,28,13,button8,1,0,0)
button(8,31,13,button9,2,0,0)
3: button(8,22,13,button6,2,0,0)
button(8,25,13,button7,2,0,0)
button(8,28,13,button8,2,0,0)
button(8,31,13,button9,1,0,0)
PUB sync 'synchronisation mit beat
repeat
until ios.hss_intreg(ios#iRowFlag) == 0 or ios.hss_intreg(ios#iEndFlag) == 1
repeat
until ios.hss_intreg(ios#iRowFlag) == 1 or ios.hss_intreg(ios#iEndFlag) == 1
PUB fadeout | i 'song langsam ausblenden
repeat i from 0 to 15
ios.hss_vol(15 - i)
if ios.keystat > 0
command
waitcnt(cnt + 60_000_000)
waitcnt(cnt + 30_000_000)
PUB wrfn(stradr) | len,i 'kopiert dateinamen bei lcnt in eram
len := strsize(stradr)
repeat i from 0 to len-1
ios.ram_write(byte[stradr][i],lcnt++)
ios.ram_write(0,lcnt++)
PUB rdfn(stradr) | i,n 'liest dateinamen bei lcnt aus eram, lcnt wird dabei erh<00>ht
i := 0
repeat
n := ios.ram_read(lcnt++)
byte[stradr][i++] := n
while n <> 0
PUB startlist 'zeiger auf listenanfang (dateinamen)
lcnt := 0
PUB printnote(n) 'nummer --> notenzeichen
'C1,C#1,D1,D#1,E1,F1,F#1,G1,G#1,A1,A#1,H1
case n
0: ios.print(string("<00>% "))
1: ios.print(string("C "))
2: ios.print(string("C" "))
3: ios.print(string("D "))
4: ios.print(string("D" "))
5: ios.print(string("E "))
6: ios.print(string("F "))
7: ios.print(string("F" "))
8: ios.print(string("G "))
9: ios.print(string("G" "))
10: ios.print(string("A "))
11: ios.print(string("A" "))
12: ios.print(string("H "))
PUB printmcnt(n) 'ausgabe der anzahl
printat(25,13,0,string("Anzahl Dateien : "))
ios.printdec(n)
PUB printsong(stradr) 'ausgabe des songnamens
printat(25,14,0, string("PlaySong : "))
printat(42,14,0,string(" "))
printat(42,14,0,stradr)
dtext(button5,string("____________________"))
dtext(button5,stradr)
PUB printrep(rep) 'ausgabe der loops
printat(25,15,0,string("Repeat : "))
printatdec(42,15,0,rep)
PUB printeflag(eflag) 'ausgabe EndFlag
printat(25,16,0,string("EndFlag : "))
printatdec(42,16,0,eflag)
{
PUB printdeb(deb) 'ausgabe debug-marke
printat(25,17,0,string("Mark : "))
printatdec(42,17,0,deb)
}
PUB at(x,y,color) 'cursorposition und farbe setzen
ios.cursetx(x)
ios.cursety(y)
ios.setcolor(color)
PUB printat(x,y,color,strptr) 'string bei position mit farbe ausgeben
at(x,y,color)
ios.print(strptr)
PUB printatdec(x,y,color,wert) 'zahl bei position mit farbe ausgeben
ios.cursetx(x)
ios.cursety(y)
ios.setcolor(color)
ios.printdec(wert)
PUB frame1 | i,sline 'hauptframe zeichnen
ios.curoff
ios.printcls
gcol := 0
sline := 24
' 64 x 48 - 32,24
dtext(title,string("STARTRACKER ",95," LOADING ...")) 'text in button rendern
top(8,sline) 'initiale ladezeile zeichnen
ton1
dtext(footer,string("DROHNE235 ",95," 2009 ")) 'restliche buttons rendern
dtext(button1,string("ENGINE A "))
dtext(button2,string("ENGINE B "))
dtext(button3,string("ENGINE C "))
dtext(button4,string("ENGINE D "))
dtext(button5,string(" DATEI "))
dtext(button6,string("PLAY ",95," STOP"))
dtext(button7,string("RELOAD "))
dtext(button8,string("NEXT SONG "))
dtext(button9,string("QUIT "))
repeat (sline / 2) - 1 'ladezeile nach oben verschieben
ios.scrollup
waitcnt(cnt + 4_000_000)
top(8,2) 'kopfzeile zeichnen
ton1
dtext(title,string("STARTRACKER ",95," HIVE-PROJEKT"))
repeat i from 0 to 10 'pegel zeichnen
'x,y,nButton,color,pegel
bar(8,5 ,button1,0,i)
bar(8,8 ,button2,1,i)
bar(8,11,button3,2,i)
bar(8,14,button4,3,i)
ios.sfx_fire($f1,0)
waitcnt(cnt + 4_000_000)
log2(24,5)
'x,y,len,nButton,col1,col2,col3
'orange=0,blue=1,past=2,purple=3,wei<00>=4,magenta=5
button(8,22,13,button6,2,0,0)
button(8,25,13,button7,2,0,0)
button(8,28,13,button8,2,0,0)
button(8,31,13,button9,2,0,0)
info(25,22,15,button5,0,1)
bottom(8,36)
PUB info(x,y,len,nButton,col1,col2) 'infobereich zeichnen
bmap(endcap_med_left,x,y,1,2,col1)
box(x+1,y,2,2,col1,false,false,false)
box(x+13,y,len-13,2,col1,false,false,false)
bmap(nButton,x+4,y,8,2,col2)
bmap(endcap_med_right,x+len,y,1,2,col1)
PUB log1(x,y) 'einen vollen logbereich zeichnen
'left,top,width,height,clr,bBottomBreak,bRightBreak,bTrimRight
'top
bmap(corner_topleft,x,y,6,2,1)
box(x+6,y,8,1,1,false,true,false)
box(x+14,y,5,1,2,false,true,false)
box(x+19,y,11,1,0,false,true,false)
'middle
box(x,y+2,4,1,1,true,false,false)
box(x,y+3,4,4,3,true,false,false)
box(x,y+7,4,2,0,true,false,false)
box(x,y+9,4,5,2,true,false,false)
'box(x,y+4,4,1,1,false,false,false)
'bottom
bmap(corner_bottomleft,x,y+14,6,2,1)
box(x+6,y+15,3,1,1,false,true,false)
box(x+9,y+15,12,1,0,false,true,false)
box(x+21,y+15,4,1,2,false,true,false)
box(x+25,y+15,5,1,1,false,true,false)
PUB log2(x,y) 'einen halben logbereich zeichnen
'left,top,width,height,clr,bBottomBreak,bRightBreak,bTrimRight
'mitte
box(x,y,4,1,1,true,false,false)
box(x,y+1,4,4,3,true,false,false)
box(x,y+5,4,2,0,true,false,false)
box(x,y+7,4,5,2,true,false,false)
'box(x,y+4,4,1,1,false,false,false)
'unten
bmap(corner_bottomleft,x,y+12,6,2,1)
box(x+6,y+13,3,1,1,false,true,false)
box(x+9,y+13,12,1,0,false,true,false)
box(x+21,y+13,4,1,2,false,true,false)
box(x+25,y+13,5,1,1,false,true,false)
PUB button(x,y,len,nButton,col1,col2,col3) 'zeichnet schaltfl<00>che
box(x,y,1,2,col1,false,false,false)
box(x+2,y,len-2,2,col2,false,false,false)
bmap(nButton,x+2,y,8,2,col2)
bmap(endcap_med_right,x+len,y,1,2,col2)
PUB top(x,y) 'zeichnet kopfzeile
bmap(title,x+15,y,21,2,gcol)
box(x+2,y,12,2,2,false,false,false)
box(x+34,y,12,2,2,false,false,false)
bmap(endcap_med_left,x,y,1,2,1)
bmap(endcap_med_right,x+47,y,1,2,1)
PUB bottom(x,y) 'zeichnet kopfzeile
bmap(footer,x+2,y,15,2,gcol)
box(x+14,y,32,2,2,false,false,false)
bmap(endcap_med_left,x,y,1,2,1)
bmap(endcap_med_right,x+47,y,1,2,1)
PUB bar(x,y,nButton,color,pegel) 'zeichnet einen bargraf
bmap(endcap_med_left,x,y,1,2,color)
bmap(nButton,x+2,y,pegel,2,gcol)
box(x+2+pegel,y,x+4-pegel,2,color,false,false,false)
PUB ton1 'ultimativerstartrecksound
repeat 4
ios.sfx_fire($f1,0)
waitcnt(cnt + 4_000_000)
CON 'INTERFACEROUTINEN
PUB bmap(nBitmap,xPos,yPos,xSize,ySize,clr) 'screen: 1bit-bitmap zeichnen
{{ nBitmap:
0: title
1: footer
2: button1
3: button2
4: button3
5: button4
6: button5
7: corner_topleft
8: corner_topright
9: corner_bottomLeft
10: endcap_med_left
11: endcap_med_right
12: endcap_small_left
13: endcap_small_right
}}
ios.bus_putchar2(0)
ios.bus_putchar2(10)
ios.bus_putchar2(nBitmap)
ios.bus_putchar2(xPos)
ios.bus_putchar2(yPos)
ios.bus_putchar2(xSize)
ios.bus_putchar2(ySize)
ios.bus_putchar2(clr)
PUB box(pleft,ptop,pwidth,pheight,pclr,bBottomBreak,bRightBreak,bTrimRight) 'screen: farbige box zeichnen
'blue=1
'purple=3
'orange=0
'red=2
ios.bus_putchar2(0)
ios.bus_putchar2(11)
ios.bus_putchar2(pleft)
ios.bus_putchar2(ptop)
ios.bus_putchar2(pwidth)
ios.bus_putchar2(pheight)
ios.bus_putchar2(pclr)
ios.bus_putchar2(bBottomBreak)
ios.bus_putchar2(bRightBreak)
ios.bus_putchar2(bTrimRight)
PUB dtext(nButton,stradr) | nLen 'screen: text in button zeichnen
{{Nur Gro<00>buchstaben!}}
nLen := strsize(stradr)
ios.bus_putchar2(0)
ios.bus_putchar2(12)
ios.bus_putchar2(nButton)
ios.bus_putchar2(nLen)
repeat nLen
ios.bus_putchar2(byte[stradr++])
DAT
ext1 byte ".HSS",0
DAT
{{
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% TERMS OF USE: MIT License %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%$%
%Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation %
%files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, %
%modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software%
%is furnished to do so, subject to the following conditions: %
% %
%The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.%
% %
%THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE %
%WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR %
%COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, %
%ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
}}