'##############
'Matrix Script
'##############

'Simulates 90s style Full Matrix Line and Terminus Display (Type AEG Krüger)

'(c) 17.09.2013 Marcel Kuhnt

'Script Version: 1.0
'Omsi release: 2.0

'Needs:
'- Cockpit (Batterietrennschalter)
'- IBIS

'NrSpecRandom Seed Area:
'971: Anzahl der Fehlerpixel pro Jahr


'Revision History:
'- Marcel Kuhnt		29.09.2012	Created from scratch
'- Marcel Kuhnt		17.09.2013	Steckschilder für ausgewählte Ziele
'- Marcel Kuhnt		17.09.2013	Seitenschild
'- Marcel Kuhnt		13.10.2013	Neuer Seitenschildpfad
'- Marcel Kuhnt		20.12.2013	Bugfix: Steckschild-Init
'- Neoplan VEST		21.11.2024	Anpassung auf BROSE Verhältnisse
'- Neoplan VEST		28.11.2024	Anpassung für 19 Zeilen
'------------------------------------------------------------------------------------------


{macro:Matrix_init}
	-1 (S.L.Matrix_RefreshCursor)
	(L.S.Year) (C.L.Matrix_Baujahr) - 0.01 max (C.L.Matrix_Fehlerpixel_pro_Jahr) * 971 (M.V.NrSpecRandom) 1 + * (S.L.Matrix_Fehlerpixel)

	-1 (S.L.matrix_steckschild_Termindex)
	0 (S.L.matrix_steckschild_vis)
{end}


{trigger:ai_scheduled_settarget}

'Stromversorgung herstellen:
	1 (S.L.elec_busbar_main_sw)	
	1.0 (S.L.elec_V_battery)

'Hier wird die Nummer eingestellt:
	(L.$.SetLineTo) (S.$.Matrix_Nr)

'Hier wird das Ziel eingestellt:
	1 (S.L.elec_busbar_main_sw)

	(L.L.AI_target_index) s0 (M.V.GetTerminusCode) s1
'Wenn der Terminus-Code größer als 1000 ist, dann bitte Steckschild verwenden:
	1000 >
	{if}
		l1 1000 - (S.L.matrix_steckschild_index)
		l0 (S.L.matrix_steckschild_Termindex)
'Matrix auf 0:
		0 (S.L.IBIS_TerminusIndex) s2
	{else}
		l0 (S.L.IBIS_TerminusIndex) s2
		-1 (S.L.matrix_steckschild_Termindex)

		-1 (S.L.Matrix_TerminusIndex_Last)

'Wenn der Bitmap-String in Verwendung ist, dann den als Integer interpretieren und Steckschild zusätzlich setzen:
		l0 6 (M.V.GetTerminusString) $StrToFloat s1
		l1 1000 >
		{if}
			l1 1000 - (S.L.matrix_steckschild_index)
			l0 (S.L.matrix_steckschild_Termindex)			
		{endif}

	{endif}
	(M.L.matrix_setsteckschild)

	l2 (M.V.GetTerminusCode) (S.L.IBIS_TerminusCode)

	1 (S.L.matrix_refresh_seitenschild)

{end}





'*******************************************
' Trigger für Seitenschild

{trigger:matrix_seitenschildklemme_drag}
	(L.S.mouse_y) -300 / (L.L.matrix_seitenschildklemme) + (S.L.matrix_seitenschildklemme) s0
	l0 0 <
	{if}
		0 (S.L.matrix_seitenschildklemme)
	{endif}
	l0 0.7 >
	{if}
		(L.L.matrix_seitenschild_refresh) 0 =
		{if}
			1 (S.L.matrix_seitenschild_refresh)
			(T.L.ev_fahrertuer_auf)
			(L.$.Matrix_Seitenschild) "" $=
			{if}
				1 (S.L.matrix_refresh_seitenschild)
			{else}
				"" (S.$.Matrix_Seitenschild)
			{endif}
		{endif}
	{endif}
	l0 1 >
	{if}
		1 (S.L.matrix_seitenschildklemme)
	{endif}
{end}

{trigger:matrix_seitenschildklemme_off}
	(L.L.matrix_seitenschildklemme)
	0.3 >
	{if}
		(T.L.ev_fahrertuer_zu)
	{endif}
	0 (S.L.matrix_seitenschildklemme)
	(S.L.matrix_seitenschild_refresh)
{end}

'*******************************************
' Trigger für Steckschild

{trigger:bus_matrix_change_steckschild}
	(L.L.matrix_steckschild_index) 1 + (S.L.matrix_steckschild_index)
	1000 + (M.V.GetTerminusIndex) (S.L.matrix_steckschild_Termindex)

	(M.L.matrix_setsteckschild)
	(M.L.matrix_refreshIntIndex)
{end}

{macro:matrix_setsteckschild}
	(L.L.matrix_steckschild_Termindex) s0
	0 >= 
	{if}
		l0 6 (M.V.GetTerminusString) (S.$.Matrix_SchildFrnt)
		1 $SetLengthL $StrToFloat 1 max (S.L.matrix_steckschild_vis)
		"..\..\Anzeigen\SteckSchilder\" (L.$.Matrix_SchildFrnt) $+ (S.$.Matrix_SchildFrnt)
	{else}
		0 (S.L.matrix_steckschild_index) (S.L.matrix_steckschild_vis)
		""  (S.$.Matrix_SchildFrnt)
	{endif}
{end}


{macro:Matrix_frame}

'******************************+
' Visible Steuerung für Repaint
'******************************+
	(L.L.vis_scoreboard) 1 =
	{if}
		(L.L.vis_Matrix_221_Bug) 1 =
		(L.L.vis_Matrix_213_Bug) 1 = ||
		{if}
			0 (S.L.vis_Matrix_Bug)
		{else}
			(L.L.vis_Matrix_221_Bug) 2 =
			(L.L.vis_Matrix_213_Bug) 2 = ||
			{if}
				1 (S.L.vis_Matrix_Bug)
			{else}
				1 (S.L.vis_Matrix_221_Bug) (S.L.vis_Matrix_213_Bug)
			{endif}
		{endif}

		(L.L.vis_Matrix_221_Seite) 1 =
		{if}
			0 (S.L.vis_Matrix_Seite)
		{else}
			(L.L.vis_Matrix_221_Seite) 2 =
			{if}
				1 (S.L.vis_Matrix_Seite)
			{else}
				1 (S.L.vis_Matrix_221_Seite)
			{endif}
		{endif}
	{endif}

	(L.L.vis_scoreboard_back) 2 =
	{if}
		(L.L.vis_Matrix_221_Heck) 1 =
		{if}
			0 (S.L.vis_Matrix_Heck)
		{else}
			(L.L.vis_Matrix_221_Heck) 2 =
			{if}
				1 (S.L.vis_Matrix_Heck)
			{else}
				1 (S.L.vis_Matrix_221_Heck)
			{endif}
		{endif}
	{endif}

	(L.L.vis_scoreboard_back) 3 =
	{if}
		(L.L.vis_Matrix_213_Heck) 1 =
		{if}
			0 (S.L.vis_Matrix_Heck)
		{else}
			(L.L.vis_Matrix_213_Heck) 2 =
			{if}
				1 (S.L.vis_Matrix_Heck)
			{else}
				1 (S.L.vis_Matrix_213_Heck)
			{endif}
		{endif}
		3 (S.L.vis_Matrix_221_Heck)
	{endif}

	(L.L.vis_scoreboard_back) 4 =
	{if}
		3 (S.L.vis_Matrix_213_Heck)
	{endif}

'******************************+
'     Matrix Beleuchtung
'******************************+

'	(L.L.cp_dummy_sw03) 1 =
	(L.L.cp_schluessel_rot) 0.2 > 
	(L.L.elec_busbar_main) &&
	{if}
		(L.L.engine_n) 600 >
		{if}
			1 (S.L.Matrix_light_Seite) (S.L.Matrix_light_Heck)
		{else}
			0 (S.L.Matrix_light_Seite) (S.L.Matrix_light_Heck)
		{endif}
		1 (S.L.Matrix_light_Front)
	{else}
		0 (S.L.Matrix_light_Front) (S.L.Matrix_light_Seite) (S.L.Matrix_light_Heck)
	{endif}

'******************************+
'    Terminus-Matrix
'******************************+

	"NV_S2xx_Brose_A0" (M.V.GetFontIndex) (S.L.Brose_A0)
	"NV_S2xx_Brose_A1" (M.V.GetFontIndex) (S.L.Brose_A1)
	"NV_S2xx_Brose_A2" (M.V.GetFontIndex) (S.L.Brose_A2)
	"NV_S2xx_Brose_A3" (M.V.GetFontIndex) (S.L.Brose_A3)
	"NV_S2xx_Brose_A4" (M.V.GetFontIndex) (S.L.Brose_A4)
	"NV_S2xx_Brose_A5" (M.V.GetFontIndex) (S.L.Brose_A5)
	"NV_S2xx_Brose_A6" (M.V.GetFontIndex) (S.L.Brose_A6)
	"NV_S2xx_Brose_A7" (M.V.GetFontIndex) (S.L.Brose_A7)
	"NV_S2xx_Brose_A8" (M.V.GetFontIndex) (S.L.Brose_A8)

'************************************************************+
'    Verschiedene Linien Fonts für Repants
'************************************************************+

	(L.L.Brose_LNR_Style) 0 = {if} "NV_S2xx_Brose_A3_2" (M.V.GetFontIndex) (S.L.Brose_Linie1) {endif}
	(L.L.Brose_LNR_Style) 1 = {if} "NV_S2xx_Brose_A3" (M.V.GetFontIndex) (S.L.Brose_Linie1) {endif}
	(L.L.Brose_LNR_Style) 2 = {if} "NV_S2xx_Brose_A3_3" (M.V.GetFontIndex) (S.L.Brose_Linie1) {endif}
	(L.L.Brose_LNR_Style) 3 = {if} "NV_S2xx_Brose_A1" (M.V.GetFontIndex) (S.L.Brose_Linie1) {endif}
	(L.L.Brose_LNR_Style) 4 = {if} "NV_S2xx_Brose_A2" (M.V.GetFontIndex) (S.L.Brose_Linie1)	{endif}
'	13x6 Linie
	"NV_S2xx_Brose_A4" (M.V.GetFontIndex) (S.L.Brose_Linie2)
'	10x6 Linie
	"NV_S2xx_Brose_A5" (M.V.GetFontIndex) (S.L.Brose_Linie3)

	(L.L.Brose_Style) 1 =
	{if}
		"NV_S2xx_Brose_2_A0" (M.V.GetFontIndex) (S.L.Brose_A0)
		"NV_S2xx_Brose_2_A1" (M.V.GetFontIndex) (S.L.Brose_A1)
		"NV_S2xx_Brose_2_A2" (M.V.GetFontIndex) (S.L.Brose_A2)
		"NV_S2xx_Brose_2_A3" (M.V.GetFontIndex) (S.L.Brose_A3)
		"NV_S2xx_Brose_2_A4" (M.V.GetFontIndex) (S.L.Brose_A4)
		"NV_S2xx_Brose_2_A5" (M.V.GetFontIndex) (S.L.Brose_A5)
		"NV_S2xx_Brose_2_A6" (M.V.GetFontIndex) (S.L.Brose_A6)
		"NV_S2xx_Brose_2_A7" (M.V.GetFontIndex) (S.L.Brose_A7)
		"NV_S2xx_Brose_A8" (M.V.GetFontIndex) (S.L.Brose_A8)
		(L.L.Brose_LNR_Style) 0 = {if} "NV_S2xx_Brose_2_A1" (M.V.GetFontIndex) (S.L.Brose_Linie1) {endif}
		(L.L.Brose_LNR_Style) 1 = {if} "NV_S2xx_Brose_2_A2" (M.V.GetFontIndex) (S.L.Brose_Linie1) {endif}
		(L.L.Brose_LNR_Style) 2 = {if} "NV_S2xx_Brose_2_A3" (M.V.GetFontIndex) (S.L.Brose_Linie1) {endif}
		(L.L.Brose_LNR_Style) 3 = {if} "NV_S2xx_Brose_2_A3" (M.V.GetFontIndex) (S.L.Brose_Linie1) {endif}
		(L.L.Brose_LNR_Style) 4 = {if} "NV_S2xx_Brose_2_A3" (M.V.GetFontIndex) (S.L.Brose_Linie1) {endif}
'	13x6 Linie
		"NV_S2xx_Brose_2_A4" (M.V.GetFontIndex) (S.L.Brose_Linie2)
'	10x6 Linie
		"NV_S2xx_Brose_2_A5" (M.V.GetFontIndex) (S.L.Brose_Linie3)
	{endif}

	(L.S.TimeGap) (L.L.Matrix_Timer) + (S.L.Matrix_Timer) (C.L.Matrix_PageDuration) 0.1 + >=
	(L.L.IBIS_TerminusIndex) (L.L.Matrix_TerminusIndex_Last) = &&
	(L.L.Matrix_TerminusAct) 0 > &&
	{if}
		(L.L.Matrix_TerminusAct) (M.V.GetTerminusCode) s0 1000 <
		{if}
			l0 (S.L.Matrix_Zielcode)
			l0 10000 + s0
		{else}
			l0 1000 + s0
		{endif}
		l0 (M.V.GetTerminusIndex) s1 0 >=
		{if}
			l1 (S.L.IBIS_TerminusIndex)
		{else}
			(L.L.Matrix_Zielcode) (M.V.GetTerminusIndex) (S.L.IBIS_TerminusIndex)
		{endif}
	{endif}

'Erster Schritt: Linie erstellen:

	(L.L.IBIS_Linie_Complex) s0 (L.L.Matrix_Nr_Last) = ! 
	(L.L.elec_busbar_main) &&
	{if}

		l0 100 / trunc s1
		(L.L.IBIS_Linie_Suffix) s4
' l0: Originalzahl; l1: erste drei Ziffern; l4: letzte zwei Ziffern

' Falls gleich 0, dann gar nix:
		l1 0 =
		{if}
			""
			0 (S.L.Matrix_InvertL)
		{else}
' Sonst die normale Nummer:
			l1 trunc $IntToStr
			0 (S.L.Matrix_InvertL)
		{endif}

		(S.$.Matrix_Nr)

' Speziell bei BROSE: Bei bestimmte Firmware wird mit lE90 die Linie ausgeblendet und das Ziel komplett zentriert.
		(L.L.IBIS_Linie_Suffix) 90 =
		{if}
			1 (S.L.lE90_Ziel_kpl)
		{else}
			0 (S.L.lE90_Ziel_kpl)
		{endif}
		
' ===============================================================================
' Falls jetzt die hinteren beiden Ziffern (l2) etwas Interessantes enthalten:
' ===============================================================================

		l4 1 =
		{if}
			"E" (L.$.Matrix_Nr) 2 $SetLengthR $RemoveSpaces $+
		{endif}
		l4 2 =
		{if}
			";"
		{endif}
		l4 3 =
		{if}
			"|"
			(L.$.Yard) "Neue Horizonte" $= {if} 1 (S.L.Matrix_InvertL) {endif}
		{endif}
		l4 4 =
		{if}
			(L.$.Matrix_Nr) "N" $+
		{endif}
		l4 5 = 
		{if}
			"S" (L.$.Matrix_Nr) 2 $SetLengthR $RemoveSpaces $+
		{endif}
		l4 6 =
		{if}
			"A" (L.$.Matrix_Nr) 2 $SetLengthR $RemoveSpaces $+
		{endif}

		l4 9 =
		{if}
			"E" (L.$.Matrix_Nr) 2 $SetLengthR $RemoveSpaces $+
		{endif}
		l4 10 =
		{if}
			(L.$.Matrix_Nr) "E" $+
		{endif}
		l4 11 =
		{if}
			"D" (L.$.Matrix_Nr) 2 $SetLengthR $RemoveSpaces $+
		{endif}
		l4 12 =
		{if}
			"C" (L.$.Matrix_Nr) 2 $SetLengthR $RemoveSpaces $+
		{endif}
		l4 13 =
		{if}
			"B" (L.$.Matrix_Nr) 2 $SetLengthR $RemoveSpaces $+
		{endif}
		l4 14 =
		{if}
			"A" (L.$.Matrix_Nr) 2 $SetLengthR $RemoveSpaces $+
		{endif}
		l4 15 =
		{if}
			"N" (L.$.Matrix_Nr) 2 $SetLengthR $RemoveSpaces $+
		{endif}

		l4 23 =
		{if}
			"S" (L.$.Matrix_Nr) 2 $SetLengthR $RemoveSpaces $+
			1 (S.L.Matrix_InvertL)
		{endif}

		l4 24 = 
		{if}
			">" (L.$.Matrix_Nr) 2 $SetLengthR $RemoveSpaces $+
		{endif}

		l4 25 =
		{if}
			"<" (L.$.Matrix_Nr) 2 $SetLengthR $RemoveSpaces $+
		{endif}
		l4 26 =
		{if}
			"U" (L.$.Matrix_Nr) 2 $SetLengthR $RemoveSpaces $+
		{endif}
		l4 27 =
		{if}
			"M" (L.$.Matrix_Nr) 2 $SetLengthR $RemoveSpaces $+
		{endif}
		l4 28 =
		{if}
			"M" (L.$.Matrix_Nr) 2 $SetLengthR $RemoveSpaces $+
		{endif}
		l4 29 =
		{if}
			"_"
		{endif}
		l4 30 =
		{if}
			(L.$.Matrix_Nr) "S" $+
			1 (S.L.Matrix_InvertL)
		{endif}
		l4 31 =
		{if}
			(L.$.Matrix_Nr) "U" $+
			1 (S.L.Matrix_InvertL)
		{endif}
		l4 32 =
		{if}
			(L.$.Matrix_Nr) "M" $+
		{endif}
		l4 35 =
		{if}
			"N" (L.$.Matrix_Nr) 2 $SetLengthR $RemoveSpaces $+
		{endif}
		l4 36 =
		{if}
			"X" (L.$.Matrix_Nr) 2 $SetLengthR $RemoveSpaces $+
		{endif}
		l4 37 =
		{if}
			"{" (L.$.Matrix_Nr) 2 $SetLengthR $RemoveSpaces $+
		{endif}
		l4 38 =
		{if}
			"}" (L.$.Matrix_Nr) 2 $SetLengthR $RemoveSpaces $+
		{endif}
		l4 39 =
		{if}
			"µ" (L.$.Matrix_Nr) 2 $SetLengthR $RemoveSpaces $+
		{endif}
		l4 40 =
		{if}
			"€"
		{endif}
		l4 41 =
		{if}
			"\"
		{endif}
		l4 42 =
		{if}
			"R" (L.$.Matrix_Nr) 2 $SetLengthR $RemoveSpaces $+
		{endif}
		l4 43 =
		{if}
			"§"
		{endif}
		l4 44 =
		{if}
			"$"
		{endif}
		l4 45 =
		{if}
			"%"
		{endif}
		l4 46 =
		{if}
			"["
		{endif}
		l4 47 =
		{if}
			"]"
		{endif}
		l4 90 =
		{if}
			" "
		{endif}
		l4 98 =
		{if}
			"~"
		{endif}
		
		(L.$.Yard) "Neue Horizonte" $=
		{if}
			l1 940 =
			{if}
				"\"
			{endif}
			
			l1 601 >= l1 609 <= && 
			{if}
				"X0" (L.$.Matrix_Nr) 1 $SetLengthR $+
				1 (S.L.Matrix_InvertL)
			{endif}
			
			l1 610 >= l1 699 <= && 
			{if}
				"X" (L.$.Matrix_Nr) 2 $SetLengthR $+
				1 (S.L.Matrix_InvertL)
			{endif}
		{endif}

		 $RemoveSpaces (S.$.Matrix_Nr)
	{endif}


'Zweiter Schritt: Ziel erstellen:

	(L.L.IBIS_TerminusIndex) s0 (L.L.Matrix_TerminusIndex_Last) s1 = !
	(L.L.elec_busbar_main) &&
	{if}
		l0 1 (M.V.GetTerminusString) $RemoveSpaces (S.$.Matrix_TerminusL1)
		l0 2 (M.V.GetTerminusString) $RemoveSpaces (S.$.Matrix_TerminusL2)

'Wenn nur die untere Zeile beschrieben ist, dann diese nach oben und untere leeren:
		(L.$.Matrix_TerminusL1) "" $=
		{if}
			(L.$.Matrix_TerminusL2) (S.$.Matrix_TerminusL1)
			"" (S.$.Matrix_TerminusL2)
		{endif}

'Zielfeld invertierung
        0 (S.L.Matrix_InvertL1) (S.L.Matrix_InvertL2)
        (L.$.Matrix_TerminusL1) 2 $SetLengthR "*I" 0 $= 
        {if}
            1 (S.L.Matrix_InvertL1)
            (L.$.Matrix_TerminusL1) 2 $cutEnd (S.$.Matrix_TerminusL1)
        {endif}
        (L.$.Matrix_TerminusL2) 2 $SetLengthR "*I" 0 $= 
        {if}
            1 (S.L.Matrix_InvertL2)
            (L.$.Matrix_TerminusL2) 2 $cutEnd (S.$.Matrix_TerminusL2)
        {endif}
        (L.$.Matrix_TerminusL2) "" $=
        {if}
            (L.L.Matrix_InvertL1) (S.L.Matrix_InvertL2)
        {endif}
	{endif}

'Dritter Schritt: Speicherbitmap schreiben:

    (L.L.IBIS_Linie_Complex) (L.L.Matrix_Nr_Last) = ! 
    (L.L.IBIS_TerminusIndex) s0 (L.L.Matrix_TerminusIndex_Last) s1 = ! ||
    (L.L.elec_busbar_main) &&
    {if}

'Überprüfen auf Unterlänge. Falls vorhanden Font Höher oder durch ein niedrigere Font ersetzen (WrieTerminus)
	(L.$.Matrix_TerminusL2) "" $=
	{if}
		(M.L.Matrix_CheckDescenderL1)
	{else}
		(M.L.Matrix_CheckDescenderL2)
	{endif}

	l0 (S.L.Matrix_TerminusAct)
	(L.L.IBIS_Linie_Complex) (S.L.Matrix_Nr_Last)
	(L.L.IBIS_Linie_Suffix) 99 = !
	{if}
	    l0 7 (M.V.GetTerminusString) $RemoveSpaces (S.$.Matrix_Bitmapfilename)
	    "" $=
	    {if}

'3.0 Initialisieren der Bitmap und setzen der Farbe:

		0 (M.V.STNewTex)
		0 (M.V.STLock)

		0
		0
		255
		0
		0
		(M.V.STSetColor)


'Ab hier gelten folgende Register-Zuordnungen:
'l0 = Fontindex
'l1 = Stringlänge (Pixel)
'l2 = Y-Offset
'l3 = Verfügbare Länge
'l4 = Einzeilig
'l5 = Zentrierungsaufschlag
'l6 = Sperrpixelfaktor
'l7 = (max.) Sperrung



		(L.$.Matrix_Nr) "" $=
		{if}
			0 s1 (S.L.Matrix_Xpos)
		{else}

'3.A.0 Sperrpixelfaktor (l6):
			(L.$.Matrix_Nr) $length 1 - 0 max s6
'3.A.05 Setzen der Maximalbreite:
			28 s3
' Zeichen umkodierung
			(L.$.Matrix_Nr) "P+R" $=
			{if}
				"€" (S.$.Matrix_Nr)
			{endif}
			(L.$.Matrix_Nr) "/^\" $=
			{if}
				";" (S.$.Matrix_Nr)
			{endif}
			(L.$.Matrix_Nr) "BVG" $=
			{if}
				"_" (S.$.Matrix_Nr)
			{endif}
			(L.$.Matrix_Nr) "Tram" $=
			(L.$.Matrix_Nr) "Strab" $= ||
			{if}
				"\" (S.$.Matrix_Nr)
			{endif}
			(L.$.Matrix_Nr) "-V-" $=
			(L.$.Matrix_Nr) "Vest" $= ||
			{if}
				"~" (S.$.Matrix_Nr)
			{endif}
			(L.$.Matrix_Nr) "gh" $=
			(L.$.Matrix_Nr) "gh " $= ||
			{if}
				"|" (S.$.Matrix_Nr)
			{endif}

'3.A.1 Bestimmen des Fonts der Linie (vorne):
' Bei 19 Zeilen Höhe
			(L.L.vis_Matrix_Bug) 1 =
			{if}
				0 s2
				(L.$.Matrix_Nr) (L.L.Brose_A0) s0 (M.V.TextLength) s1
				l3 >
				{if}
					1 s2
					(L.$.Matrix_Nr) (L.L.Brose_Linie1) s0 (M.V.TextLength) s1
					l3 >
					{if}
						4 s2
						(L.$.Matrix_Nr) (L.L.Brose_Linie3) s0 (M.V.TextLength) s1
					{endif}
				{endif}


'	l0: Schriftart, l1: Länge in Pixeln

'3.A.5 Berechnen der Sperrung:
				l3 l1 - l6 / trunc 2 min s7
				l1 l6 l7 * + s1
'3.A.6 Berechnen des Zentrierungsaufschlages (l5):
				l3 l1 - 2 / trunc s5

'3.A.7 Schreiben:
				0
				l5
				0 l2 +
				l0
				2
				l7
				(L.$.Matrix_Nr)
				(M.V.STTextOut)
			{else}
' Ansonsten nur bei 16 Zeilen
				0 s2
				(L.$.Matrix_Nr) (L.L.Brose_Linie1) s0 (M.V.TextLength) s1
				l3 >
				{if}
					1 s2
					(L.$.Matrix_Nr) (L.L.Brose_Linie2) s0 (M.V.TextLength) s1
					l3 >
					{if}
						2 s2
						(L.$.Matrix_Nr) (L.L.Brose_Linie3) s0 (M.V.TextLength) s1
					{endif}
				{endif}


'	l0: Schriftart, l1: Länge in Pixeln

'3.A.5 Berechnen der Sperrung:
				l3 l1 - l6 / trunc 2 min s7
				l1 l6 l7 * + s1
'3.A.6 Berechnen des Zentrierungsaufschlages (l5):
				l3 l1 - 2 / trunc s5

'3.A.7 Schreiben:
				0
				l5
				3 l2 +
				l0
				2
				l7
				(L.$.Matrix_Nr)
				(M.V.STTextOut)
			{endif}

'3.A.4 Bestimmen des Fonts der Linie (Rechts):


' Bei 19 Zeilen Höhe
			(L.L.vis_Matrix_Seite) 1 =
			{if}
				0 s2
				(L.$.Matrix_Nr) (L.L.Brose_A0) s0 (M.V.TextLength) s1
				l3 >
				{if}
					1 s2
					(L.$.Matrix_Nr) (L.L.Brose_Linie1) s0 (M.V.TextLength) s1
					l3 >
					{if}
						4 s2
						(L.$.Matrix_Nr) (L.L.Brose_Linie3) s0 (M.V.TextLength) s1
					{endif}
				{endif}


'	l0: Schriftart, l1: Länge in Pixeln

'3.A.5 Berechnen der Sperrung:
				l3 l1 - l6 / trunc 2 min s7
				l1 l6 l7 * + s1
'3.A.6 Berechnen des Zentrierungsaufschlages (l5):
				l3 l1 - 2 / trunc s5

'3.A.7 Schreiben:
				0
				l5
				19 l2 +
				l0
				2
				l7
				(L.$.Matrix_Nr)
				(M.V.STTextOut)
			{else}
' Ansonsten nur bei 16 Zeilen
				0 s2
				(L.$.Matrix_Nr) (L.L.Brose_Linie1) s0 (M.V.TextLength) s1
				l3 >
				{if}
					1 s2
					(L.$.Matrix_Nr) (L.L.Brose_Linie2) s0 (M.V.TextLength) s1
					l3 >
					{if}
						2 s2
						(L.$.Matrix_Nr) (L.L.Brose_Linie3) s0 (M.V.TextLength) s1
					{endif}
				{endif}


'	l0: Schriftart, l1: Länge in Pixeln

'3.A.5 Berechnen der Sperrung:
				l3 l1 - l6 / trunc 2 min s7
				l1 l6 l7 * + s1
'3.A.6 Berechnen des Zentrierungsaufschlages (l5):
				l3 l1 - 2 / trunc s5

'3.A.7 Schreiben:
				0
				l5
				22 l2 +
				l0
				2
				l7
				(L.$.Matrix_Nr)
				(M.V.STTextOut)
			{endif}

'3.A.5 Bestimmen des Fonts der Linie (Heck) 16 zeilig:

			(L.L.vis_Matrix_Heck) 1 =
			{if}
				0 s2
				(L.$.Matrix_Nr) (L.L.Brose_A0) s0 (M.V.TextLength) s1
				l3 >
				{if}
					1 s2
					(L.$.Matrix_Nr) (L.L.Brose_Linie1) s0 (M.V.TextLength) s1
					l3 >
					{if}
						4 s2
						(L.$.Matrix_Nr) (L.L.Brose_Linie3) s0 (M.V.TextLength) s1
					{endif}
				{endif}


'	l0: Schriftart, l1: Länge in Pixeln

'3.A.5 Berechnen der Sperrung:
				l3 l1 - l6 / trunc 2 min s7
				l1 l6 l7 * + s1
'3.A.6 Berechnen des Zentrierungsaufschlages (l5):
				l3 l1 - 2 / trunc s5

'3.A.7 Schreiben:
				0
				l5
				38 l2 +
				l0
				2
				l7
				(L.$.Matrix_Nr)
				(M.V.STTextOut)
			{else}
				0 s2
				(L.$.Matrix_Nr) (L.L.Brose_Linie1) s0 (M.V.TextLength) s1
				l3 >
				{if}
					1 s2
					(L.$.Matrix_Nr) (L.L.Brose_Linie2) s0 (M.V.TextLength) s1
					l3 >
					{if}
						2 s2
						(L.$.Matrix_Nr) (L.L.Brose_Linie3) s0 (M.V.TextLength) s1
					{endif}
				{endif}


