Commit 003f6b2b authored by ROOL's avatar ROOL 🤖
Browse files

Comment and indentation improvements

Detail:
  Readability improvements ahead of some other changes
Admin:
  Submission from Chris Wraight.

Version 2.12. Tagged as 'Maestro-2_12'
parent b693b127
/* (2.11)
/* (2.12)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 2.11
#define Module_MajorVersion_CMHG 2.12
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 02 Feb 2019
#define Module_Date_CMHG 13 Apr 2019
#define Module_MajorVersion "2.11"
#define Module_Version 211
#define Module_MajorVersion "2.12"
#define Module_Version 212
#define Module_MinorVersion ""
#define Module_Date "02 Feb 2019"
#define Module_Date "13 Apr 2019"
#define Module_ApplicationDate "02-Feb-19"
#define Module_ApplicationDate "13-Apr-19"
#define Module_ComponentName "Maestro"
#define Module_ComponentPath "apache/RiscOS/Sources/Apps/Maestro"
#define Module_FullVersion "2.11"
#define Module_HelpVersion "2.11 (02 Feb 2019)"
#define Module_LibraryVersionInfo "2:11"
#define Module_FullVersion "2.12"
#define Module_HelpVersion "2.12 (13 Apr 2019)"
#define Module_LibraryVersionInfo "2:12"
......@@ -1351,7 +1351,7 @@ IFM$="Maestro" THEN
PROCSetupBarStarts(0)
PROCscore_init
PROCSetDefaultChannels
PROCupdate_score(0,-Score_Height%,Score_Width%,0)
PROCscore_update(0,-Score_Height%,Score_Width%,0)
PROCStopScoring
CHANGED%=FALSE
ENDIF
......@@ -1738,25 +1738,43 @@ IFN%(C%)<FINE%(C%) FORN%=N%(C%)TOFINE%(C%)STEP4:!N%=N%!2:NEXT
?GP%=?GP%ANDNOT(%1<<C%)
ENDPROC
DEF FNallocate_channel(S%)
LOCALC%,c%,G%
G%=?GP%
C%=-1:c%=7
DEF FNallocate_channel (s%)
LOCAL channel%,c%
channel%=-1
c%=7
REPEAT
WHILEc%>=0ANDG%AND%1<<c%:c%+=TRUE:ENDWHILE
IFc%>=0 IFS_C%(c%)=S% C%=c%
c%+=TRUE
UNTILc%<0
=C%
DEF PROCarrange_stave(S%)
LOCALC%,B%
B%=TRUE:C%=TRUE
IF?GP% ELSEREPEATGP%+=2:UNTIL?GP%ORGP%>=GATE%
WHILEB%ANDGP%<GATE%
C%=C%ORFNsort_gate
PROCskip_notes(?GP%):GP%+=1
IF?GP% ELSEB%=C%:C%=FALSE:REPEATGP%+=2:UNTIL?GP%ORGP%>=GATE%
WHILE c%>=0 AND (?GP% AND 1<<c%)
c%-=1
ENDWHILE
IF c%>=0 THEN
IF S_C%(c%)=s% THEN channel%=c%
ENDIF
c%-=1
UNTIL c%<0
=channel%
DEF PROCarrange_stave (S%)
LOCAL C%,B%,bar%
B%=TRUE
C%=TRUE
IF ?GP% THEN
ELSE
REPEAT
GP%+=2
UNTIL ?GP% OR GP%>=GATE%
ENDIF
WHILE B% AND GP%<GATE%
C%=C% OR FNsort_gate
PROCskip_notes(?GP%)
GP%+=1
IF ?GP% THEN
ELSE
B%=C%
C%=FALSE
REPEAT
GP%+=2
UNTIL ?GP% OR GP%>=GATE%
ENDIF
ENDWHILE
ENDPROC
......@@ -1765,7 +1783,7 @@ LOCALC%,NC%,NN%,G%,g%,pg%,d%,shortest%,Gchanged%
shortest%=255
G%=?GP%
g%=FNprevious_gate(GP%)
pg%=FNpreceding_gate(GP%)
pg%=FNpreceding_gate(GP%):REM note-gate immediately before
NC%=-1
NN%=-1
FORC%=0TO7
......@@ -1779,18 +1797,29 @@ IFg%ANDNC%>0ANDNN%>=0 PROCsort
=Gchanged%
DEF PROCsort
LOCALN%,M%
LOCAL N%,M%
c%()=-1
FORM%=0TONC%
FORN%=0TONN%
IFFNsame_pitch(n%(M%),C%(N%)) c%(N%)=n%(M%)
NEXT
FOR M%=0 TO NC%
FOR N%=0 TO NN%
IF FNsame_pitch(n%(M%),C%(N%)) THEN
c%(N%)=n%(M%)
ENDIF
NEXT
NEXT
FORN%=0TONN%
IFc%(N%)<0 c%(N%)=FNbest
FOR N%=0 TO NN%
IF c%(N%)<0 THEN c%(N%)=FNbest
NEXT
FORN%=0TONN%
IFC%(N%)=c%(N%) ELSEGchanged%=TRUE:M%=FNin(c%(N%),C%()):IFM%>N% PROCswap_notes(N%,M%) ELSEPROCmove_note(N%)
FOR N%=0 TO NN%
IF C%(N%)=c%(N%) THEN
ELSE
Gchanged%=TRUE
M%=FNin(c%(N%),C%())
IF M%>N% THEN
PROCswap_notes(N%,M%)
ELSE
PROCmove_note(N%)
ENDIF
ENDIF
NEXT
ENDPROC
......@@ -1817,17 +1846,17 @@ LOCAL short%,free%,rest%,any%,tied%
FOR N%=NC%TO0STEP-1
C%=n%(N%)
IFFNin(C%,c%())<0 THEN
IFN%(C%)?-2AND4 THEN
tied%=C%+1
ELSE
IFpg%AND%1<<C% THEN
IF(N%(C%)?-1>>3)=shortest% short%=C%+1
IFN%(C%)?-2AND&F8 ELSErest%=C%+1
ELSE
free%=C%+1
ENDIF
any%=C%+1
ENDIF
IFN%(C%)?-2AND4 THEN
tied%=C%+1
ELSE
IFpg%AND%1<<C% THEN
IF(N%(C%)?-1>>3)=shortest% THENshort%=C%+1
IFN%(C%)?-2AND&F8 ELSErest%=C%+1
ELSE
free%=C%+1
ENDIF
any%=C%+1
ENDIF
ENDIF
NEXT
IFshort% C%=short% ELSEIFfree% C%=free% ELSEIFrest% C%=rest% ELSEIFany% C%=any% ELSEC%=tied%
......@@ -1954,10 +1983,16 @@ PW%(PX%)=R%:REM Width of new note
PTYPE%(PX%)=Note%:REM Note type
ENDPROC
DEF PROCbound_note(L%)
LOCALH%,S%,s%
H%=L%>>8AND&FF
IFL%AND&F8 S%=H%>>5ORL%<<3AND8 ELSES%=rest%ORH%>>5:REM Note/rest sprite
DEF PROCbound_note (L%)
LOCAL H%,S%,s%
H%=L%>>8 AND &FF
IF (L% AND &F8) THEN
REM Note
S%=H%>>5 OR L%<<3 AND &8
ELSE
REM Rest
S%=rest% OR H%>>5
ENDIF
lx0%=x%(S%):REM Prefix width
lx1%=X%(S%):REM Suffix width
ly0%=y%(S%):REM Decender height
......@@ -2086,6 +2121,16 @@ CASE key% OF
ENDCASE
=used%
DEF PROCscore_update (Window%!x0%,Window%!y0%,Window%!x1%,Window%!y1%)
Window%!handle%=ScoreWind_h%
SYS "Wimp_UpdateWindow",,Window%+handle% TO R%
WHILE R%
CLG
PROCdraw_staves
SYS "Wimp_GetRectangle",,Window%+handle% TO R%
ENDWHILE
ENDPROC
REM // Goto bar //
DEF PROCgoto_init
......@@ -2123,14 +2168,7 @@ CASE key% OF
ENDCASE
=used%
DEF PROCupdate_score(Window%!x0%,Window%!y0%,Window%!x1%,Window%!y1%)
Window%!handle%=ScoreWind_h%
SYS "Wimp_UpdateWindow",,Window%+handle% TO R%
WHILE R%
CLG:PROCdraw_staves
SYS "Wimp_GetRectangle",,Window%+handle% TO R%
ENDWHILE
ENDPROC
REM // Draw //
REM PROCEDURE: draw_staves
REM
......@@ -2167,12 +2205,10 @@ FORL%=Li%*2TOL%*2STEPL%
LINEc%,Y%+L%,lx1%,Y%+L%:REM Plot upper line
LINEc%,Y%-L%,lx1%,Y%-L%:REM Plot lower line
NEXT
ENDIF
NEXT
ENDPROC
::
REM PROCEDURE: draw_score(Based X%,Y%, PX bounds A%,B%)
REM
REM DESCRIPTION: Write current section of music score that appears between A%
......@@ -2226,6 +2262,7 @@ REPEAT
NC0%=?N%(C%) : NC1%=N%(C%)?1 :REM fast local vars
y%=Y%+Y_STAVE%(S_C%(C%))
IF NC0% AND &F8 THEN
REM Draw note
l%=(NC0%>>3)-16
ly%=y%
y%+=Li%*l%
......@@ -2242,6 +2279,7 @@ REPEAT
lasty%=y%
IF NC1% AND 7 PROCsprite(accidental% OR NC1% AND 7,x%-x%(s%),y%)
ELSE
REM Draw rest
s%=rest% OR NC1%>>5
PROCsprite(s%,x%,y%)
ENDIF
......@@ -2250,7 +2288,7 @@ REPEAT
N%(C%)+=2:REM Pull from note queue
UNTIL(2<<C%)>G%:REM Until no more notes (1 bits)
ENDPROC
::
DEF PROCdraw_attribute(A%)
LOCALx%,N%
N%=TRUE:REPEATN%-=TRUE:UNTILA%AND%1<<N%
......@@ -2423,6 +2461,8 @@ IF (STAVE%+1) AND 2 THEN
ENDIF
ENDPROC
REM // Put //
DEF PROCput_down
LOCALC%,PX%,X%,Y%,S%,s%
SYS "Hourglass_On"
......@@ -2493,7 +2533,7 @@ ENDPROC
DEF PROCput_tie
IF?N%(C%)AND4 THEN
PROCnote_tie(C%,FALSE)
PROCupdate_score(X%+24,Y%+12,X%+70,Y%+24)
PROCscore_update(X%+24,Y%+12,X%+70,Y%+24)
ELSE
LOCALI%
PROCnote_tie(C%,TRUE)
......@@ -2501,7 +2541,7 @@ PROCskip_notes(?GP%):GP%+=1
PROCarrange_stave(S%)
GP%=SCRIBE%(sgp%)
FORI%=0TO7:N%(I%)=SCRIBE%(I%):NEXT
IFN%(C%)+2>=FINE%(C%)OR(?N%(C%)EORN%(C%)?2)AND&F8 PROCnote_tie(C%,FALSE) ELSEPROCupdate_score(X%+24,Y%+12,X%+70,Y%+24)
IFN%(C%)+2>=FINE%(C%)OR(?N%(C%)EORN%(C%)?2)AND&F8 PROCnote_tie(C%,FALSE) ELSEPROCscore_update(X%+24,Y%+12,X%+70,Y%+24)
ENDIF
ENDPROC
......@@ -2511,7 +2551,7 @@ a%=N%(C%)?1AND7
A%=s%AND7
IFA%=a% A%=0
PROCnote_accidental(C%,A%)
IFA%*a% PROCupdate_score(X%-34,Y%-24,X%+16,Y%+52) ELSEPROCrescore(PX%)
IFA%*a% PROCscore_update(X%-34,Y%-24,X%+16,Y%+52) ELSEPROCrescore(PX%)
ENDPROC
DEF PROCput_dot
......@@ -2523,7 +2563,7 @@ PROCnote_dots(C%,D%)
IFD%*d% THEN
s%=N%(C%)?1>>5OR?N%(C%)<<3AND8:IF?N%(C%)AND&F8 ELSEs%=s%ORrest%
X%+=x%(s%)
PROCupdate_score(X%+24,Y%-8,X%+50,Y%)
PROCscore_update(X%+24,Y%-8,X%+50,Y%)
ELSE
PROCrescore(PX%)
ENDIF
......@@ -2607,7 +2647,7 @@ DEF PROCrescore(px%)
IFpx% ELSEPROCstart_music:REM Bar position assumed set, but reset if px%=0
PROCset_score(px%)
IF px%=0 PROCSetupBarStarts(0) ELSE PROCSetupBarStarts(FNFindBar(px%))
PROCupdate_score(PX%(px%),-Score_Height%,Score_Width%,0)
PROCscore_update(PX%(px%),-Score_Height%,Score_Width%,0)
ENDPROC
DEF PROCupdate_note(S%,N%,X%,Y%)
......@@ -2620,7 +2660,7 @@ IFX%(dot%)>lx1% lx1%=X%(dot%):REM Extend to ledger extent
ENDIF
ly1%+=Y%:Y%-=ly0%:ly0%=Y_STAVE%(S%):REM Stave position
IFly1%<ly0%-Li%*5 ly1%=ly0%-Li%*5 ELSEIFY%>ly0%+Li%*5 Y%=ly0%+Li%*5:REM If ledger lines will be drawn increase vertical update space
PROCupdate_score(X%-lx0%,Y%,X%+lx1%+Pgap%,ly1%):REM Update symbol space
PROCscore_update(X%-lx0%,Y%,X%+lx1%+Pgap%,ly1%):REM Update symbol space
ENDPROC
DEF PROCattach(s%,V%)
......@@ -2650,7 +2690,7 @@ ENDPROC
REM PROCEDURE: scribe(At X%,Y%)
REM
REM DESCRIPTION: Draw current music symbol at position over score window
:
DEF PROCscribe(X%,Y%)
LOCALS%,L%,C%
Window%!handle%=ScoreWind_h%
......@@ -2686,8 +2726,8 @@ PROCfloat(SCRIBE%(sprite%),X%,Y%)
ENDIF
ENDIF
ENDPROC
::
REM PROCEDURE: proximate(Positions valid mask V%)
REM PROCEDURE: proximate(Positions valid mask V%)
REM
REM DESCRIPTION: Will set X%,Y% to be the nearest valid position to the point
REM X%,Y% supplied (all in stave coordinates) and return the
......@@ -2703,14 +2743,20 @@ REM 5 -> To nearest stave line (else nearest stave)
REM 6 -> To nearest symbol present
REM 7 -> On bar line if near
REM
REM EFFECTS: Sets S%=Stave, L%=Line(-15..15), C%=Channel of note, GP%,N%()=Gate & note pointers, PX%=PX%() index, X%,Y% position
:
REM SETS: S% Stave
REM L% Line(-15..15)
REM C% Channel of note
REM GP%,N%() Gate and Note pointers
REM PX% PX%() index
REM X%,Y% Position
DEF PROCproximate(V%):REM (V%, var X%,Y%) = (S%,L%,PX%)
LOCALd%,D%:REM Distance previous&current
LOCALpx%,x%:REM Previous PX%, Between note X position
LOCALgp%:REM Previous gate pointer, key sig
LOCAL d%,D%:REM Distance previous&current
LOCAL px%,x%:REM Previous PX%, Between note X position
LOCAL gp%:REM Previous gate pointer, key sig
IF NBars%>4 THEN BAR%=LHBAR% ELSE BAR%=0
PROCGetBarInfo(BAR%) : REM Start from start of page
REM Start from start of page
PROCGetBarInfo(BAR%)
D%=4*S_Width%:REM A suitably excessive distance
IF V%AND7 THEN
LOCALT%:REM Type mask
......@@ -2792,11 +2838,23 @@ ENDIF
ENDIF
Y%=Y_STAVE%(S%)+L%*Li%:REM Centre line + offset
ENDPROC
::
DEF PROCsavp:n%()=N%():d%=D%:px%=PX%:gp%=GP%:clef%()=CLEF%():sig%()=SIG%():ENDPROC
DEF PROCsavp
n%()=N%()
d%=D%
px%=PX%
gp%=GP%
clef%()=CLEF%()
sig%()=SIG%()
ENDPROC
DEF PROCrstp:N%()=n%():PX%=px%:GP%=gp%:CLEF%()=clef%():SIG%()=sig%():ENDPROC
DEF PROCrstp
N%()=n%()
PX%=px%
GP%=gp%
CLEF%()=clef%()
SIG%()=sig%()
ENDPROC
DEF PROCSetTempo (t%)
Tempo%=t%
......@@ -4097,7 +4155,7 @@ REM ENDIF
IF lx1% > R% THEN R% = lx1%
NC0% = n%(C%)?0: NC1% = n%(C%)?1
y% = y2% + Y_STAVE%(S_C%(C%))
IF NC0% AND &f8 THEN
IF (NC0% AND &F8) THEN
l% = (NC0% >> 3) - 16
IF ABS(l%) > 5 PROCprint_sprite(ledger% + l% DIV 2, xs, y%, factors%)
y% += Li%*l%
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment