Browse code

Started implementing 2-bit mode in nasu

neauoire authored on 15/04/2021 05:06:22
Showing 6 changed files
... ...
@@ -32,7 +32,7 @@ else
32 32
 fi
33 33
 
34 34
 echo "Assembling.."
35
-./bin/assembler projects/examples/gui.picture.usm bin/boot.rom
35
+./bin/assembler projects/software/nasu.usm bin/boot.rom
36 36
 
37 37
 echo "Running.."
38 38
 if [ "${2}" = '--cli' ]; 
... ...
@@ -23,7 +23,7 @@
23 23
 	( load ) ,icn1_path =File.name #1800 =File.length ,image =File.load
24 24
 	( draw ) #0008 #0008 #0100 #00c0 #27 ,image ,draw-icn JSR2
25 25
 
26
-	( load ) ,icn2_path =File.name #1800 =File.length ,image =File.load
26
+	( load ) ,icn2_path =File.name #0800 =File.length ,image =File.load
27 27
 	( draw ) #0010 #0078 #0080 #0080 #27 ,image ,draw-icn JSR2
28 28
 
29 29
 	( load ) ,chr1_path =File.name #4000 =File.length ,image =File.load
... ...
@@ -71,7 +71,7 @@ RTN
71 71
 		( draw ) ~rect.x1 =Screen.x ~color DUP =Screen.color 
72 72
 		( draw ) ~rect.x2 =Screen.x =Screen.color
73 73
 		( incr ) SWP2 ++ SWP2
74
-		OVR2 OVR2 LTH2 ^$ver JNZ
74
+		OVR2 OVR2 LTS2 ^$ver JNZ
75 75
 	POP2 POP2
76 76
 	~rect.x1 ~rect.x2
77 77
 	$hor
... ...
@@ -79,7 +79,7 @@ RTN
79 79
 		( draw ) ~rect.y1 =Screen.y ~color DUP =Screen.color 
80 80
 		( draw ) ~rect.y2 =Screen.y =Screen.color
81 81
 		( incr ) SWP2 ++ SWP2
82
-		OVR2 OVR2 ++ LTH2 ^$hor JNZ
82
+		OVR2 OVR2 ++ LTS2 ^$hor JNZ
83 83
 	POP2 POP2
84 84
 
85 85
 RTN
... ...
@@ -95,10 +95,10 @@ RTN
95 95
 			( save ) OVR2 =Screen.x
96 96
 			( draw ) ~color =Screen.color
97 97
 			( incr ) SWP2 ++ SWP2
98
-			OVR2 OVR2 LTH2 ^$hor JNZ
98
+			OVR2 OVR2 LTS2 ^$hor JNZ
99 99
 		POP2 POP2 STH2r STH2r
100 100
 		( incr ) SWP2 ++ SWP2
101
-		OVR2 OVR2 LTH2 ^$ver JNZ
101
+		OVR2 OVR2 LTS2 ^$ver JNZ
102 102
 	POP2 POP2 POP2 POP2
103 103
 
104 104
 RTN
105 105
new file mode 100644
106 106
Binary files /dev/null and b/projects/pictures/zerotwo10x10.chr differ
... ...
@@ -8,7 +8,6 @@
8 8
 )
9 9
 
10 10
 %RTN   { JMP2r }
