-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbeta.asm
1160 lines (890 loc) · 19.5 KB
/
beta.asm
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
; Copyright (C) 2006 Remy Glaser
;
; This program is free software; you can redistribute it and/or
; modify it under the terms of the GNU General Public License
; as published by the Free Software Foundation; either version 2
; of the License, or (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
; LICENSE.html for more details.
;
.Nolist
#define equ .equ
#define EQU .equ
#define end .end
#define END .end
#IFDEF TI83P
#include "include/TI83P/ti83plus.inc"
#ELSE
#include "include/TI83/ti83asm.inc"
#ENDIF
#DEFINE use_file.open
#DEFINE use_file.skip
#DEFINE use_file.readByte
#define Square(aa,bb,cc,dd) ld bc,aa*256+bb \ ld de,cc*256+dd \ call SQUARE
; Beta XP text format tags:
;tag_ equ $00
tag_Return equ $D6 ; D6
;tag_ equ $ED
;tag_ equ $EE
;tag_ equ $EF
;tag_ equ $F0
;tag_ equ $F1
;tag_ equ $F2
;tag_ equ $F3
;tag_ equ $F4
;tag_ equ $F5
;tag_ equ $F6
tag_Author equ $F7 ; F7 [text] F7
tag_Title equ $F8 ; F8 [text] F8
tag_Square equ $F9 ; F9 [x1] [y1] [x2] [y2] [op]
tag_Line equ $FA ; FA [x1] [y1] [x2] [y2] [op]
tag_Picture equ $FB ; FB [x] [y] [width] [height] [pic] [length H] [length L]
tag_FreeText equ $FC ; FC [x] [y] [text] FC
tag_Invert equ $FD ; FD [text] FD
tag_Tab equ $FE ; FE
tag_Page_End equ $FF ; FF
; Flags:
SelectFlags EQU asm_flag1
;XWiskunde EQU 7
;XNatuurkunde EQU 6
;XScheikunde EQU 5
;XNoSubject EQU 4
xCalc EQU 3
xText EQU 2
; EQU 1
; EQU 0
Properties EQU asm_flag2
;XWiskunde EQU 7
;XNatuurkunde EQU 6
;XScheikunde EQU 5
;XNoSubject EQU 4
;xCalc EQU 3
;xText EQU 2
; EQU 1
; EQU 0
BetaFlags EQU asm_flag3
LftMenu EQU 0
MenuInDisplay EQU 1
; EQU 2
; EQU 3
; EQU 4
; EQU 5
; EQU 6
; EQU 7
; key equates:
key_down EQU $01
key_left EQU $02
key_right EQU $03
key_up EQU $04
key_enter EQU $09
key_clear EQU $0F
key_3 EQU $12
key_2 EQU $1A
key_1 EQU $22
key_4 EQU $23
key_comma EQU $25
key_log EQU $2C
key_graph EQU $31
key_trace EQU $32
key_zoom EQU $33
key_window EQU $34
key_Y EQU $35
key_quit EQU $37
; RAM area used by beta:
; System RAM (should never be cleared inside beta)
SAVESP EQU Statvars+00
; EQU Statvars+01
BetaName EQU Statvars+02
; EQU Statvars+03
; EQU Statvars+04
; EQU Statvars+05
; EQU Statvars+06
; EQU Statvars+07
; EQU Statvars+08
; EQU Statvars+09
; EQU Statvars+10
; misc RAM
CURRENT_ADRESS EQU Statvars+11
; EQU Statvars+12
UP_OR_DOWN EQU Statvars+13
; EQU Statvars+14
ASAVE EQU Statvars+15
; Navigation RAM
Cursor_Adress EQU Statvars+16
; EQU Statvars+17
Min_Adress EQU Statvars+18
; EQU Statvars+19
Max_Adress EQU Statvars+20
; EQU Statvars+21
; Navigation RAM Backup
Cursor_Adress2 EQU Statvars+22
; EQU Statvars+23
Min_Adress2 EQU Statvars+24
; EQU Statvars+25
Max_Adress2 EQU Statvars+26
; EQU Statvars+27
; Picture RAM
X EQU Statvars+28
Y EQU Statvars+29
Width EQU Statvars+30
Height EQU Statvars+31
PIC_CURRENT EQU Statvars+32
; EQU Statvars+33
PIC_MAX EQU Statvars+34
; EQU Statvars+35
; Square routine
sq_length EQU Statvars+36
sq_height EQU Statvars+37
point1bit EQU Statvars+38
point1 EQU Statvars+39
; EQU Statvars+40
point2bit EQU Statvars+41
point2 EQU Statvars+42
; EQU Statvars+43
operation EQU Statvars+44
; Menu RAM
LeftMenuCur EQU Statvars+45
RightMenuCur EQU Statvars+46
String_Length EQU Statvars+47
String_Adress EQU Statvars+48
; EQU Statvars+49
Author EQU Statvars+50
; EQU Statvars+51
String_temp EQU Statvars+52
Statvars_max EQU Statvars+531
; RAM equates
LftMenuCur EQU LeftMenuCur
RgtMenuCur EQU RightMenuCur
Description EQU String_Temp
.LIST
.org progstart
; Save Beta's program name
ld hl,Op1
ld de,BetaName
ld bc,9
ldir
; Clear Screen
bcall(_clrLCDFull)
; (re)set flags
#IFDEF TI83P
res 2,(iy+50) ; No large font on graph screen
set bufferonly,(iy+plotflag3) ; Draw to graph backup buffer only
#ENDIF
res statsvalid,(IY+statflags) ; Make sure Statvars RAM area isn't used
res plotLoc,(iy+plotflags)
set textwrite,(iy+sgrflags) ; Write text only in graph backup buffer
; Save SP register
ld (savesp),sp
; Get select flags
ld a,(FlagsSave)
;| or %00001100 ; make sure calcs and texts are selected
ld (iy+SelectFlags),a
ld hl,plotsscreen
ld de,savesscreen
ld bc,768
ldir ; copy graph screen to buffer
; Start Beta
BETASHELL:
#include "menu.asm"
_ChkFindPlug:
; _ChkfindPlugin checks the validity of a plugin which name is in op1
; Input:
; Op1=name of plugin to check
; Output:
; carry flag set if invalid plugin
; carry flag reset if valid plugin
; (iy+Properties)=Plugin flags
call file.open
jp c,CS_INVALID
xor a
ld (op1+9),a ; Sometimes, _chkfindsym loads 5 or 6 into op1+9
call CHK_INCCURSOR
cp $D9 ; STOP
jr z,CS_TEXTPLUGIN
cp $3F ; \n
jr z,CS_CALCPLUGIN
jp INVALID2
CS_TEXTPLUGIN:
call CHK_INCCURSOR
cp $3F ; \n
jr nz,CS_INVALID
call CHK_INCCURSOR
or %00000100 ; Make sure text flag is set
ld (iy+properties),a
rcf
ret
CS_CALCPLUGIN:
call CHK_INCCURSOR
cp $2A
jp nz,INVALID2
call CHK_INCCURSOR
ld hl,1
cp $29 ; space
jr z,CS_SKIP_ONE
cp $3F
jr z,CS_SKIP_NONE
CS_SKIP_TWO:
inc hl
CS_SKIP_ONE:
call file.skip
call file.readByte
cp $3F
jp nz,INVALID2
CS_SKIP_NONE:
set xCalc,(iy+Properties) ; Make sure calc flag is set
rcf
ret
;| call CHK_INCCURSOR
;| cp $2A ; "
;| jp nz,INVALID2
;| call CHK_INCCURSOR
;| cp $29 ; space
;| jr z,CS_NO_OK
;| cp 'W'
;| jr z,CS_WI
;| cp 'N'
;| jr z,CS_NA
;| cp 'S'
;| jr z,CS_SK
;| jp INVALID2
;|CS_WI:
;| call CHK_INCCURSOR
;| cp 'I'
;| ld a,%10001000
;| jr z,CS_OK
;| jp INVALID2
;|CS_NA:
;| call CHK_INCCURSOR
;| cp 'A'
;| ld a,%01001000
;| jr z,CS_OK
;| jp INVALID2
;|CS_SK:
;| call CHK_INCCURSOR
;| cp 'K'
;| ld a,%00101000
;| jr z,CS_OK
;| jp INVALID2
;|CS_NO_OK: ; no subject
;| ld a,%00011000
;|CS_OK:
;| ld (iy+Properties),a
CS_INVALID:
SCF:
scf ; set carry flag
ret
_ChkFindPlugin:
; _ChkfindPlugin checks the validity of a plugin which name is in op1
; and returns its flags and adress
; Input:
; Op1=name of plugin to detect
; Output:
; a: Plugin flags
; carry flag set if invalid plugin
; carry flag reset if valid plugin
; (iy+Properties)=Plugin flags
; (Current_adress)=pointer to plugin start in RAM
; Description=Program Description
; (Author)=Author
call file.open
jp c,INVALID2
xor a
ld (op1+9),a ; Sometimes, _chkfindsym loads 5 or 6 into op1+9
call CHK_INCCURSOR
cp $D9 ; Stop
jr z,TEXTPLUGIN
cp $3F ; \n
jp z,CALCPLUGIN
jp INVALID2
TEXTPLUGIN:
call CHK_INCCURSOR
cp $3F ; \n
jp nz,INVALID2
call CHK_INCCURSOR
or %00000100 ; Make sure text flag is set, we don't really care for any actual settings in this byte, but it may be used again in the future
ld (iy+Properties),a
; Search for Description
xor a
ld (String_length),a
ld hl,String_temp
ld (String_adress),hl
call file.readByte
jr c,TXT_TITLE_LOOP_END
cp tag_title
jr nz,TXT_TITLE_LOOP_END
TXT_TITLE_LOOP:
call file.readByte
jr c,TXT_TITLE_LOOP_END
cp tag_title
jr z,TXT_TITLE_LOOP_END
push af
ld l,a
ld h,8
bcall(_htimesl)
bcall(_sFont_Len) ; calculate length
ld a,(String_length)
add a,b ; new string length
add a,255-92 ; Description max=92 pixels
jr c,TXT_TITLE_TOO_LONG
sub 255-92
ld (String_length),a
pop af
ld hl,(String_adress)
ld (hl),a
inc hl
ld (String_adress),hl
jr TXT_TITLE_LOOP
TXT_TITLE_TOO_LONG:
pop af ; cleans the stack a is not used here (we already known the length is too long)
TXT_TITLE_TOO_LONG_LOOP:
call file.readByte
jr c,TXT_TITLE_LOOP_END ; EOF
cp tag_title
jr nz,TXT_TITLE_TOO_LONG_LOOP ; loop until the tag end is found (or an EOF encountered). The last part of the description is ignored.
TXT_TITLE_LOOP_END:
ld hl,(String_adress)
ld (hl),0 ; it's now a zero-terminated string
inc hl
ld (String_adress),hl
ld (Author),hl
TXT_AUTHOR:
; Search for Author
xor a
ld (String_length),a
call file.readByte
jr c,TXT_AUTHOR_LOOP_END
cp tag_author
jr nz,TXT_AUTHOR_LOOP_END
TXT_AUTHOR_LOOP:
call file.readByte
jr c,TXT_AUTHOR_LOOP_END
cp tag_author
jr z,TXT_AUTHOR_LOOP_END
push af
ld l,a
ld h,8
bcall(_htimesl)
bcall(_sFont_Len) ; calculate length
ld a,(String_length)
add a,b ; new string length
add a,255-54 ; Description max=54 pixels
jr c,TXT_AUTHOR_TOO_LONG
sub 255-54
ld (String_length),a
pop af
ld hl,(String_adress)
ld (hl),a
inc hl
ld (String_adress),hl
jr TXT_AUTHOR_LOOP
TXT_AUTHOR_TOO_LONG:
pop af ; cleans the stack a is not used here (we already known the length is too long)
TXT_AUTHOR_TOO_LONG_LOOP:
call file.readByte
jr c,TXT_AUTHOR_LOOP_END ; EOF
cp tag_author
jr nz,TXT_AUTHOR_TOO_LONG_LOOP ; loop until the tag end is found (or an EOF encountered). The last part of the description is ignored.
TXT_AUTHOR_LOOP_END:
ld hl,(String_adress)
ld (hl),0 ; it's now a zero-terminated string
rcf
ret
CALCPLUGIN:
call CHK_INCCURSOR
cp $2A
jp nz,INVALID2
call CHK_INCCURSOR
cp $29 ; space
jr z,SKIP_ONE
cp $3F
jr z,SKIP_NONE
SKIP_TWO:
call CHK_INCCURSOR
SKIP_ONE:
call CHK_INCCURSOR
SKIP_NONE:
cp $3F
jp nz,INVALID2
set xCalc,(iy+Properties) ; Make sure calc flag is set
;| call CHK_INCCURSOR
;| cp $2A ; "
;| jp nz,INVALID2
;|
;| call CHK_INCCURSOR
;| cp $29 ; space
;| jr z,SU_NO_OK
;| cp 'W'
;| jr z,SU_WI
;| cp 'N'
;| jr z,SU_NA
;| cp 'S'
;| jr z,SU_SK
;| jp INVALID2
;|SU_WI:
;| call CHK_INCCURSOR
;| cp 'I'
;| ld a,%10001000
;| jr z,OKOK
;| jp INVALID2
;|SU_NA:
;| call CHK_INCCURSOR
;| cp 'A'
;| ld a,%01001000
;| jr z,OKOK
;| jp INVALID2
;|SU_SK:
;| call CHK_INCCURSOR
;| cp 'K'
;| ld a,%00101000
;| jr z,OKOK
;| jp INVALID2
;|SU_NO_OK: ; no subject
;| ld a,%00011000
;|OKOK:
; Search for Description
xor a
ld (String_length),a
ld hl,String_temp
ld (String_adress),hl
call file.readByte
jr c,CLC_TITLE_LOOP_END
cp $2A
jr nz,CLC_TITLE_LOOP_END
CLC_TITLE_LOOP:
call file.readByte
jr c,CLC_TITLE_LOOP_END
cp $3F
jr z,CLC_TITLE_LOOP_END
push af
ld l,a
ld h,8
bcall(_htimesl)
bcall(_sFont_Len) ; calculate length
ld a,(String_length)
add a,b ; new string length
add a,255-92 ; Description max=92 pixels
pop hl ; af pops out as hl because it causes a return error if title too long (don't pop as af because carry flag will change)
jr c,CLC_TITLE_TOO_LONG
push hl
sub 255-92
ld (String_length),a
pop af
ld hl,(String_adress)
ld (hl),a
inc hl
ld (String_adress),hl
jr CLC_TITLE_LOOP
CLC_TITLE_TOO_LONG:
call file.readByte
jr c,CLC_TITLE_LOOP_END
cp $3F
jr z,CLC_TITLE_LOOP_END
jr CLC_TITLE_TOO_LONG
CLC_TITLE_LOOP_END:
ld hl,(String_adress)
ld (hl),0 ; it's now a zero-terminated string
inc hl
ld (String_adress),hl
ld (Author),hl
CLC_AUTHOR:
; Search for Author
xor a
ld (String_length),a
call file.readByte
jr c,CLC_AUTHOR_LOOP_END
cp $2A
jr nz,CLC_AUTHOR_LOOP_END
CLC_AUTHOR_LOOP:
call file.readByte
jr c,CLC_AUTHOR_LOOP_END
cp $3F
jr z,CLC_AUTHOR_LOOP_END
push af
ld l,a
ld h,8
bcall(_htimesl)
bcall(_sFont_Len) ; calculate length
ld a,(String_length)
add a,b ; new string length
add a,255-54 ; Description max=54 pixels
jr c,CLC_AUTHOR_TOO_LONG
sub 255-54
ld (String_length),a
pop af
ld hl,(String_adress)
ld (hl),a
inc hl
ld (String_adress),hl
jr CLC_AUTHOR_LOOP
CLC_AUTHOR_TOO_LONG:
call file.readByte
jr c,CLC_AUTHOR_LOOP_END
cp $3F
jr z,CLC_AUTHOR_LOOP_END
jr CLC_AUTHOR_TOO_LONG
CLC_AUTHOR_LOOP_END:
ld hl,(String_adress)
ld (hl),0 ; it's now a zero-terminated string
rcf
ret
INVALID2:
xor a
ld (iy+Properties),a
scf ; set carry flag
pop hl
ret
CHK_INCCURSOR:
call file.readByte
jr c,INVALID2
ret
_FindBetaUp:
; _FindBetaUp finds alphabetically the next valid beta plugin
; Input:
; Op1: previous program name
; Output:
; OP1: name of next plugin
; a: Plugin flags
; carry flag set if this was the last plugin
; carry flag reset this was not the last plugin
; (iy+Properties)=Plugin flags
; (Current_adress)=pointer to plugin start in RAM
ld hl,Cursor_adress
ld de,Cursor_adress2
ld bc,6
ldir
bcall(_op1toop5)
FindBetaUp:
bcall(_op1toop6)
bcall(_findalphaup)
ld hl,FindBetaUp ; Needs to be saved in case of invalid plugins
ld (up_or_down),hl
jr FINDBeta
_FindBetaDown:
; _FindBetaDown finds alphabetically the previous valid beta plugin
; Input:
; Op1: current program name
; Output:
; OP1: name of previous plugin
; carry flag set if this was the first plugin
; carry flag reset this was not the first plugin
bcall(_op1toop5)
ld hl,Cursor_adress
ld de,Cursor_adress2
ld bc,6
ldir
FindBetaDown:
bcall(_Op1toop6)
bcall(_findalphadn)
ld hl,FindBetaDown ; Needs to be saved in case of invalid plugins
ld (up_or_down),hl
FINDBeta:
exx
ex af,af'
bcall(_op6toop2)
call cpop1op2
jr nz,NO_BUG
FindBeta_Invalid:
bcall(_op5toop1) ; restore original name
ld hl,Cursor_adress2 ; restore original flags & adresses
ld de,Cursor_adress
ld bc,6
ldir
scf
ret
NO_BUG:
exx
ex af,af'
call _chkfindplug
jr c,INVALID
ld a,(iy+selectflags) ; This code checks if this plug is what we asked for
xor %11111111
ld b,a
ld a,(iy+Properties)
and b
jr nz,INVALID
inc hl ; hl is at the actual beginning of the plugin
ld (current_adress),hl
rcf
ret
INVALID:
ld hl,(up_or_down) ; _FindBetaup or _FindBetadown
push hl
ret ; jump to _FindBetaup or _FindBetadown
OPEN_PLUGIN:
bcall(_op5toop1) ; op5= first plugin in the list
call _chkfindplugin ; Gets plugin settings
bit XText,(iy+Properties)
jr nz,SIMPLE_SCROLL ; goto scroll engine for text plugins
bit XCalc,(iy+Properties)
jr nz,CALC_PLUG ; goto basic engine for programs
;;
;; ; Start calculator
;;
CALC_PLUG:
bcall(_op1toop2)
call SAVE_SELECT_FLAGS
bcall(_op2toop1)
res textwrite,(iy+sgrflags) ; Write text only in graph backup buffer
#IFDEF TI83P
res bufferonly,(iy+plotflag3) ; Draw to graph backup buffer only
#ENDIF
res oninterrupt,(iy+onflags)
ld sp,(savesp)
bcall(_grbufclr)
ld hl,0
ld (currow),hl
ld a,$20
bcall(_putmap)
bcall(_clrscrnfull)
bcall(_clrtxtshd)
; bcall(_JforceCmdnochar) ; This is the cause of the Beta NT memory bug
set ProgExecuting,(iy+newDispf)
bcall(_ParseInp)
res progExecuting,(iy+newDispf)
ret
#include "scroll.asm"
;BETAKEY:
; bcall(_runindicoff)
;#IFDEF TI83P
; bcall(_op1toop3) ; prevents MirageOS bug
;#ENDIF
; bcall(_getkey)
;#IFDEF TI83P
; bcall(_op3toop1) ; prevents MirageOS bug
;#ENDIF
;
; bit oninterrupt,(iy+onflags) ; On key
; jr nz,EXIT
;
; cp key_clear
; jr z,EXIT
; cp key_quit
; jr z,EXIT
; ld b,%10001100 ; Wiskunde
; cp key_Y
; jr z,SHORTCUT
; ld b,%01001100 ; Natuurkunde
; cp Key_window
; jr z,SHORTCUT
; ld b,%00101100 ; Scheikunde
; cp Key_zoom
; jr z,SHORTCUT
; ld b,%00011100 ; Overigen
; cp Key_Trace
; jr z,SHORTCUT
; ld b,%11111100 ; Alles
; cp Key_graph
; jr z,SHORTCUT
; ret
;
;SHORTCUT:
; ld a,b
; ld (iy+SelectFlags),a
; bit MenuInDisplay,(iy+BetaFlags)
; jr z,BETASHELL
; jr UPDATE_MENU
BETAKEY:
bcall(_runindicoff)
GETKEY_LOOP:
bcall(_GetCSC)
and a
jr z,GETKEY_LOOP
bit oninterrupt,(iy+onflags) ; On key
jp nz,EXIT
cp key_clear
jp z,EXIT
cp key_quit
jp z,EXIT
; ld b,%10001100 ; Wiskunde
; cp key_Y
; jr z,SHORTCUT
; ld b,%01001100 ; Natuurkunde
; cp Key_window
; jr z,SHORTCUT
; ld b,%00101100 ; Scheikunde
; cp Key_zoom
; jr z,SHORTCUT
; ld b,%00011100 ; Overigen
; cp Key_Trace
; jr z,SHORTCUT
; ld b,%11111100 ; Alles
; cp Key_graph
; jr z,SHORTCUT
ret
;SHORTCUT:
; ld a,b
; ld (iy+SelectFlags),a
; bit MenuInDisplay,(iy+BetaFlags)
; jp z,BETASHELL
; jp UPDATE_MENU
CPOP1OP2:
; Compares the program names in op1 and op2, the _cpop1op2 routine compares them as floating point
; Input:
; op1: program name to compare
; op2: program name to compare
; Output:
; zero flag set if op1=op2
; zero flag reset if op1!=op2
; Destroys:
; Registers hl, de, b, a, c
ld hl,op1+1
ld de,op2+1
ld b,8
CPOP1OP2_LOOP:
ld a,(de)
ld c,(hl)
cp c
ret nz
inc hl
inc de
djnz CPOP1OP2_LOOP
ret
SQUARE:
; Puts a rectangle in the graph backup buffer or a straight line
; Input:
; b: x coordinate of upper left corner
; c: y coordinate of upper left corner
; d: x coordinate of lower right corner
; e: y coordinate of lower right corner
; h: 0 - pixel off operation
; 1 - pixel on operation
; 2+ - pixel change operation (xor)
; @require b<96 && c<64 && d<96 && e<64 && b<=d && c<=e
; to draw a line, make sure b=d or c=e
; to draw a point, make sure b=d and c=e
ld a,h
cp 2
jr nz,SQUARE_PIXELCHANGE1
LineOn
SQUARE_PIXELCHANGE1:
; b=b
; c=c
; d=d
; e=c
push de
ld e,c
bcall(_iline)
pop de
; b=b
; c=e
; d=d
; e=e
push bc
ld c,e
bcall(_iline)
pop bc