Browse code

Cleaned up examples

neauoire authored on 11/02/2021 03:05:40
Showing 5 changed files
... ...
@@ -1,5 +1,8 @@
1 1
 ( blank )
2 2
 
3
+:dev/r fff8 ( std read port )
4
+:dev/w fff9 ( std write port )
5
+
3 6
 |0100 @RESET BRK
4 7
 |c000 @FRAME BRK 
5 8
 |d000 @ERROR BRK 
... ...
@@ -1,29 +1,25 @@
1
-( hello world )
1
+( hello world, to console )
2 2
 
3
-;iterator
3
+:dev/w fff9 ( const write port )
4
+;i 1 ( var iterator )
4 5
 
5 6
 |0100 @RESET
6 7
 
7
-@word1 "hello_world ( len: 0x0b )
8
+	,00 ,dev/w STR ( set dev/write to console ) 
8 9
 
9
-@loop
10
-	IOW ( write to device#0 )
11
-	,incr JSR ( increment itr )
12
-	,word1 ,strlen JSR ( get strlen )
13
-	NEQ ,loop ROT JSR? ( loop != strlen )
10
+	@word1 "hello_world ( len: 0x0b )
14 11
 
15
-BRK
12
+	@loop
13
+		IOW ( write to device#0 )
14
+		,incr JSR ( increment itr )
15
+		,i LDR ( a = i )
16
+		,word1 ,strlen JSR ( b = string length )
17
+		NEQ ,loop ROT JSR? ( a != b ? loop )
16 18
 
17
-@strlen
18
-	,0001 ADD^ LDR
19
-	RTS
19
+BRK
20 20
 
21
-@incr
22
-	,iterator LDR
23
-	,01 ADD
24
-	,iterator STR 
25
-	,iterator LDR
26
-	RTS
21
+@strlen ,0001 ADD^ LDR RTS
22
+@incr ,i LDR ,01 ADD ,i STR RTS
27 23
 
28 24
 |c000 @FRAME BRK 
29 25
 |d000 @ERROR BRK 
... ...
@@ -1,4 +1,4 @@
1
-( draw pixel )
1
+( draw a single pixel )
2 2
 
3 3
 :dev/w fff9 ( keep write port in a const )
4 4
 ;x 2
... ...
@@ -3,7 +3,7 @@
3 3
 :dev/r fff8 ( std read port )
4 4
 :dev/w fff9 ( std write port )
5 5
 
6
-;x 2 ;y 2 ;color 1 
6
+;x 2 ;y 2 ;color 1 ;alive 1
7 7
 
8 8
 |0100 @RESET 
9 9
 	
... ...
@@ -11,36 +11,34 @@
11 11
 	,01 ,color STR ( set color ) 	
12 12
 	,0020 ,x STR^ ( set x-pos )
13 13
 	,0030 ,y STR^ ( set y-pos )
14
+	,01 ,alive STR ( set alive = true )
14 15
 
15 16
 BRK
16 17
 
17 18
 |c000 @FRAME 
18 19
 
19
-	,colorize JSR
20
-	,move JSR
21
-	( draw )
20
+	,alive LDR ,00 EQU BRK?
22 21
 	,01 ,color LDR ,x LDR^ ,y LDR^ ,putpixel JSR
22
+	,move JSR
23 23
 
24 24
 BRK
25 25
 
26
-@colorize
27
-	,color LDR ,01 ADD ,color STR ( incr color )
28
-	,color LDR ,04 LTH RTS?
29
-	,01 ,color STR 
30
-	RTS
31
-
32 26
 @move
33 27
 	,x LDR^ ,0001 ADD^ ,x STR^ ( incr x )
34
-	,x LDR^ ,0060 LTH^ RTS?    ( if x > 60 )
28
+	,x LDR^ ,0040 LTH^ RTS?    ( if x > 60 )
35 29
 	,0020 ,x STR^              ( x = 0x0020 )
36 30
 	,y LDR^ ,0001 ADD^ ,y STR^ ( incr y )
31
+
32
+	,y LDR^ ,0050 LTH^ RTS?    ( y > 50 )
33
+	,00 ,alive STR             ( alive = 0 )
34
+
37 35
 	RTS
38 36
 
39 37
 @putpixel 
40 38
 	IOW^ ( y short )
41 39
 	IOW^ ( x short )
42
-	IOW ( color byte )
43
-	IOW ( redraw byte )
40
+	IOW  ( color byte )
41
+	IOW  ( redraw byte )
44 42
 	RTS
45 43
 
46 44
 |d000 @ERROR BRK 
... ...
@@ -1,11 +1,9 @@
1
-( my default test file )
1
+( my test file, junk )
2 2
 
3 3
 :dev/r fff8 ( std read port )
4 4
 :dev/w fff9 ( std write port )
5 5
 
6 6
 |0100 @RESET 
7
-	
8
-	,01 ,dev/w STR ( set dev/write screen#01 ) 
9 7
 
10 8
 BRK
11 9