'	l0: Schriftart, l1: Länge in Pixeln

'3.A.5 Berechnen der Sperrung:
				l3 l1 - l6 / trunc 2 min s7
				l1 l6 l7 * + s1
'3.A.6 Berechnen des Zentrierungsaufschlages (l5):
				l3 l1 - 2 / trunc s5

'3.A.7 Schreiben:
				0
				l5
				41 l2 +
				l0
				2
				l7
				(L.$.Matrix_Nr)
				(M.V.STTextOut)
			{endif}

'3.A.5 Bestimmen des Fonts der Linie (Heck) 13 zeilig:

			0 s2
			(L.$.Matrix_Nr) (L.L.Brose_Linie2) s0 (M.V.TextLength) s1
			l3 >
			{if}
				1 s2
				(L.$.Matrix_Nr) (L.L.Brose_Linie3) s0 (M.V.TextLength) s1
			{endif}

'	l0: Schriftart, l1: Länge in Pixeln

'3.A.5 Berechnen der Sperrung:
			l3 l1 - l6 / trunc 2 min s7
			l1 l6 l7 * + s1
'3.A.6 Berechnen des Zentrierungsaufschlages (l5):
			l3 l1 - 2 / trunc s5

'3.A.7 Schreiben:
			0
			30 l5 +
			44 l2 +
			l0
			2
			l7
			(L.$.Matrix_Nr)
			(M.V.STTextOut)
		{endif}


'Schreiben des Zieles Front-Anzeige:

		(L.L.lE90_Ziel_kpl) 0 =
		{if}
			(L.L.vis_Matrix_Bug) 1 =
			{if}
				28 (S.L.Matrix_Xpos)
				0 (S.L.Matrix_Ypos)

				(M.L.Matrix_WriteTerminus_19)
			{else}
				28 (S.L.Matrix_Xpos)
				3 (S.L.Matrix_Ypos)

				(M.L.Matrix_WriteTerminus)
			{endif}

'Und Schreiben des Zieles Seitenanzeige:

			(L.L.vis_Matrix_Seite) 1 =
			{if}
				28 (S.L.Matrix_Xpos)
				19 (S.L.Matrix_Ypos)

				(M.L.Matrix_WriteTerminus_19)
			{else}
				28 (S.L.Matrix_Xpos)
				22 (S.L.Matrix_Ypos)

				(M.L.Matrix_WriteTerminus)
			{endif}
		{else}
			(L.L.vis_Matrix_Bug) 1 =
			{if}
				0 (S.L.Matrix_Xpos)
				0 (S.L.Matrix_Ypos)

				(M.L.Matrix_WriteTerminus_19)
			{else}
				0 (S.L.Matrix_Xpos)
				3 (S.L.Matrix_Ypos)

				(M.L.Matrix_WriteTerminus)
			{endif}

'Und Schreiben des Zieles Seitenanzeige:

			(L.L.vis_Matrix_Seite) 1 =
			{if}
				0 (S.L.Matrix_Xpos)
				19 (S.L.Matrix_Ypos)

				(M.L.Matrix_WriteTerminus_19)
			{else}
				0 (S.L.Matrix_Xpos)
				22 (S.L.Matrix_Ypos)

				(M.L.Matrix_WriteTerminus)
			{endif}
		{endif}

'Fertig: Unlocken


		0 (M.V.STUnlock)

	    {else}
		"..\..\Anzeigen\Brose_S2xx\" (L.$.Matrix_Bitmapfilename) $+ 0 (M.V.STLoadTex) $msg
	    {endif}
	    (L.L.Matrix_TerminusAct) (S.L.Matrix_TerminusIndex_Last)
	    (M.L.matrix_refreshIntIndex)
	{endif}
'RefreshCursor zurücksetzen:
	0 (S.L.Matrix_RefreshCursor)
    {endif}



'Nun sollen die Pixel schrittweise übertragen werden - zunächst mit 1Pixel/Frame:



	(L.L.elec_busbar_main)
	(L.L.Matrix_RefreshCursor) 0 >= &&
	{if}	


'Locken:
		0 (M.V.STLock)
		1 (M.V.STLock)


'Sound abspielen:

		(L.L.Matrix_RefreshCursor) 0 =
		{if}
			(T.L.ev_Matrix_Terminus_change)
		{endif}


		(M.L.Matrix_PixelRefresh_x3)
		(M.L.Matrix_PixelRefresh_x3)
		(M.L.Matrix_PixelRefresh_x3)
		(M.L.Matrix_PixelRefresh_x3)
		(M.L.Matrix_PixelRefresh_x3)
		(M.L.Matrix_PixelRefresh_x3)
		(M.L.Matrix_PixelRefresh_x3)
		(M.L.Matrix_PixelRefresh_x3)
		(M.L.Matrix_PixelRefresh_x3)
		(M.L.Matrix_PixelRefresh_x3)
		(M.L.Matrix_PixelRefresh_x3)
		(M.L.Matrix_PixelRefresh_x3)
		(M.L.Matrix_PixelRefresh_x3)
		(M.L.Matrix_PixelRefresh_x3)
		(M.L.Matrix_PixelRefresh_x3)
		(M.L.Matrix_PixelRefresh_x3)
		(M.L.Matrix_PixelRefresh_x3)
		(M.L.Matrix_PixelRefresh_x3)
		(M.L.Matrix_PixelRefresh_x3)
		(M.L.Matrix_PixelRefresh_x3)
		(M.L.Matrix_PixelRefresh_x3)
		(M.L.Matrix_PixelRefresh_x3)

		0 (S.L.Matrix_Timer)

'Unlocken:
		
		0 (M.V.STUnlock)
		1 (M.V.STUnlock)
		1 (M.V.STFilter)


	{endif}



			

'Aktualisierung der Code-Tafel:

	"Linienlisten\" (L.$.yard) "_ANX.jpg" $+ $+ (S.$.Matrix_Linelist)

	(L.L.matrix_refresh_seitenschild)
	{if}
		"..\..\Anzeigen\Seitenschilder\" 2 (M.V.GetDepotStringGlobal) $+ "\" $+ (L.$.Matrix_Nr) $RemoveSpaces $+ ".bmp" $+ (S.$.Matrix_Seitenschild)
		0 (S.L.matrix_refresh_seitenschild)
	{endif}

{end}




'*------------------------------------------------------------------------------------------------------------

{macro:Matrix_PixelRefresh_x3}
	0 s0
	(M.L.Matrix_PixelRefresh)
	(L.L.Matrix_RefreshCursor) 1 - (S.L.Matrix_RefreshCursor)
	1 s0
	(M.L.Matrix_PixelRefresh)
	(L.L.Matrix_RefreshCursor) 1 - (S.L.Matrix_RefreshCursor)
	2 s0
	(M.L.Matrix_PixelRefresh)
{end}

{macro:Matrix_PixelRefresh}
		(L.L.Matrix_RefreshCursor) (C.L.Matrix_HxW) >=
		(L.L.Matrix_RefreshCursor) 0 < ||
		{if}
			(L.L.IBIS_Linie_Suffix) 99 =
			{if}
				(L.L.Matrix_Testcolor) ! (S.L.Matrix_Testcolor)
				0
			{else}
				0 (S.L.Matrix_Timer)
				-1
			{endif}
			(S.L.Matrix_RefreshCursor)
		{else}