11
-%RTN?  { #00 EQU #02 JNZ STH2r JMP2 }
12 11
 %STEP8 { #0033 SFT2 }
13 12
 
14 13
 %++ { #0001 ADD2 }
... ...
@@ -16,10 +15,13 @@
16 15
 %8/ { #0003 SFT2 } %8* { #0030 SFT2 }
17 16
 %8- { #0008 SUB2 } %8+ { #0008 ADD2 }
18 17
 %SFL { #40 SFT SFT }
18
+%MOD { DUP2 DIV MUL SUB }
19
+
20
+%BANK { #2000 }
19 21
 
20 22
 ( variables )
21 23
 
22
-;bankview { x 2 y 2 mode 1 addr 2 }
24
+;bankview { x 2 y 2 mode 1 addr 2 depth 1 }
23 25
 ;tileview { x 2 y 2 addr 2 }
24 26
 ;rect { x1 2 y1 2 x2 2 y2 2 }
25 27
 ;mouse { x 2 y 2 }
... ...
@@ -42,21 +44,22 @@
42 44
 
43 45
 |0200
44 46
 
45
-	( theme ) #e0fc =System.r #30cc =System.g #30ac =System.b
47
+	( theme ) #0efc =System.r #03cc =System.g #03ac =System.b
46 48
 	( vectors ) ,on-button =Controller.vector
47 49
 	( vectors ) ,on-mouse =Mouse.vector
48 50
 	( vectors ) ,on-transfer =File.vector
49 51
 
50 52
 	~Screen.width 2/ #008a SUB2 =bankview.x 
51 53
 	~Screen.height 2/ #003f SUB2 =bankview.y 
52
-	,bank =bankview.addr
54
+	BANK =bankview.addr
53 55
 
54 56
 	~Screen.width 2/ #0002 ADD2 =tileview.x 
55 57
 	~Screen.height 2/ #003f SUB2 =tileview.y 
56
-	,bank #0448 ADD2 =tileview.addr
58
+	BANK #0448 ADD2 =tileview.addr
57 59
 
58
-	,filepath1 =File.name #0800 =File.length ,bank =File.load
59
-	,filepath2 =File.name #0800 =File.length ,bank #0800 ADD2 =File.load
60
+	,filepath1 =File.name #0800 =File.length BANK =File.load
61
+	,filepath2 =File.name #0800 =File.length BANK #0800 ADD2 =File.load
62
+	,filepath3 =File.name #1000 =File.length BANK #1000 ADD2 =File.load
60 63
 
61 64
 	,redraw JSR2
62 65
 
... ...
@@ -101,19 +104,18 @@ BRK
101 104
 			~Mouse.x ~bankview.x SUB2 8/ #000d LTH2 ^$no-brush-click JNZ
102 105
 			~Mouse.x ~bankview.x SUB2 8/ #000f GTH2 ^$no-brush-click JNZ
103 106
 				( select ) ~mouse.x ~bankview.x SUB2 8/ #000d SUB2 SWP POP =bankview.mode
104
-				( release ) #00 =Mouse.state
105
-				,redraw JSR2 ,$click-end JMP2
106 107
 			$no-brush-click
107 108
 			~Mouse.x ~tileview.x SUB2 8/ #000e NEQ2 ^$no-load-click JNZ
108 109
 				( load ) ,filepath1  =File.name #0800 =File.length ~bankview.addr =File.load
109
-				( release ) #00 =Mouse.state
110
-				,redraw JSR2 ,$click-end JMP2
111 110
 			$no-load-click
112 111
 			~Mouse.x ~tileview.x SUB2 8/ #000f NEQ2 ^$no-save-click JNZ
113 112
 				( save ) ,filepath1  =File.name #0800 =File.length ~bankview.addr =File.save
113
+			$no-save-click
114
+			~Mouse.x ~bankview.x SUB2 8/ #0005 NEQ2 ^$no-toggle-depth JNZ
115
+				( toggle ) ~bankview.depth #00 EQU =bankview.depth
116
+			$no-toggle-depth
114 117
 				( release ) #00 =Mouse.state
115 118
 				,redraw JSR2 ,$click-end JMP2
116
-			$no-save-click
117 119
 		$no-toolbar-click
118 120
 
119 121
 		( bankview )
... ...
@@ -253,8 +255,13 @@ RTN
253 255
 
254 256
 	( toolbar )
255 257
 
256
-	~bankview.x #0068 ADD2 =Screen.x
257 258
 	~bankview.y #0010 SUB2 =Screen.y
259
+
260
+	~bankview.x #0028 ADD2 =Screen.x
261
+	,depth_icn #00 ~bankview.depth 8* ADD2 =Screen.addr
262
+	#23 =Screen.color
263
+
264
+	~bankview.x #0068 ADD2 =Screen.x
258 265
 	,tool_selector =Screen.addr
259 266
 	#21 ~bankview.mode #00 EQU ADD =Screen.color
260 267
 
... ...
@@ -290,23 +297,21 @@ RTN
290 297
 
291 298
 	( body )
292 299
 
293
-	~bankview.x =Screen.x ~bankview.y =Screen.y
294
-	#00 =pt.x #00 =pt.y ~bankview.addr =Screen.addr
300
+	( load ) ~bankview.addr =Screen.addr
301
+	~bankview.y DUP2 #0080 ADD2
295 302
 	$ver
296
-		#00 =pt.x
297
-		~bankview.x =Screen.x
298
-		$hor
299
-			( draw ) #21
300
-				~Screen.addr ~tileview.addr LTH2 
301
-				~Screen.addr ~tileview.addr #0018 ADD2 GTH2 
302
-				#0000 EQU2 #06 MUL ADD =Screen.color
303
-			( incr ) ~Screen.x 8+ =Screen.x
304
-			( incr ) ~Screen.addr 8+ =Screen.addr
305
-			( incr ) ~pt.x #01 ADD =pt.x
306
-			~pt.x #10 LTH ,$hor JNZ2
307
-		( incr ) ~pt.y #01 ADD =pt.y
308
-		( incr ) ~Screen.y 8+ =Screen.y
309
-		~pt.y #10 LTH ,$ver JNZ2
303
+		( save ) OVR2 =Screen.y
304
+		~bankview.x DUP2 #0080 ADD2
305
+		$hor 
306
+			( save ) OVR2 =Screen.x
307
+			( draw ) #21 ~Screen.addr ~tileview.addr EQU2 #06 MUL ADD ~bankview.depth #2e MUL ADD =Screen.color
308
+			( incr ) SWP2 8+ SWP2
309
+			( incr ) ~Screen.addr 8+ #00 ~bankview.depth #0008 MUL2 ADD2 =Screen.addr
310
+			OVR2 OVR2 LTH2 ^$hor JNZ
311
+		POP2 POP2
312
+		( incr ) SWP2 8+ SWP2
313
+		OVR2 OVR2 LTH2 ^$ver JNZ
314
+	POP2 POP2
310 315
 
311 316
 RTN
312 317
 
... ...
@@ -431,11 +436,6 @@ RTN
431 436
 
432 437
 @draw-cursor
433 438
 
434
-	~mouse.x ~Mouse.x NEQ2
435
-	~mouse.y ~Mouse.y NEQ2
436
-
437
-	#0000 EQU2 RTN? ( Return if unchanged )
438
-
439 439
 	( clear last cursor )
440 440
 	~mouse.x =Screen.x
441 441
 	~mouse.y =Screen.y
... ...
@@ -450,7 +450,7 @@ RTN
450 450
 	~mouse.x =Screen.x
451 451
 	~mouse.y =Screen.y
452 452
 	,tool_selector #00 ~bankview.mode #08 MUL ADD2 =Screen.addr
453
-	#32 =Screen.color
453
+	#32 ~Mouse.state #00 NEQ ADD =Screen.color
454 454
 
455 455
 RTN
456 456
 
... ...
@@ -473,34 +473,46 @@ RTN
473 473
 
474 474
 ( Utils )
475 475
 
476
-@line-rect ( x1 y1 x2 y2 color )
476
+@line-rect ( x1 y1 x2 y2 color -- )
477 477
 
478
-	( load ) =color =rect.y2 =rect.x2 DUP2 =Screen.y =rect.y1 DUP2 =Screen.x =rect.x1
479
-	$hor
480
-		( incr ) ~Screen.x ++ =Screen.x
481
-		( draw ) ~rect.y1 =Screen.y ~color =Screen.color
482
-		( draw ) ~rect.y2 =Screen.y ~color =Screen.color
483
-		~Screen.x ~rect.x2 LTH2 ^$hor JNZ
484
-	~rect.y1 =Screen.y
478
+	( load ) =color DUP2 STH2 =rect.y2 =rect.x2 DUP2 STH2 =rect.y1 =rect.x1
479
+	STH2r STH2r
485 480
 	$ver
486
-		( draw ) ~rect.x1 =Screen.x ~color =Screen.color
487
-		( draw ) ~rect.x2 =Screen.x ~color =Screen.color
488
-		( incr ) ~Screen.y ++ =Screen.y
489
-		~Screen.y ~rect.y2 ++ LTH2 ^$ver JNZ
481
+		( save ) OVR2 =Screen.y
482
+		( draw ) ~rect.x1 =Screen.x ~color DUP =Screen.color 
483
+		( draw ) ~rect.x2 =Screen.x =Screen.color
484
+		( incr ) SWP2 ++ SWP2
485
+		OVR2 OVR2 LTS2 ^$ver JNZ
486
+	POP2 POP2
487
+	~rect.x1 ~rect.x2
488
+	$hor
489
+		( save ) OVR2 =Screen.x
490
+		( draw ) ~rect.y1 =Screen.y ~color DUP =Screen.color 
491
+		( draw ) ~rect.y2 =Screen.y =Screen.color
492
+		( incr ) SWP2 ++ SWP2
493
+		OVR2 OVR2 ++ LTS2 ^$hor JNZ
494
+	POP2 POP2
490 495
 
491 496
 RTN
492 497
 
493 498
 @tool_selector [ 80c0 e0f0 f8e0 1000 ]
494 499
 @tool_hand     [ 4040 4070 f8f8 f870 ]
495 500
 @tool_eraser   [ 2050 b87c 3e1c 0800 ]
496
-@blank_icn     [ 0000 0000 0000 0000 ]
497
-@cell1_icn     [ 7cfe fefe fefe 7c00 ]
501
+@blank_icn     [
502
+	0000 0000 0000 0000
503
+	7cfe fefe fefe 7c00
504
+]
505
+@depth_icn [
506
+	00fe 8282 fe82 82fe
507
+	00fe 9292 fe92 92fe
508
+]
498 509
 @load_icn      [ feaa d6aa d4aa f400 ]
499 510
 @save_icn      [ fe82 8282 848a f400 ]
500 511
 @moveup_icn    [ 0010 387c fe10 1000 ]
501 512
 @movedown_icn  [ 0010 1010 fe7c 3810 ]
502 513
 @filepath1     [ projects/fonts/specter8.bit 00 ]
503 514
 @filepath2     [ projects/pictures/cibo.bit 00 ]
515
+@filepath3     [ projects/pictures/zerotwo10x10.chr 00 ]
504 516
 
505 517
 @font_hex ( 0-F ) 
506 518
 [
... ...
@@ -513,5 +525,3 @@ RTN
513 525
 	007c 8280 8080 827c 00fc 8282 8282 82fc 
514 526
 	007c 8280 f080 827c 007c 8280 f080 8080
515 527
 ]
516
-
517
-|2000 @bank [ ]	
... ...
@@ -14,7 +14,6 @@
14 14
 )
15 15
 
16 16
 %RTN   { JMP2r }
17
-%RTN? { #00 EQU #02 JNZ STH2r JMP2 }
18 17
 %ABS2 { DUP2 #000f SFT2 EQU #04 JNZ #ffff MUL2 }
19 18
 %CLN2r { DUP2 STH2 }
20 19
 %STEP8 { #0033 SFT2 }
... ...
@@ -68,7 +67,6 @@
68 67
 	( vectors ) ,on-screen =Screen.vector
69 68
 	( vectors ) ,on-button =Controller.vector
70 69
 	( vectors ) ,on-mouse =Mouse.vector
71
-	( vectors ) ,on-transfer =File.vector
72 70
 
73 71
 	~theme.r0 =System.r ~theme.g0 =System.g ~theme.b0 =System.b
74 72
 
... ...
@@ -96,13 +94,6 @@
96 94
 
97 95
 BRK
98 96
 
99
-@on-transfer ( -> )
100
-	
101
-	,draw-canvas JSR2
102
-	( release ) #00 =Mouse.state
103
-
104
-BRK
105
-
106 97
 @on-screen ( -> )
107 98
 	
108 99
 	~document.edit #01 NEQ ^$no-edit JNZ
... ...
@@ -365,7 +356,6 @@ BRK
365 356
 	~Screen.height #0002 DIV2 ~canvas.h 8* 2/ SUB2 =canvas.y1
366 357
 
367 358
 	,fit-canvas JSR2
368
-
369 359
 	,draw-foreground JSR2
370 360
 
371 361
 RTN
... ...
@@ -412,19 +402,6 @@ RTN
412 402
 
413 403
 RTN
414 404
 
415
-@load-file ( path -- )
416
-
417
-	=File.name FILESIZE =File.length ,data =File.load
418
-	~File.name ,path.name ,strcpy JSR2
419
-
420
-RTN
421
-
422
-@save-file ( path -- )
423
-
424
-	=File.name FILESIZE =File.length ,data =File.save
425
-
426
-RTN
427
-
428 405
 @fit-canvas
429 406
 	
430 407
 	~canvas.w 8* ~canvas.x1 ADD2 =canvas.x2 
... ...
@@ -600,6 +577,22 @@ RTN
600 577
 
601 578
 RTN
602 579
 
580
+( file )
581
+
582
+@load-file ( path -- )
583
+
584
+	=File.name FILESIZE =File.length ,data =File.load
585
+	~File.name ,path.name ,strcpy JSR2
586
+	,draw-canvas JSR2
587
+
588
+RTN
589
+
590
+@save-file ( path -- )
591
+
592
+	=File.name FILESIZE =File.length ,data =File.save
593
+
594
+RTN
595
+
603 596
 ( Drawing )
604 597
 
605 598
 @redraw ( -- )
... ...
@@ -650,13 +643,6 @@ RTN
650 643
 
651 644
 @draw-cursor ( -- )
652 645
 
653
-	~cursor.x ~Mouse.x NEQ2
654
-	~cursor.y ~Mouse.y NEQ2
655
-	#0000 EQU2 
656
-	~Mouse.state 
657
-	#00 NEQ 
658
-	#0101 EQU2 RTN? ( Return if unchanged )
659
-
660 646
 	,blank_icn =Screen.addr
661 647
 	( clear brush size )
662 648
 	~cursor.x #0003 SUB2 =Screen.x ~cursor.y #0003 SUB2 =Screen.y #30 =Screen.color
... ...
@@ -819,18 +805,23 @@ RTN
819 805
 
820 806
 @line-rect ( x1 y1 x2 y2 color -- )
821 807
 
822
-	( load ) =color =rect.y2 =rect.x2 DUP2 =Screen.y =rect.y1 DUP2 =Screen.x =rect.x1
823
-	$hor
824
-		( incr ) ~Screen.x ++ =Screen.x
825
-		( draw ) ~rect.y1 =Screen.y ~color =Screen.color
826
-		( draw ) ~rect.y2 =Screen.y ~color =Screen.color
827
-		~Screen.x ~rect.x2 NEQ2 ^$hor JNZ
828
-	~rect.y1 =Screen.y
808
+	( load ) =color DUP2 STH2 =rect.y2 =rect.x2 DUP2 STH2 =rect.y1 =rect.x1
809
+	STH2r STH2r
829 810
 	$ver
830
-		( draw ) ~rect.x1 =Screen.x ~color =Screen.color
831
-		( draw ) ~rect.x2 =Screen.x ~color =Screen.color
832
-		( incr ) ~Screen.y ++ =Screen.y
833
-		~Screen.y ~rect.y2 ++ NEQ2 ^$ver JNZ
811
+		( save ) OVR2 =Screen.y
812
+		( draw ) ~rect.x1 =Screen.x ~color DUP =Screen.color 
813
+		( draw ) ~rect.x2 =Screen.x =Screen.color
814
+		( incr ) SWP2 ++ SWP2
815
+		OVR2 OVR2 LTS2 ^$ver JNZ
816
+	POP2 POP2
817
+	~rect.x1 ~rect.x2
818
+	$hor
819
+		( save ) OVR2 =Screen.x
820
+		( draw ) ~rect.y1 =Screen.y ~color DUP =Screen.color 
821
+		( draw ) ~rect.y2 =Screen.y =Screen.color
822
+		( incr ) SWP2 ++ SWP2
823
+		OVR2 OVR2 ++ LTS2 ^$hor JNZ
824
+	POP2 POP2
834 825
 
835 826
 RTN
836 827