about summary refs log tree commit diff stats
path: root/prototypes/tile/10.mu
diff options
context:
space:
mode:
Diffstat (limited to 'prototypes/tile/10.mu')
-rw-r--r--prototypes/tile/10.mu28
1 files changed, 14 insertions, 14 deletions
diff --git a/prototypes/tile/10.mu b/prototypes/tile/10.mu
index a20e50ef..a9a4c85c 100644
--- a/prototypes/tile/10.mu
+++ b/prototypes/tile/10.mu
@@ -75,7 +75,7 @@ $main:loop: {
     render root-addr, cursor-addr
     loop
   }
-  clear-screen
+  clear-screen 0
   enable-keyboard-type-mode
   exit-status <- copy 0
 }
@@ -199,7 +199,7 @@ fn create-child node: (handle cell) {
 #######################################################
 
 fn render root: (addr cell), cursor: (addr cell) {
-  clear-screen
+  clear-screen 0
   var depth/eax: int <- tree-depth root
   var viewport-width/ecx: int <- copy 0x65  # col2
   viewport-width <- subtract 5  # col1
@@ -318,11 +318,11 @@ fn draw-hatching row1: int, col1: int, row2: int, col2: int {
 
 fn draw-horizontal-line row: int, col1: int, col2: int {
   var col/eax: int <- copy col1
-  move-cursor-on-screen row, col
+  move-cursor 0, row, col
   {
     compare col, col2
     break-if->=
-    print-string-to-screen "-"
+    print-string 0, "-"
     col <- increment
     loop
   }
@@ -333,8 +333,8 @@ fn draw-vertical-line row1: int, row2: int, col: int {
   {
     compare row, row2
     break-if->=
-    move-cursor-on-screen row, col
-    print-string-to-screen "|"
+    move-cursor 0, row, col
+    print-string 0, "|"
     row <- increment
     loop
   }
@@ -346,8 +346,8 @@ fn try-divide _nr: int, _dr: int -> result/eax: int {
   # x = next power-of-2 multiple of _dr after _nr
   var x/ecx: int <- copy 1
   {
-#?     print-int32-hex-to-screen x
-#?     print-string-to-screen "\n"
+#?     print-int32-hex 0, x
+#?     print-string 0, "\n"
     var tmp/edx: int <- copy _dr
     tmp <- multiply x
     compare tmp, _nr
@@ -355,7 +355,7 @@ fn try-divide _nr: int, _dr: int -> result/eax: int {
     x <- shift-left 1
     loop
   }
-#?   print-string-to-screen "--\n"
+#?   print-string 0, "--\n"
   # min, max = x/2, x
   var max/ecx: int <- copy x
   var min/edx: int <- copy max
@@ -363,8 +363,8 @@ fn try-divide _nr: int, _dr: int -> result/eax: int {
   # narrow down result between min and max
   var i/eax: int <- copy min
   {
-#?     print-int32-hex-to-screen i
-#?     print-string-to-screen "\n"
+#?     print-int32-hex 0, i
+#?     print-string 0, "\n"
     var foo/ebx: int <- copy _dr
     foo <- multiply i
     compare foo, _nr
@@ -374,9 +374,9 @@ fn try-divide _nr: int, _dr: int -> result/eax: int {
   }
   result <- copy i
   result <- decrement
-#?   print-string-to-screen "=> "
-#?   print-int32-hex-to-screen result
-#?   print-string-to-screen "\n"
+#?   print-string 0, "=> "
+#?   print-int32-hex 0, result
+#?   print-string 0, "\n"
 }
 
 fn test-try-divide-1 {
ss='alt'>
e842afe ^
f1d8278 ^
f5db520
e842afe ^



















f5db520

fbccc58 ^
f5db520

fbccc58 ^
f5db520

9b2db84 ^
f5db520
bada5c0 ^
f5db520

9b2db84 ^


fbccc58 ^
9b2db84 ^

fbccc58 ^
9b2db84 ^

fbccc58 ^
9b2db84 ^

f5db520


bada5c0 ^

f5db520

9b2db84 ^
d439df5 ^
f5db520


bada5c0 ^
f5db520

f1d8278 ^





c5da0d0 ^

f1d8278 ^

f5db520

bada5c0 ^
9b2db84 ^
f5db520



bada5c0 ^
f5db520



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
         
















                                                                                
      

                       


                                                                                







                                                                              
                                                                

                                                   
                                                
                                                       

                      
                                                            
                                            


          
                                     
 
 
 
          



















                                                                                                        

                                                               
                                                                                                                       

                                                             
                                                                                                                 

                         
                                                   
            
                                                                                              

                      


                                                     
                                 

                                                 
                                   

                                                      
                                  

                                                                                 


        

                                     

                                                 
                                                        
                                                                     


                                     
                                                                                                               

                                                                                                    





                                                                                                                                                    

                              

                  

                     
                                                    
                                                



                                      
                            



           
#!/bin/sh

################################################################################
# Copyright 2022 Charadon                                                      #
#                                                                              #
# Licensed under the Apache License, Version 2.0 (the "License");              #
# you may not use this file except in compliance with the License.             #
# You may obtain a copy of the License at                                      #
#                                                                              #
# http://www.apache.org/licenses/LICENSE-2.0                                   #
#                                                                              #
# Unless required by applicable law or agreed to in writing, software          #
# distributed under the License is distributed on an "AS IS" BASIS,            #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.     #
# See the License for the specific language governing permissions and          #
# limitations under the License.                                               #
################################################################################

set -e
cd "$(dirname "$0")"
. "$(pwd -P)/config.sh"

################################################################################

# Move script to background if DSCIP_DAEMON_FORK is set to true #
if [ "$DSCIP_DAEMON" = "true" ]; then
	if [ "$DSCIP_DAEMON_FORK" = "true" ] && [ ! "$FORKED" = "true" ]; then
		FORKED=true nohup "$0" "$@" > /dev/null 2>&1
		exit 0
	fi
fi

# Check if script is currently running, and if not, reset LOCK #
if [ -f "$WORKING_DIRECTORY/LOCK" ]; then
	LOCKED_PID=$(cat "$WORKING_DIRECTORY/LOCK")
	if ps -p "$LOCKED_PID" > /dev/null; then
		echo "Script still running. Exiting..."
		exit 0
	else
		echo "Script not running, resetting lock..."
		rm "$WORKING_DIRECTORY/LOCK"
	fi
fi

echo "$$" > "$WORKING_DIRECTORY/LOCK"



build () {
	# Print variables #
	{
		echo "################################################################################";
		date;
		echo "################################################################################";
		echo "DSCIP_GITREPO=$DSCIP_GITREPO";
		echo "DSCIP_GITMODE=$DSCIP_GITMODE";
		echo "DSCIP_BRANCH=$DSCIP_BRANCH";
		echo "WORKING_DIRECTORY=$WORKING_DIRECTORY";
		echo "DSCIP_PRE_CMD=$DSCIP_PRE_CMD";
		echo "DSCIP_BUILD_CMD=$DSCIP_BUILD_CMD";
		echo "DSCIP_POST_CMD=$DSCIP_POST_CMD";
		echo "DSCIP_DAEMON=$DSCIP_DAEMON";
		echo "DSCIP_DAEMON_FORK=$DSCIP_DAEMON_FORK";
		echo "DSCIP_SLEEP=$DSCIP_SLEEP";
		echo "DSCIP_DISREGARD_COMMIT_CHECK=$DSCIP_DISREGARD_COMMIT_CHECK";
		echo "DSCIP_OUTPUT_TO=$DSCIP_OUTPUT_TO"
	} >> "$DSCIP_OUTPUT_TO"

	# Grab remote sources #
	if [ "$DSCIP_GITMODE" = "clone" ]; then
		rm -rf "$WORKING_DIRECTORY/wrkdir" # Clean Up #
		git clone --depth 1 -b "$DSCIP_BRANCH" "$DSCIP_GITREPO" wrkdir >> "$DSCIP_OUTPUT_TO" 2>&1 # Clone git #
	elif [ "$DSCIP_GITMODE" = "pull" ]; then
		if [ ! -d "$WORKING_DIRECTORY/wrkdir" ]; then
			git clone --depth 1 -b "$DSCIP_BRANCH" "$DSCIP_GITREPO" wrkdir >> "$DSCIP_OUTPUT_TO" 2>&1
		fi
		cd wrkdir
		git pull >> "$DSCIP_OUTPUT_TO" 2>&1
	else
		echo "Invalid GITMODE, choose either 'clone' or 'pull'" 2>> "$DSCIP_OUTPUT_TO"
		exit 1
	fi
	{
		cd "$WORKING_DIRECTORY/wrkdir";
		echo "Running pre-build commands...";
		"$DSCIP_PRE_CMD";
		echo "Running build commands...";
		cd "$WORKING_DIRECTORY/wrkdir";
		"$DSCIP_BUILD_CMD";
		echo "Running post-build commands...";
		cd "$WORKING_DIRECTORY/wrkdir";
		"$DSCIP_POST_CMD";
	} >> "$DSCIP_OUTPUT_TO" 2>&1
	echo "$CURRENT_COMMIT" > "$WORKING_DIRECTORY/LAST_COMMIT" # Save commit #
}

run () {
	mkdir -p "$WORKING_DIRECTORY"
	cd "$WORKING_DIRECTORY"

	# Loads last commit hash if it exists. # 
	if [ -f "$WORKING_DIRECTORY/LAST_COMMIT" ]; then
		LAST_COMMIT="$(cat "$WORKING_DIRECTORY/LAST_COMMIT")"
	fi

	# Loads current commit hash #
	CURRENT_COMMIT=$(git ls-remote "$DSCIP_GITREPO" | awk "/refs\/(heads|tags)\/$DSCIP_BRANCH/{print \$1}")

	# If LAST_COMMIT doesn't exist, that means it's a first run and we can go ahead and build. #
	# Or skip the commit check if DSCIP_DISREGARD_COMMIT_CHECK is set to true.
	if [ "$DSCIP_DISREGARD_COMMIT_CHECK" = "false" ]; then
		if [ -z "$LAST_COMMIT" ]; then
			build
		elif [ ! "$LAST_COMMIT" = "$CURRENT_COMMIT" ]; then # If the last commit and current commit don't match, then we go ahead and build.
			build
		else
			return
		fi
	else
		build
	fi
	rm "$WORKING_DIRECTORY/LOCK" # Remove lock #
	printf "Done.\n\n" >> "$DSCIP_OUTPUT_TO"
}

run
while [ "$DSCIP_DAEMON" = "true" ]; do
	sleep "$DSCIP_SLEEP"
	run
done

exit 0