'X und Y berechnen:
'l0: Ebene (vorne/Seite)
'l1: X
'l2: Y

			(L.L.Matrix_RefreshCursor) (C.L.Matrix_HxW) % (C.L.Matrix_Height) / trunc s1
			(L.L.Matrix_RefreshCursor) (C.L.Matrix_HxW) % (C.L.Matrix_Height) / trunc s1
			(L.L.Matrix_RefreshCursor) (C.L.Matrix_HxW) % (C.L.Matrix_Height) % s2

'Fehlerpixel berechnen:
			(L.L.Matrix_RefreshCursor) (M.V.NrSpecRandom) 2 * (L.L.Matrix_Fehlerpixel) / s6
			1 <
			{if}
				255 s7
			{else}
			l6 2 <
			{if}
				0 s7
			{else}
'Wenn 99er-Code, dann alles grün:
			(L.L.IBIS_Linie_Suffix) 99 =
			{if}
				(L.L.Matrix_Testcolor) 255 * s7
			{else}

'Farbe setzen:
				0
				l1
				l2 l0 19 * +
				(M.V.STReadPixel) 

				0 (M.V.STGetR) s7
				
'Überprüfe ob nur das Zielfeld betroffen ist oder die Komplette Anzeige

				(L.L.lE90_Ziel_kpl) 1 =
                {if}
' Wurde am IBIS lE90 ausgewählt, dann das Linienfeld auf der Frontanzeige mit invertieren. Seite nicht, da abgesetzte Linie ist. 
					l0 0 = l2 0 >= l2 10 <= (L.L.Matrix_InvertL1) && && &&
					l0 0 = l2 11 >= l2 18 <= (L.L.Matrix_InvertL2) && && && ||
					l1 0 >= &&
					l0 1 = l2 0 >= l2 10 <= (L.L.Matrix_InvertL1) && && &&
					l0 1 = l2 11 >= l2 18 <= (L.L.Matrix_InvertL2) && && && ||
					l1 0 >= && ||
				{else}
' Ansonsten das Linienfeld nicht invertieren
					l0 0 = l2 0 >= l2 10 <= (L.L.Matrix_InvertL1) && && &&
					l0 0 = l2 11 >= l2 18 <= (L.L.Matrix_InvertL2) && && && ||
					l1 28 >= &&
					l0 1 = l2 0 >= l2 10 <= (L.L.Matrix_InvertL1) && && &&
					l0 1 = l2 11 >= l2 18 <= (L.L.Matrix_InvertL2) && && && ||
					l1 28 >= && ||
                {endif}
                {if}
                    l7 255 = {if} 0 s7 {else} 255 s7 {endif}
                {endif}

' Soll bei bestimmte Liniendarstellung das Linienfeld invertieren?
				l0 0 = l2 0 >= l2 7 <= (L.L.Matrix_InvertL) && && &&
				l0 0 = l2 8 >= l2 18 <= (L.L.Matrix_InvertL) && && && ||
				l1 27 <= &&
				l0 1 = l2 0 >= l2 7 <= (L.L.Matrix_InvertL) && && &&
				l0 1 = l2 8 >= l2 18 <= (L.L.Matrix_InvertL) && && && ||
				l1 27 <= && ||
				l0 2 = l2 0 >= l2 7 <= (L.L.Matrix_InvertL) && && &&
				l0 2 = l2 8 >= l2 18 <= (L.L.Matrix_InvertL) && && && ||
				l1 58 <= && ||
                {if}
                    l7 255 = {if} 0 s7 {else} 255 s7 {endif}
                {endif}
			{endif}
			{endif}
			{endif}


			1
			l7
			255
			255
			255
			(M.V.STSetColor)

'Pixel zeichnen:
			1
			l1 (C.L.Matrix_PixelFactor) * s4
			l2 l0 19 * + (C.L.Matrix_PixelFactor) * s5
			l4 (C.L.Matrix_PixelFactor) + 2 -
			l5 (C.L.Matrix_PixelFactor) + 2 -
			(M.V.STDrawRect)

'Cursor verschieben:
			(L.L.Matrix_RefreshCursor) 1 + (S.L.Matrix_RefreshCursor)
		{endif}
{end}


{macro:Matrix_WriteTerminus}

'3.B.2 Bestimmen der verbliebenen Länge des Zieles vorne (l3):
		112 (L.L.Matrix_Xpos) - s3


'3.B.3 Einzeilig (l4)?
		(L.$.Matrix_TerminusL2) "" $= s4

'3.B.4 Bestimmen des Fonts der Zeile 1 des Ziels (l0/l1):

		l4 {if}
			3 s7
			(L.L.Matrix_TerminusL1HasDescender) 1 =
			{if}
				0 s2
				(L.$.Matrix_TerminusL1) (L.L.Brose_A4) s0 (M.V.TextLength) s1
			{else}
				0 s2
				(L.$.Matrix_TerminusL1) (L.L.Brose_A2) s0 (M.V.TextLength) s1
			{endif}
			l3 >
			{if}
				3 s7
				(L.L.Matrix_TerminusL1HasDescender) 1 =
				{if}
					0 s2
					(L.$.Matrix_TerminusL1) (L.L.Brose_A4) s0 (M.V.TextLength) s1
				{else}
					0 s2
					(L.$.Matrix_TerminusL1) (L.L.Brose_A3) s0 (M.V.TextLength) s1
				{endif}
				l3 >
				{if}
					3 s7
					(L.L.Matrix_TerminusL1HasDescender) 1 =
					{if}
						0 s2
						(L.$.Matrix_TerminusL1) (L.L.Brose_A4) s0 (M.V.TextLength) s1
					{else}
						1 s2
						(L.$.Matrix_TerminusL1) (L.L.Brose_A4) s0 (M.V.TextLength) s1
					{endif}
					l3 >
					{if}
						3 s7
						3 s2
						(L.$.Matrix_TerminusL1) (L.L.Brose_A5) s0 (M.V.TextLength) s1
						l3 >
						{if}
							3 s7
							4 s2
							(L.$.Matrix_TerminusL1) (L.L.Brose_A6) s0 (M.V.TextLength) s1
							l3 >
							{if}
								3 s7
								4 s2
								(L.$.Matrix_TerminusL1) (L.L.Brose_A7) s0 (M.V.TextLength) s1
								l3 >
								{if}
									3 s7
									4 s2
									(L.$.Matrix_TerminusL1) (L.L.Brose_A8) s0 (M.V.TextLength) s1
								{endif}
							{endif}
						{endif}
					{endif}
				{endif}
			{endif}
		{else}
			0 s2
			2 s7
			(L.$.Matrix_TerminusL1) (L.L.Brose_A6) s0 (M.V.TextLength) s1
			l3 >
			{if}
				2 s7
				0 s2
				(L.$.Matrix_TerminusL1) (L.L.Brose_A7) s0 (M.V.TextLength) s1
				l3 >
				{if}
					2 s7
					0 s2
					(L.$.Matrix_TerminusL1) (L.L.Brose_A8) s0 (M.V.TextLength) s1
				{endif}
			{endif}
		{endif}
'3.B.5 Berechnen des Sperrpixelfaktors: (Anzahl der Buchstaben, l6)
	(L.$.Matrix_TerminusL1) $length 1 - 0 max s6
'3.B.6 Berechnen der Sperrung:
	l3 l1 - l6 / trunc l7 min s7
	l1 l6 l7 * + s1
'3.B.7 Berechnen des Zentrierungsaufschlages (l5):
	l3 l1 - 2 / trunc s5
'3.B.8 Schreiben:
			0
			(L.L.Matrix_Xpos) l5 +
			(L.L.Matrix_Ypos) l2 +
			l0
			2
			l7
			(L.$.Matrix_TerminusL1)
			(M.V.STTextOut)

	


