-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunit.z80
1137 lines (809 loc) · 19.3 KB
/
unit.z80
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
org 32768
; jp go
call test_f24 ; 1: 46E900
call wat
call addtoVec2_test ; 2: 400000 410000
call wat
call subfromVec2_test ; 3: C00000 400000
call wat
call sumVec2_test ; 4: 42E000 40C000
call wat
call diffVec2_test ; 5: C1C000 C12000
call wat
call minusVec2_test ; 6: C10000 C00000
call wat
call scaleVec2_test ; 7: C00000 BF0000
call wat
call scaledVec2_test ; 8: C00000 BF0000
call wat
call Transpose_test ; 9: 400000 410000 / C00000 BF0000
call wat
call initMat22_test ; A: 3EBB67 BDFFFD / 3DFFFD 3EBB67
call wat
call matmul_test ; B: 410000 42E000
call wat
call matmulMM_test ; C: 410000 C30000 / 420000 41A000
call wat
call Dot_test ; D: 441000
call wat
call Crossvv_test ; E: C24000
call wat
call Absv_test ; F: 410000 400000
call wat
call AbsM_test ; 10: 400000 400000 / 410000 3E0000
call wat
call Flip_test ; 11: 03 04 01 02
call wat
call ComputeIncidentEdge_test ; 12: 449000 800000 xxxx0401 / C49000 800000 xxxx0102
call wat
go: call ClipSegmentToLine_test ; 13: 02 / 449000 000000 00 00 04 01/ BDFF80 000000 00 02 01 00
call wat
call ClipSegmentToLine_test2 ; 14: 02 / BE0000 000000 00 02 01 00/ 3E0000 000000 04 00 00 01
call wat
call Collide_test ; 15: 02 / BDFF80 B847A0 / 000000 BF0000 00 02 01 00
call wat; 3E0000 B847A0 / 000000 BF0000 04 00 00 01
ret
; insertArbiter_test
IA_ArbiterKey:
dw 12000,48000
IA_Arbiter:
ds 106,9
insertArbiter_test:
ld de,insertArbiter_key
ld hl,IA_ArbiterKey
ld bc,4
ldir
ld de,insertArbiter_value
ld hl,IA_Arbiter
ld bc,106
ldir
call insertArbiter
ld a,(g_numArbiters)
call writeByte
ld de,findArbiter_key
ld hl,IA_ArbiterKey
ld bc,4
ldir
call findArbiter
push hl
ld a,h
call writeByte
pop hl
ld a,l
call writeByte
ld ix,findArbiter_key
ld (ix+0),12
ld (ix+1),23
ld (ix+2),44
ld (ix+3),98
call findArbiter ; should be 0
push hl
ld a,h
call writeByte
pop hl
ld a,l
call writeByte
ld de,eraseArbiter_key
ld hl,IA_ArbiterKey
ld bc,4
ldir
call eraseArbiter
ld a,(g_numArbiters)
call writeByte
ret
; ----------------------------------------------
; ComputeIncidentEdge_test
; ----------------------------------------------
CIE_h:
db $44,$90,$00, $42,$40,$00 ; 50 10
CIE_pos:
db 0,0,0, $C2,$40,$00; 0 -10
CIE_Rot:
db $3F,0,0, 0,0,0 ; 1 0
db 0,0,0, $3F,0,0 ; 0 1
CIE_normal
db 0,0,0, $BF,0,0 ; 0 -1
CIE_c:
ds 20; ClipVertex*2
ComputeIncidentEdge_test:
ld ix,CIE_c
ld hl,CIE_h
ld de,ComputeIncidentEdge_h
ld bc,Vec2
ldir
ld hl,CIE_pos
ld de,ComputeIncidentEdge_pos
ld bc,Vec2
ldir
ld hl,CIE_Rot
ld de,ComputeIncidentEdge_Rot
ld bc,Mat22
ldir
ld hl,CIE_normal
ld de,ComputeIncidentEdge_normal
ld bc,Vec2
ldir
call ComputeIncidentEdge
ld ix,CIE_c ; c[0].v
call writeVec2
ld a,(CIE_c+ClipVertex_fp); c[0].fp
call writeByte
ld a,(CIE_c+ClipVertex_fp+1)
call writeByte
ld a,(CIE_c+ClipVertex_fp+2)
call writeByte
ld a,(CIE_c+ClipVertex_fp+3)
call writeByte
ld ix,CIE_c+ClipVertex ; c[1].v
call writeVec2
ld a,(CIE_c+ClipVertex+ClipVertex_fp); c[1].fp
call writeByte
ld a,(CIE_c+ClipVertex+ClipVertex_fp+1)
call writeByte
ld a,(CIE_c+ClipVertex+ClipVertex_fp+2)
call writeByte
ld a,(CIE_c+ClipVertex+ClipVertex_fp+3)
call writeByte
ret
; ---------------------------------------------------------
; ClipSegmentToLine_test
; ---------------------------------------------------------
CSTL_vIn:
db $44,$90,0, 0,0,0 ; v=50 0
db 0,0,4,1 ; fp
db $c4,$90,0, 0,0,0 ; v=-50 0
db 0,0,1,2 ; fp
CSTL_normal:
db $BF,0,0, 0,0,0; -1 0
CSTL_offset
db $3E,0,0 ; 0.5
CSTL_clipEdge
db 2
CSTL_vOut:
ds 20; ClipVertex*2
ClipSegmentToLine_test:
ld ix,CSTL_vOut
ld iy,CSTL_vIn
ld hl,CSTL_normal
ld de,ClipSegmentToLine_normal
ld bc,Vec2
ldir
ld hl,CSTL_offset
ld de,ClipSegmentToLine_offset
ld bc,3
ldir
ld a,(CSTL_clipEdge)
ld (ClipSegmentToLine_clipEdge),a
CSTL1: call ClipSegmentToLine
call writeByte
ld ix,CSTL_vOut ; vOut[0].v
call writeVec2
ld a,(CSTL_vOut+ClipVertex_fp); vOut[0].fp
call writeByte
ld a,(CSTL_vOut+ClipVertex_fp+1)
call writeByte
ld a,(CSTL_vOut+ClipVertex_fp+2)
call writeByte
ld a,(CSTL_vOut+ClipVertex_fp+3)
call writeByte
ld ix,CSTL_vOut+ClipVertex ; vOut[1].v
call writeVec2
ld a,(CSTL_vOut+ClipVertex+ClipVertex_fp); vOut[1].fp
call writeByte
ld a,(CSTL_vOut+ClipVertex+ClipVertex_fp+1)
call writeByte
ld a,(CSTL_vOut+ClipVertex+ClipVertex_fp+2)
call writeByte
ld a,(CSTL_vOut+ClipVertex+ClipVertex_fp+3)
call writeByte
ret
; ---------------------------------------------------------
; ClipSegmentToLine_test2
; ---------------------------------------------------------
CSTL_vIn2:
db $44,$90,0, 0,0,0 ; v=50 0
db 0,0,4,1 ; fp
db $be,$00,0, 0,0,0 ; v=-0.5 0
db 0,2,1,0 ; fp
CSTL_normal2:
db $3F,0,0, 0,0,0; 1 0
CSTL_offset2
db $3E,0,0 ; 0.5
CSTL_clipEdge2
db 4
ClipSegmentToLine_test2:
ld ix,CSTL_vOut
ld iy,CSTL_vIn2
ld hl,CSTL_normal2
ld de,ClipSegmentToLine_normal
ld bc,Vec2
ldir
ld hl,CSTL_offset2
ld de,ClipSegmentToLine_offset
ld bc,3
ldir
ld a,(CSTL_clipEdge2)
ld (ClipSegmentToLine_clipEdge),a
jp CSTL1
ret
; --------------------------------------------------------
; Collide_test
; --------------------------------------------------------
contacts: ds 49*2 ; Contact*2
bodyA: db 0,0,0, $3D,$F5,$C3, 0,0,0 ; position, rotation = (0 0.49) 0
db 0,0,0, 0,0,0, 0,0,0 ; vel, angvel = (0 0) 0
db 0,0,0, 0,0,0, 0,0,0 ; force torque = (0 0) 0
db $3F,0,0, $3F,0,0 ; width = 1 1
; friction mass invmass I invI = 0.2 200 5e-3 33.3 0.03
db $3C,$99,$9A ;0.2
db $46,$90,$00 ;200
db $37,$47,$AE ;5e-3
db $44,$0A,$66 ;33.3
db $39,$EB,$85 ;0.03
bodyB:
db 0,0,0, $C2,$40,$00, 0,0,0 ; position, rotation = (0 -10) 0
db 0,0,0, 0,0,0, 0,0,0 ; vel, angvel = (0 0) 0
db 0,0,0, 0,0,0, 0,0,0 ; force torque = (0 0) 0
db $45,$90,$00, $43,$40,$00 ; width = 100 20
; friction mass invmass I invI = 0.2 inf 0 inf 0
db $3C,$99,$9A ;0.2
db $7F,0,0 ; inf
db 0,0,0
db $7F,0,0 ; inf
db 0,0,0
Collide_test:
ld hl,contacts
ld ix,bodyA
ld iy,bodyB
call Collide
call writeByte ; numContacts
ld ix,contacts
call writeVec2 ; contacts[0].position
ld ix,contacts+Contact_normal
call writeVec2 ; contacts[0].normal
ld a,(contacts+Contact_feature) ; contacts[0].feature
call writeByte
ld a,(contacts+Contact_feature+1)
call writeByte
ld a,(contacts+Contact_feature+2)
call writeByte
ld a,(contacts+Contact_feature+3)
call writeByte
ld ix,contacts+Contact
call writeVec2 ; contacts[1].position
ld ix,contacts+Contact+Contact_normal
call writeVec2 ; contacts[1].normal
ld a,(contacts+Contact+Contact_feature) ; contacts[1].feature
call writeByte
ld a,(contacts+Contact+Contact_feature+1)
call writeByte
ld a,(contacts+Contact+Contact_feature+2)
call writeByte
ld a,(contacts+Contact+Contact_feature+3)
call writeByte
ret
; ----------------------------------------------------------------
; Basic test of f24 lib
; (12*53-147)*0.5= 244.5
; print answer to screen using writeAHL
; ----------------------------------------------------------------
reslt: ds 3 ; string to store the result
test_f24:
ld a,12
call u8tof24 ; result on AHL
push af
push hl
ld a,53
call u8tof24 ; result on AHL
pop de
pop bc; b=a. need c=a
ld c,b
call f24mul ; AHL * CDE
push af
push hl
ld a,147
call u8tof24; AHL
ld c,a
ld d,h
ld e,l
pop hl
pop af
call f24sub
ld c,00111110b ; 0 0111110 0000000000000000 (0.5)
ld d,0
ld e,0
call f24mul
call writeAHL
ret
; ----------------------------------------------------------------
; Test addtoVec2. Pass in vector1 and vector2, sum is in vector1
; result should be (2.0, 4.0) which is shown as
; 40 00 00 41 00 00
; ----------------------------------------------------------------
vector1: db 00111111b, 0, 0, 01000000b, 0, 0 ; (1.0, 2.0)
vector2: db 00111111b, 0, 0, 01000000b, 0, 0 ; (1.0, 2.0)
addtoVec2_test:
ld ix,vector1
ld hl,vector2
ld de,addtoVec2_other
ld bc,6
ldir
call addtoVec2 ; result in vec1
ld a,(ix+0) ; x
ld h,(ix+1)
ld l,(ix+2)
call writeAHL
ld a,(ix+3) ; y
ld h,(ix+4)
ld l,(ix+5)
call writeAHL
ret
; ----------------------------------------------------------------
; test subfromVec2
; ----------------------------------------------------------------
subfromVec2_test:
ld ix,vector2
ld (ix+0),41h; 4.0
ld (ix+1),0
ld (ix+2),0
ld (ix+3),40h; 2.0
ld (ix+4),0
ld (ix+5),0
ld ix,vector1
ld (ix+0),40h; 2.0
ld (ix+1),0
ld (ix+2),0
ld (ix+3),41h; 4.0
ld (ix+4),0
ld (ix+5),0
ld hl,vector2
ld de,subfromVec2_other
ld bc,6
ldir
call subfromVec2 ; result in vec1: (2,4)-(4,2) = (-2,2)
ld a,(ix+0) ; x=-2
ld h,(ix+1)
ld l,(ix+2)
call writeAHL
ld a,(ix+3) ; y=2
ld h,(ix+4)
ld l,(ix+5)
call writeAHL
ret
; ----------------------------------------------------------------
; minusVec2_test
; ----------------------------------------------------------------
minusVec2_test:
ld ix,minusVec2_v
ld (ix+0),41h; 4.0
ld (ix+1),0
ld (ix+2),0
ld (ix+3),40h; 2.0
ld (ix+4),0
ld (ix+5),0
call minusVec2
ld ix,minusVec2_res
call writeVec2
ret
; ----------------------------------------------------------------
; scaledVec2_test
; ----------------------------------------------------------------
scaledVec2_test:
ld ix,scaledVec2_v
ld (ix+0),41h; 4.0
ld (ix+1),0
ld (ix+2),0
ld (ix+3),40h; 2.0
ld (ix+4),0
ld (ix+5),0
ld ix,scaledVec2_s
ld (ix+0),$BE ; -0.5
ld (ix+1),0
ld (ix+2),0
call scaledVec2
ld ix,scaledVec2_res
call writeVec2
ret
; ----------------------------------------------------------------
; scaleVec2_test
; ----------------------------------------------------------------
scaleVec2_test:
ld ix,scaleVec2_a
ld (ix+0),$BE ; -0.5
ld (ix+1),0
ld (ix+2),0
ld ix,vector1
ld (ix+0),41h; 4.0
ld (ix+1),0
ld (ix+2),0
ld (ix+3),40h; 2.0
ld (ix+4),0
ld (ix+5),0
call scaleVec2
call writeVec2
ret
; ----------------------------------------------------------------
; sumVec2_test
; ----------------------------------------------------------------
sumVec2_test:
ld ix,sumVec2_a
ld (ix+0),41h; 4.0
ld (ix+1),0
ld (ix+2),0
ld (ix+3),$BE; -0.5
ld (ix+4),0
ld (ix+5),0
ld ix,sumVec2_b
ld (ix+0),$42; 11.0
ld (ix+1),$60
ld (ix+2),0
ld (ix+3),41h; 4.0
ld (ix+4),0
ld (ix+5),0
call sumVec2
ld ix,sumVec2_res
call writeVec2
ret
; ----------------------------------------------------------------
; diffVec2_test
; ----------------------------------------------------------------
diffVec2_test:
ld ix,diffVec2_a
ld (ix+0),41h; 4.0
ld (ix+1),0
ld (ix+2),0
ld (ix+3),$BE; -0.5
ld (ix+4),0
ld (ix+5),0
ld ix,diffVec2_b
ld (ix+0),$42; 11.0
ld (ix+1),$60
ld (ix+2),0
ld (ix+3),41h; 4.0
ld (ix+4),0
ld (ix+5),0
call diffVec2
ld ix,diffVec2_res
call writeVec2
ret
; ----------------------------------------------------------------
; test Transpose
; 2 -2 -> 2 4
; 4 -1 -2 -1
; ----------------------------------------------------------------
Transpose_test:
ld ix,Transpose_mat
ld (ix+0),40h ; 2.0
ld (ix+1),0
ld (ix+2),0
ld (ix+3),41h ; 4.0
ld (ix+4),0
ld (ix+5),0
ld (ix+Mat22_col2+0),0xC0 ; -2.0
ld (ix+Mat22_col2+1),0
ld (ix+Mat22_col2+2),0
ld (ix+Mat22_col2+3),0xBF ; -1.0
ld (ix+Mat22_col2+4),0
ld (ix+Mat22_col2+5),0
call Transpose
ld ix,Transpose_res
call writeMat22
ret
; ----------------------------------------------------------------
; test initMat22
; angle = pi/6 = 30 deg
; sqrt(3)/2 -1/2
; 1/2 sqrt(3)/2
; ----------------------------------------------------------------
mat: ds 12
initMat22_test:
ld ix,initMat22_angle
ld (ix+0),$3E; pi/6
ld (ix+1),$0C
ld (ix+2),$15
ld hl,mat
call initMat22
ld ix,mat
call writeMat22
ret
; ----------------------------------------------------------------
; test matmul
; 2 -2 * 4 = 4
; 4 -0.5 2 15
; ----------------------------------------------------------------
matmul_test:
ld ix,matmul_A
ld (ix+0),40h ; 2.0
ld (ix+1),0
ld (ix+2),0
ld (ix+3),41h ; 4.0
ld (ix+4),0
ld (ix+5),0
ld (ix+Mat22_col2+0),0xC0 ; -2.0
ld (ix+Mat22_col2+1),0
ld (ix+Mat22_col2+2),0
ld (ix+Mat22_col2+3),0xBE ; -0.5
ld (ix+Mat22_col2+4),0
ld (ix+Mat22_col2+5),0
ld ix,matmul_v
ld (ix+0),41h; 4.0
ld (ix+1),0
ld (ix+2),0
ld (ix+3),40h; 2.0
ld (ix+4),0
ld (ix+5),0
call matmul
ld ix,matmul_res
call writeVec2
ret
; ----------------------------------------------------------------
; matmulMM_test
; 2 -2 * 2 3 = 4 -16
; 4 -0.5 0 11 8 6.5
; ----------------------------------------------------------------
matmulMM_test:
ld ix,matmulMM_A
ld (ix+0),$40 ; 2.0
ld (ix+1),0
ld (ix+2),0
ld (ix+3),$41 ; 4.0
ld (ix+4),0
ld (ix+5),0
ld (ix+Mat22_col2+0),$C0 ; -2.0
ld (ix+Mat22_col2+1),0
ld (ix+Mat22_col2+2),0
ld (ix+Mat22_col2+3),$BE ; -0.5
ld (ix+Mat22_col2+4),0
ld (ix+Mat22_col2+5),0
ld ix,matmulMM_B
ld (ix+0),$40 ; 2.0
ld (ix+1),0
ld (ix+2),0
ld (ix+3),0 ; 0.0
ld (ix+4),0
ld (ix+5),0
ld (ix+Mat22_col2+0),$40 ; 3.0
ld (ix+Mat22_col2+1),$80
ld (ix+Mat22_col2+2),0
ld (ix+Mat22_col2+3),$42 ; 11
ld (ix+Mat22_col2+4),$60
ld (ix+Mat22_col2+5),0
call matmulMM
ld ix,matmulMM_res
call writeMat22
ret
; ----------------------------------------------------------------
; Dot_test
; (4,2).(3,11) = 12+22 = 34
; ----------------------------------------------------------------
Dot_test:
ld ix,Dot_a
ld (ix+0),41h; 4.0
ld (ix+1),0
ld (ix+2),0
ld (ix+3),40h; 2.0
ld (ix+4),0
ld (ix+5),0
ld ix,Dot_b
ld (ix+0),$40; 3.0
ld (ix+1),$80
ld (ix+2),0
ld (ix+3),$42; 11
ld (ix+4),$60
ld (ix+5),0
call Dot
ld ix,Dot_res
ld a,(ix+0)
ld h,(ix+1)
ld l,(ix+2)
call writeAHL
ret
; ----------------------------------------------------------------
; Crossvv_test
; (4,2)x(11,3) = 12-22 = -10
; ----------------------------------------------------------------
Crossvv_test:
ld ix,Crossvv_a
ld (ix+0),41h; 4.0
ld (ix+1),0
ld (ix+2),0
ld (ix+3),40h; 2.0
ld (ix+4),0
ld (ix+5),0
ld ix,Crossvv_b
ld (ix+0),$42; 11
ld (ix+1),$60
ld (ix+2),0
ld (ix+3),$40; 3.0
ld (ix+4),$80
ld (ix+5),0
call Crossvv
ld ix,Crossvv_res
ld a,(ix+0)
ld h,(ix+1)
ld l,(ix+2)
call writeAHL
ret
; ----------------------------------------------------------------
; Absv_test
; ----------------------------------------------------------------
Absv_test:
ld ix,Absv_a
ld (ix+0),41h; 4.0
ld (ix+1),0
ld (ix+2),0
ld (ix+3),$C0; -2.0
ld (ix+4),0
ld (ix+5),0
call Absv
ld ix,Absv_res
call writeVec2
ret
; ----------------------------------------------------------------
; AbsM_test
; ----------------------------------------------------------------
AbsM_test:
ld ix,AbsM_A
ld (ix+0),$40 ; 2.0
ld (ix+1),0
ld (ix+2),0
ld (ix+3),$41 ; 4.0
ld (ix+4),0
ld (ix+5),0
ld (ix+Mat22_col2+0),$C0 ; -2.0
ld (ix+Mat22_col2+1),0
ld (ix+Mat22_col2+2),0
ld (ix+Mat22_col2+3),$BE ; -0.5
ld (ix+Mat22_col2+4),0
ld (ix+Mat22_col2+5),0
call AbsM
ld ix,AbsM_res
call writeMat22
ret
; ----------------------------------------------------------------
; Flip_test
; {1, 2, 3, 4} -> {3, 4, 1, 2}
; ----------------------------------------------------------------
edges1: db 1,2,3,4
Flip_test:
ld ix,edges1
call Flip
ld hl,0
ld (writeAHL_pp),hl
ld a,(edges1)
call writeByte
ld a,(edges1+1)
call writeByte
ld a,(edges1+2)
call writeByte
ld a,(edges1+3)
call writeByte
ret
; ----------------------------------------------------------
; wat pause until S key pressed
; ----------------------------------------------------------
wat_cnt: db 0
wat:
ld a,(wat_cnt)
inc a
ld (wat_cnt),a
ld hl,reslt
call u8toh
ld ix,reslt ; string to print
ld hl,32*23 ; print pos from top-left
ld a,00111010b ; ink 2, paper 7, not bright, not flash
ld b,2 ; no. chars to print
call me
wat1:
ld a,253 ; wait until S is pressed
in a,(254)
bit 1,a
jr nz,wat1
call cl
ld hl,0
ld (writeAHL_pp),hl
ret
; ----------------------------------------------------------------
; writeVec2. Write vec at ix on the next line down
; ----------------------------------------------------------------