'3.C.1 Bestimmen des Fonts der Zeile 2 des Ziels (l0/l1):
		l4 ! {if}
			(L.L.Matrix_TerminusL2HasDescender) 1 =
			{if}
				8 s2
				(L.$.Matrix_TerminusL2) (L.L.Brose_A6) s0 (M.V.TextLength) s1
			{else}
				9 s2
				(L.$.Matrix_TerminusL2) (L.L.Brose_A6) s0 (M.V.TextLength) s1
			{endif}
			l3 >
			{if}
				(L.L.Matrix_TerminusL2HasDescender) 1 =
				{if}
					8 s2
					(L.$.Matrix_TerminusL2) (L.L.Brose_A7) s0 (M.V.TextLength) s1
				{else}
					9 s2
					(L.$.Matrix_TerminusL2) (L.L.Brose_A7) s0 (M.V.TextLength) s1
				{endif}
			{endif}
			l3 >
			{if}
				(L.L.Matrix_TerminusL2HasDescender) 1 =
				{if}
					8 s2
					(L.$.Matrix_TerminusL2) (L.L.Brose_A8) s0 (M.V.TextLength) s1
				{else}
					9 s2
					(L.$.Matrix_TerminusL2) (L.L.Brose_A8) s0 (M.V.TextLength) s1
				{endif}
			{endif}

'3.C.2 Berechnen des Sperrpixelfaktors: (Anzahl der Buchstaben, l6)
	(L.$.Matrix_TerminusL2) $length 1 - 0 max s6
'3.C.3 Berechnen der Sperrung:
	l3 l1 - l6 / trunc 2 min s7
	l1 l6 l7 * + s1
'3.C.4 Berechnen des Zentrierungsaufschlages (l5):
	l3 l1 - 2 / trunc s5
'3.C.5 Schreiben:
			0
			(L.L.Matrix_Xpos) l5 +
			(L.L.Matrix_Ypos) l2 +
			l0
			2
			l7
			(L.$.Matrix_TerminusL2)
			(M.V.STTextOut)


		{endif}
{end}

{macro:Matrix_WriteTerminus_19}

'3.B.2 Bestimmen der verbliebenen Länge des Zieles vorne (l3):
		112 (L.L.Matrix_Xpos) - s3


'3.B.3 Einzeilig (l4)?
		(L.$.Matrix_TerminusL2) "" $= s4

'3.B.4 Bestimmen des Fonts der Zeile 1 des Ziels (l0/l1):

		l4 {if}
			3 s7
			(L.L.Matrix_TerminusL1HasDescender) 1 =
			{if}
				0 s2
				(L.$.Matrix_TerminusL1) (L.L.Brose_A2) s0 (M.V.TextLength) s1
			{else}
				2 s2
				(L.$.Matrix_TerminusL1) (L.L.Brose_A2) s0 (M.V.TextLength) s1
			{endif}
			l3 >
			{if}
				3 s7
				(L.L.Matrix_TerminusL1HasDescender) 1 =
				{if}
					0 s2
					(L.$.Matrix_TerminusL1) (L.L.Brose_A3) s0 (M.V.TextLength) s1
				{else}
					2 s2
					(L.$.Matrix_TerminusL1) (L.L.Brose_A3) s0 (M.V.TextLength) s1
				{endif}
				l3 >
				{if}
					3 s7
					(L.L.Matrix_TerminusL1HasDescender) 1 =
					{if}
						1 s2
						(L.$.Matrix_TerminusL1) (L.L.Brose_A4) s0 (M.V.TextLength) s1
					{else}
						3 s2
						(L.$.Matrix_TerminusL1) (L.L.Brose_A4) s0 (M.V.TextLength) s1
					{endif}
					l3 >
					{if}
						3 s7
						4 s2
						(L.$.Matrix_TerminusL1) (L.L.Brose_A5) s0 (M.V.TextLength) s1
						l3 >
						{if}
							3 s7
							5 s2
							(L.$.Matrix_TerminusL1) (L.L.Brose_A6) s0 (M.V.TextLength) s1
							l3 >
							{if}
								3 s7
								5 s2
								(L.$.Matrix_TerminusL1) (L.L.Brose_A7) s0 (M.V.TextLength) s1
								l3 >
								{if}
									3 s7
									5 s2
									(L.$.Matrix_TerminusL1) (L.L.Brose_A8) s0 (M.V.TextLength) s1
								{endif}
							{endif}
						{endif}
					{endif}
				{endif}
			{endif}
		{else}
			0 s2
			2 s7
			(L.$.Matrix_TerminusL1) (L.L.Brose_A5) s0 (M.V.TextLength) s1
			l3 >
			{if}
				0 s2
				2 s7
				(L.$.Matrix_TerminusL1) (L.L.Brose_A6) s0 (M.V.TextLength) s1
				l3 >
				{if}
					2 s7
					0 s2
					(L.$.Matrix_TerminusL1) (L.L.Brose_A7) s0 (M.V.TextLength) s1
					l3 >
					{if}
						2 s7
						0 s2
						(L.$.Matrix_TerminusL1) (L.L.Brose_A8) s0 (M.V.TextLength) s1
					{endif}
				{endif}
			{endif}
		{endif}
'3.B.5 Berechnen des Sperrpixelfaktors: (Anzahl der Buchstaben, l6)
	(L.$.Matrix_TerminusL1) $length 1 - 0 max s6
'3.B.6 Berechnen der Sperrung:
	l3 l1 - l6 / trunc l7 min s7
	l1 l6 l7 * + s1
'3.B.7 Berechnen des Zentrierungsaufschlages (l5):
	l3 l1 - 2 / trunc s5
'3.B.8 Schreiben:
			0
			(L.L.Matrix_Xpos) l5 +
			(L.L.Matrix_Ypos) l2 +
			l0
			2
			l7
			(L.$.Matrix_TerminusL1)
			(M.V.STTextOut)

	


'3.C.1 Bestimmen des Fonts der Zeile 2 des Ziels (l0/l1):
		l4 ! {if}
			(L.L.Matrix_TerminusL2HasDescender) 1 =
			{if}
				11 s2
				(L.$.Matrix_TerminusL2) (L.L.Brose_A6) s0 (M.V.TextLength) s1
			{else}
				12 s2
				(L.$.Matrix_TerminusL2) (L.L.Brose_A6) s0 (M.V.TextLength) s1
			{endif}
			l3 >
			{if}
				(L.L.Matrix_TerminusL2HasDescender) 1 =
				{if}
					11 s2
					(L.$.Matrix_TerminusL2) (L.L.Brose_A7) s0 (M.V.TextLength) s1
				{else}
					12 s2
					(L.$.Matrix_TerminusL2) (L.L.Brose_A7) s0 (M.V.TextLength) s1
				{endif}
			{endif}
			l3 >
			{if}
				(L.L.Matrix_TerminusL2HasDescender) 1 =
				{if}
					11 s2
					(L.$.Matrix_TerminusL2) (L.L.Brose_A8) s0 (M.V.TextLength) s1
				{else}
					12 s2
					(L.$.Matrix_TerminusL2) (L.L.Brose_A8) s0 (M.V.TextLength) s1
				{endif}
			{endif}

'3.C.2 Berechnen des Sperrpixelfaktors: (Anzahl der Buchstaben, l6)
	(L.$.Matrix_TerminusL2) $length 1 - 0 max s6
'3.C.3 Berechnen der Sperrung:
	l3 l1 - l6 / trunc 2 min s7
	l1 l6 l7 * + s1
'3.C.4 Berechnen des Zentrierungsaufschlages (l5):
	l3 l1 - 2 / trunc s5
'3.C.5 Schreiben:
			0
			(L.L.Matrix_Xpos) l5 +
			(L.L.Matrix_Ypos) l2 +
			l0
			2
			l7
			(L.$.Matrix_TerminusL2)
			(M.V.STTextOut)


		{endif}
{end}

{macro:matrix_refreshIntIndex}
	(L.L.matrix_steckschild_Termindex) s0 0 >=
	l0 0 (M.V.GetTerminusString) "" $= ! &&
	{if}
		l0
	{else}
		(L.L.Matrix_TerminusAct)
	{endif}
	(S.L.target_index_int)
{end}





{macro:Matrix_CheckDescenderL1}
	0 (S.L.Matrix_TerminusL1HasDescender)
	1 (S.L.Matrix_RefreshCursor)
	(M.L.Matrix_CheckDescender3)
	(M.L.Matrix_CheckDescender3)
	(M.L.Matrix_CheckDescender3)
	0 (S.L.Matrix_RefreshCursor)
{end}

{macro:Matrix_CheckDescender3}
	(M.L.Matrix_CheckDescender2)
	(M.L.Matrix_CheckDescender2)
{end}

{macro:Matrix_CheckDescender2}
	(M.L.Matrix_CheckDescender1)
	(M.L.Matrix_CheckDescender1)
{end}

{macro:Matrix_CheckDescender1}
	(M.L.Matrix_CheckDescender0)
	(M.L.Matrix_CheckDescender0)
{end}

{macro:Matrix_CheckDescender0}
	(L.$.Matrix_TerminusL1) $length s7 (L.L.Matrix_RefreshCursor) >=
	{if}
		l7 (L.L.Matrix_RefreshCursor) - s7
		(L.$.Matrix_TerminusL1) (L.L.Matrix_RefreshCursor) 1 - $cutBegin l7 $cutEnd "g" $=
		(L.$.Matrix_TerminusL1) (L.L.Matrix_RefreshCursor) 1 - $cutBegin l7 $cutEnd "j" $= ||
		(L.$.Matrix_TerminusL1) (L.L.Matrix_RefreshCursor) 1 - $cutBegin l7 $cutEnd "p" $= ||
		(L.$.Matrix_TerminusL1) (L.L.Matrix_RefreshCursor) 1 - $cutBegin l7 $cutEnd "q" $= ||
		(L.$.Matrix_TerminusL1) (L.L.Matrix_RefreshCursor) 1 - $cutBegin l7 $cutEnd "y" $= ||
		{if}
			1 (S.L.Matrix_TerminusL1HasDescender)
		{endif}
		(L.L.Matrix_RefreshCursor) 1 + (S.L.Matrix_RefreshCursor)
	{endif}
{end}

'Das ganze nochmal für die untere Zeile
{macro:Matrix_CheckDescenderL2}
	0 (S.L.Matrix_TerminusL2HasDescender)
	1 (S.L.Matrix_RefreshCursor)
	(M.L.Matrix_CheckDescender3L2)
	(M.L.Matrix_CheckDescender3L2)
	(M.L.Matrix_CheckDescender3L2)
	0 (S.L.Matrix_RefreshCursor)
{end}

{macro:Matrix_CheckDescender3L2}
	(M.L.Matrix_CheckDescender2L2)
	(M.L.Matrix_CheckDescender2L2)
{end}

{macro:Matrix_CheckDescender2L2}
	(M.L.Matrix_CheckDescender1L2)
	(M.L.Matrix_CheckDescender1L2)
{end}

{macro:Matrix_CheckDescender1L2}
	(M.L.Matrix_CheckDescender0L2)
	(M.L.Matrix_CheckDescender0L2)
{end}

{macro:Matrix_CheckDescender0L2}
	(L.$.Matrix_TerminusL2) $length s7 (L.L.Matrix_RefreshCursor) >=
	{if}
		l7 (L.L.Matrix_RefreshCursor) - s7
		(L.$.Matrix_TerminusL2) (L.L.Matrix_RefreshCursor) 1 - $cutBegin l7 $cutEnd "g" $=
		(L.$.Matrix_TerminusL2) (L.L.Matrix_RefreshCursor) 1 - $cutBegin l7 $cutEnd "j" $= ||
		(L.$.Matrix_TerminusL2) (L.L.Matrix_RefreshCursor) 1 - $cutBegin l7 $cutEnd "p" $= ||
		(L.$.Matrix_TerminusL2) (L.L.Matrix_RefreshCursor) 1 - $cutBegin l7 $cutEnd "q" $= ||
		(L.$.Matrix_TerminusL2) (L.L.Matrix_RefreshCursor) 1 - $cutBegin l7 $cutEnd "y" $= ||
		(L.$.Matrix_TerminusL2) (L.L.Matrix_RefreshCursor) 1 - $cutBegin l7 $cutEnd "," $= ||
'	Anpassung auf einzelne Zeichensätze
		(L.L.Brose_A5) 
		{if} 
			(L.$.Matrix_TerminusL2) (L.L.Matrix_RefreshCursor) 1 - $cutBegin l7 $cutEnd "g" $=
			(L.$.Matrix_TerminusL2) (L.L.Matrix_RefreshCursor) 1 - $cutBegin l7 $cutEnd "j" $= ||
			(L.$.Matrix_TerminusL2) (L.L.Matrix_RefreshCursor) 1 - $cutBegin l7 $cutEnd "p" $= ||
			(L.$.Matrix_TerminusL2) (L.L.Matrix_RefreshCursor) 1 - $cutBegin l7 $cutEnd "q" $= ||
			(L.$.Matrix_TerminusL2) (L.L.Matrix_RefreshCursor) 1 - $cutBegin l7 $cutEnd "y" $= ||
			(L.$.Matrix_TerminusL2) (L.L.Matrix_RefreshCursor) 1 - $cutBegin l7 $cutEnd "ß" $= ||
			(L.$.Matrix_TerminusL2) (L.L.Matrix_RefreshCursor) 1 - $cutBegin l7 $cutEnd "," $= ||
		{endif}
		(L.L.Brose_A6) 
		(L.L.Brose_A7) ||
		(L.L.Brose_A8) ||
		{if} 
			(L.$.Matrix_TerminusL2) (L.L.Matrix_RefreshCursor) 1 - $cutBegin l7 $cutEnd "g" $=
			(L.$.Matrix_TerminusL2) (L.L.Matrix_RefreshCursor) 1 - $cutBegin l7 $cutEnd "j" $= ||
			(L.$.Matrix_TerminusL2) (L.L.Matrix_RefreshCursor) 1 - $cutBegin l7 $cutEnd "p" $= ||
			(L.$.Matrix_TerminusL2) (L.L.Matrix_RefreshCursor) 1 - $cutBegin l7 $cutEnd "q" $= ||
			(L.$.Matrix_TerminusL2) (L.L.Matrix_RefreshCursor) 1 - $cutBegin l7 $cutEnd "y" $= ||
			(L.$.Matrix_TerminusL2) (L.L.Matrix_RefreshCursor) 1 - $cutBegin l7 $cutEnd "ß" $= ||
			(L.$.Matrix_TerminusL2) (L.L.Matrix_RefreshCursor) 1 - $cutBegin l7 $cutEnd ">" $= ||
			(L.$.Matrix_TerminusL2) (L.L.Matrix_RefreshCursor) 1 - $cutBegin l7 $cutEnd "," $= ||
		{endif}
		{if}
			1 (S.L.Matrix_TerminusL2HasDescender)
		{endif}
		(L.L.Matrix_RefreshCursor) 1 + (S.L.Matrix_RefreshCursor)
	{endif}
{end}

