-
Notifications
You must be signed in to change notification settings - Fork 9
/
geoWrite-0.s
6040 lines (5442 loc) · 177 KB
/
geoWrite-0.s
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
; ----------------------------------------------------------------------------
; geoWrite V2.1 (C64)
; 00 - MAIN: library code, core text editing
; ----------------------------------------------------------------------------
; reverse-engineered by Michael Steil, www.pagetable.com
; ----------------------------------------------------------------------------
.include "sym.inc"
.include "geosmac.inc"
.include "const.inc"
.include "zeropage.inc"
.include "geoWrite-0.inc"
.include "geoWrite-2.inc"
.include "geoWrite-3.inc"
.include "geoWrite-4.inc"
.include "geoWrite-5.inc"
.include "geoWrite-6.inc"
.include "geoWrite-7.inc"
; ----------------------------------------------------------------------------
.segment "CODE0": absolute
jmp appInit
; ----------------------------------------------------------------------------
jmp MEM_OVERLAY ; $0403 [XXX unused?]
;---------------------------------------------------------------
; 8x5 bitmaps "1"-"8", used by the ruler
;---------------------------------------------------------------
bitmap_1:
.byte $80 + 5
.byte %00100000 ; "1"
.byte %01100000
.byte %00100000
.byte %00100000
.byte %01110001
bitmap_2:
.byte $80 + 5
.byte %00110000 ; "2"
.byte %01001000
.byte %00010000
.byte %00100000
.byte %01111001
bitmap_3:
.byte $80 + 5
.byte %01110000 ; "3"
.byte %00001000
.byte %00110000
.byte %00001000
.byte %01110001
bitmap_4:
.byte $80 + 5
.byte %00010000 ; "4"
.byte %00110000
.byte %01010000
.byte %01111000
.byte %00010001
bitmap_5:
.byte $80 + 5
.byte %01111000 ; "5"
.byte %01000000
.byte %01110000
.byte %00001000
.byte %01110001
bitmap_6:
.byte $80 + 5
.byte %00110000 ; "6"
.byte %01000000
.byte %01110000
.byte %01001000
.byte %00110001
bitmap_7:
.byte $80 + 5
.byte %01111000 ; "7"
.byte %00001000
.byte %00010000
.byte %00100000
.byte %00100001
bitmap_8:
.byte $80 + 5
.byte %01111000 ; "8"
.byte %01001000
.byte %01111000
.byte %01001000
.byte %01111000
;---------------------------------------------------------------
; clearMarginbar
;
; Function: Clear the margin bar, which is the 320x5 pixel
; area below the ruler that contains the M, P
; and tab stop symbols.
;---------------------------------------------------------------
clearMarginbar:
jsr i_BitmapUp
.addr graph_marginbar
.byte 0 ; x
.byte 24 ; y
.byte 40 ; width
.byte 5 ; height
rts4: rts
;---------------------------------------------------------------
; updateRulerUI
;
; Function: Draw the ruler, the margin bar and the
; justification/spacing UI according to the current
; state.
;---------------------------------------------------------------
updateRulerUI:
ldx #0
lda sideFlippingOffset
cmp tmpSideFlippingOffset
beq :+
dex
: sta tmpSideFlippingOffset
ldy #.sizeof(ruler)-1
@loop: lda rulerData1,y
eor tmpRulerData,y
cpy #ruler::justification
bne :+
and #MASK_JST_SPACING+MASK_JST_JUST
: cmp #0
beq :+
dex ; difference -> update UI later
: lda rulerData1,y
sta tmpRulerData,y
dey
bpl @loop
txa
bpl rts4 ; nothing to update
jsr drawInchMarks
jsr clearMarginbar
jsr drawMarginbar
jsr updatePageIndicator
jsr i_GraphicsString ; clear all justification checkboxes
.byte NEWPATTERN
.byte 0
.byte MOVEPENTO
.word $1A
.byte $1E
.byte RECTANGLETO
.word $1C
.byte $20
.byte MOVEPENTO
.word $41
.byte $1E
.byte RECTANGLETO
.word $43
.byte $20
.byte MOVEPENTO
.word $60
.byte $1E
.byte RECTANGLETO
.word $62
.byte $20
.byte MOVEPENTO
.word $7C
.byte $1E
.byte RECTANGLETO
.word $7E
.byte $20
.byte MOVEPENTO
.word $10F
.byte $1E
.byte RECTANGLETO
.word $111
.byte $20
.byte MOVEPENTO
.word $124
.byte $1E
.byte RECTANGLETO
.word $126
.byte $20
.byte MOVEPENTO
.word $135
.byte $1E
.byte RECTANGLETO
.word $137
.byte $20
.byte NEWPATTERN ; fill next one
.byte 1
.byte NULL
lda rulerData1+ruler::justification
and #MASK_JST_JUST
jsr @draw
lda rulerData1+ruler::justification
and #MASK_JST_SPACING
lsr a
lsr a
add #4
@draw: tax
lda jst_checkbox_x_hi,x
sta @left+1
sta @right+1
lda jst_checkbox_x_lo,x
sta @left
add #2
sta @right
jsr i_Rectangle
.byte 30 ; top
.byte 32 ; bottom
@left: .word 0 ; left
@right: .word 0 ; right
rts
; x offsets of checkboxes below ruler:
; left center right full 1 1.5 2
.define jst_checkbox_x 26, 65, 96, 124, 271, 292, 309
jst_checkbox_x_lo: .lobytes jst_checkbox_x
jst_checkbox_x_hi: .hibytes jst_checkbox_x
jst_checkbox_x_count = * - jst_checkbox_x_hi
;---------------------------------------------------------------
; drawInchMarks
;
; Function: Draw the numbers in the ruler indicating the inch
; position.
;---------------------------------------------------------------
drawInchMarks:
ldx #0 ; offset 0
ldy sideFlippingOffset
beq @1
ldx #2 ; offset 2
dey
beq @1
ldx #4 ; offset 4
@1: ldy pageWidth1+1
dey
bne @2
inx
@2: stx r14L
lda #8
sta @xpos
lda #4
sta r14H ; 4 numbers
@3: ldx r14L
lda inchmark_ptrs,x
sta @bitmap
jsr i_BitmapUp
@bitmap: .word bitmap_2
@xpos: .byte 8 ; x
.byte 17 ; y
.byte 1 ; width
.byte 5 ; height
lda @xpos
add #10
sta @xpos ; + 10 cards
inc r14L
dec r14H
bne @3
rts
inchmark_ptrs:
.byte <bitmap_1, <bitmap_2, <bitmap_3, <bitmap_4, <bitmap_5, <bitmap_6, <bitmap_7, <bitmap_8
.assert >bitmap_1 = >bitmap_8, error
;---------------------------------------------------------------
; drawMarginbar
;
; Function: Draw the P, M and tab stop symbols into the margin
; bar.
;---------------------------------------------------------------
drawMarginbar:
ldy #0
@loop: lda rulerData1+ruler::left_margin,y
sta r11L
lda rulerData1+ruler::left_margin+1,y
and #$7F
sta r11H
iny
iny
cpy #ruler::paragraph_margin+4
beq @rts
jsr screenXFromPageX
bcs @loop ; is left of screen, ignore
lda r11L
and #7
beq :+
IncW r11
: ldx #rulerM-rulerIcons ; "M"
cpy #ruler::tabs+2
bcc @3 ; left/right margin
lda rulerData1-2,y
cmp rulerData1+ruler::right_margin
bne @1
lda rulerData1-1,y
cmp rulerData1+ruler::right_margin+1
beq @loop ; ignore
@1: ldx #rulerTab-rulerIcons
lda rulerData1-1,y
bpl @2
ldx #rulerDTab-rulerIcons
@2: cpy #ruler::paragraph_margin+2
bcc @3
ldx #rulerP-rulerIcons
@3: tya
pha
jsr drawMarginBarItem1
pla
tay
jmp @loop
@rts: rts
;---------------------------------------------------------------
; updatePageIndicator
;
; Function: Update the page location indicator sprite position.
;
; Pass: a5 vertical position on page
;---------------------------------------------------------------
updatePageIndicator:
LoadB r3L, 6 ; page indicator sprite
LoadW r4, 192 ; x coordinate
ldy sideFlippingOffset
beq @2 ; at the very left
lda #5
ldx pageWidth1+1
dex
beq @1
lda #4 ; add 4 pixels
dey
beq @1
lda #8 ; add 8 pixels
@1: ldx #r4
jsr addWIToZp ; add to r4
@2: MoveW pagePosY, r0
jsr @divHeight ; [XXX]
txa ; [XXX]
add #0 ; [XXX]
sta r5L
jsr PosSprite
jmp EnablSprite
@divHeight:
ldx #r0
ldy #usablePageHeightDiv13
jsr Ddiv
ldx r0L
rts
;---------------------------------------------------------------
; drawMarginBarItem1
;
; Function: Draw one of the M, P, Tab, DTab icons into the
; margin bar.
;
; Pass: x index of icon * 10
;
; Notes: * graphics data is 16x5 pixels
; * if the MSB of the first byte is inverted, the
; graphics data is ANDed, otherwise ORed
;---------------------------------------------------------------
drawMarginBarItem1:
txa
add #<rulerIcons
sta r0L
lda #0
adc #>rulerIcons
sta r0H
;---------------------------------------------------------------
; drawMarginBarItem2
;
; Function: Draw one of the M, P, Tab, DTab icons into the
; margin bar.
;
; Pass: r0 pointer to icon
;---------------------------------------------------------------
drawMarginBarItem2:
lda #8
ldx #r11
jsr subWBI ; r11 -= 8
ldy #0
lda (r0),y ; first byte has flag in MSB
sta r2L
ldx #24 ; first line of margin bar
@loop: jsr GetScanLine ; r5 = scanline ptr + r11
AddW r11, r5
ldy #0
CmpWI r11, -8
beq @3 ; clip on the left
lda (r0),y ; get first byte of row
bit r2L
bmi @1 ; negative: clear pixels, positive: set pixels
ora (r5),y ; set pixels
bra @2
@1: and (r5),y ; clear pixels
@2: sta (r5),y
@3: AddVW 8, r5 ; next 8 pixels
jsr incWr0 ; next input byte
CmpWI r11, SC_PIX_WIDTH-8
beq @6 ; clip on the right
lda (r0),y ; get second byte of row
bit r2L
bmi @4 ; negative: clear pixels, positive: set pixels
ora (r5),y ; set pixels
bra @5
@4: and (r5),y ; clear pixels
@5: sta (r5),y
@6: jsr incWr0
inx
cpx #24+5 ; 5 lines
bmi @loop
ldx #r11
lda #8
jmp addWIToZp
; ----------------------------------------------------------------------------
L065D: jsr removeRedundantRulersAndCardsets ; 065D 20 9C 06 ..
jsr resetToPageStart ; 0660 20 B1 26 .&
L0663: jsr measureLine ; 0663 20 7A 10 z.
bcs L067A ; 0666 B0 12 ..
CmpW pageTextHeight, pagePosY
bcs L067A ; 0672 B0 06 ..
jsr L27BC ; 0674 20 BC 27 .'
bra L0663 ; 0678 50 E9 P.
L067A: MoveW pageTextHeight, pagePosY
MoveW cursor3+cursor::font, tmpFont3 ; 0688 85 C5 ..
lda cursor3+cursor::mode ; 068A A5 A7 ..
sta tmpMode3 ; 068C 85 C7 ..
MoveW r15, topScrTxtPtr
jsr copyRuler1To2 ; 0696 20 8E 28 .(
jmp L15CA ; 0699 4C CA 15 L..
;---------------------------------------------------------------
; removeRedundantRulersAndCardsets
;
; Function: Interpret page until the end, removing all ruler
; and cardset escapes that were identical to the
; previous one.
;
; Pass: r15 start pointer
;---------------------------------------------------------------
removeRedundantRulersAndCardsets:
jsr LoadR15_MEM_PAGE
ldy #0
sty r6L ; start with illegal font
sty r6H
dey ; and illegal ruler
sty rulerData1+ruler::left_margin
@again: jsr cmpPageEndPtr2R15 ; beyond end, then done
bcc rts7
beq rts7
ldy #0
lda (r15),y
cmp #ESC_GRAPHICS
beq @graph ; then skip 5
cmp #ESC_RULER
beq @ruler
cmp #NEWCARDSET
bne @char
jsr copyCardsetToRegsCmp ; compare cardset to r6: font, r7L: mode
cpx #0
bmi @1 ; cardset was different, skip 4
LoadB r8L, 4
jsr deleteRange ; delete redundant cardset from page
bra @again
@graph: jsr incWR15 ; skip 5
@1: jsr addWI3R15 ; skip 4
@char: jsr incWR15 ; skip 1
bcc @again
@ruler: jsr copyToRuler1Cmp
txa
bmi @2
LoadB r8L, .sizeof(ruler)+1
jsr deleteRange
bra @again
@2: jsr addRulerSizeToR15
bcc @again ; always
copyCardsetToRegsCmp:
ldy #3
ldx #0
@loop: lda (r15),y
cmp r6L-1,y
beq @skip
dex
@skip: sta r6L-1,y
dey
bne @loop
rts7: rts
; ----------------------------------------------------------------------------
_mouseScrollUpDown:
bit zp_DBb ; 0704 24 DB $.
bmi rts7 ; 0706 30 FB 0.
jmp J2_mouseScrollUpDown ; 0708 4C 5C 32 L\2
; ----------------------------------------------------------------------------
copyToRuler1Cmp:
ldy #.sizeof(ruler)
ldx #0
@loop: lda (r15),y
cpy #ruler::justification+1
bne @1
and #$0F
@1: cmp rulerData1-1,y
beq @2
dex
@2: sta rulerData1-1,y
dey
bne @loop
rts
;---------------------------------------------------------------
; deleteRange
;
; Function: Deletes a range of bytes on the page and updates
; the cursor/selection pointers to be consistent.
;
; Pass: r15 start of the range
; r8L length
;---------------------------------------------------------------
deleteRange:
lda r15L ; tmpRangeStart = r15
sta tmpRangeStart ; tmpRangeEnd = r15 + r8L
add r8L
sta tmpRangeEnd
lda r15H
sta tmpRangeStart+1
adc #0
sta tmpRangeEnd+1
PushW_r15 ; delete range
jsr deleteTextAndPicturesinRange
PopW_r15
jsr cmpR15Cursor0Ptr ; if r15 < selection start
bcs @skip
lda cursor0+cursor::ptr ; then selection start -= r8L
sub r8L
sta cursor0+cursor::ptr
bcs @skip
dec cursor0+cursor::ptr+1
@skip: jsr CmpR15Cursor1Ptr ; if r15 < selection end?
bcs @rts
lda cursor1+cursor::ptr ; then selection end -= r8L
sub r8L
sta cursor1+cursor::ptr
bcs @rts
dec cursor1+cursor::ptr+1
@rts: rts
; ----------------------------------------------------------------------------
editor:
lda #$FF ; 075F A9 FF ..
sta zp_DDb ; 0761 85 DD ..
LoadW_ pagePosY, 0 ; 0767 85 77 .w
sta nextPageOpen ; 0769 85 DE ..
sta sideFlippingOffset ; 076B 8D BC 2F ../
sta zp_D9b ; 076E 85 D9 ..
jsr loadCursor0PtrPageCardset ; 0770 20 76 27 v'
jsr copyCursor0To1 ; 0773 20 C0 28 .(
jsr L065D ; 0776 20 5D 06 ].
jsr J2_analyzeSelectionFont ; 0779 20 65 32 e2
ldx #0 ; 077C A2 00 ..
jsr getLineRuler ; 077E 20 C9 1D ..
L0781: sec ; 0781 38 8
L0782: lda #$FF ; 0782 A9 FF ..
sta cursor0+cursor::srcline ; 0784 85 84 ..
sta cursor1+cursor::srcline ; 0786 85 8E ..
bcc L0796 ; 0788 90 0C ..
jsr pushRulerData ; 078A 20 73 26 s&
jsr L0862 ; 078D 20 62 08 b.
jsr popRulerData ; 0790 20 93 26 .&
jmp setPromptFontMetricsUpdateRulerUI ; 0793 4C 7A 1D Lz.
L0796: jsr L0862 ; 0796 20 62 08 b.
jmp setPromptFontMetricsUpdateRulerUI ; 0799 4C 7A 1D Lz.
; ----------------------------------------------------------------------------
L079C: clc ; 079C 18 .
bcc L0782 ; 079D 90 E3 ..
;---------------------------------------------------------------
; measurePage
;
; Function: Iterate over all characters until the end of the
; page and collect metrics information.
;---------------------------------------------------------------
measurePage:
lda curPage
cmp #PAGE_HEADER
bcc @1
MoveW pageEndPtr2, pageEndPtr1
rts
@1: jsr resetToPageStart
@loop: MoveW r15, zp_ADw
DecW zp_ADw ; zp_ADw = page start - 1
MoveW curFont, tmpFont1
MoveB currentMode, tmpMode1
MoveB justification, tmpJustification1
jsr measureLine ; <---------------!
php
jsr moveCursor3Ptr_r15
jsr addLineHeightToPageHeight
CmpW pageTextHeight, usablePageHeight
bcc @2
; line does not fit on page
plp
MoveW zp_ADw, pageEndPtr1
MoveW tmpFont1, curFont
MoveB tmpMode1, currentMode
lda tmpJustification1
and #$FF-JST_20-JST_10
sta r4L
lda tmpJustification1
and #JST_20
lsr a
ora r4L
sta rulerData1+ruler::justification
jmp loadFontMetrics
@2: plp ; page end?
bcc @loop ; no, continue
lda justification
sta rulerData1+ruler::justification
MoveW cursor3+cursor::ptr, pageEndPtr1
lda curPage
cmp #PAGE_LAST_USABLE
bne @rts
ldy #0
lda (pageEndPtr2),y
beq @rts ; last page && does not end on NULL?
MoveW pageEndPtr1, pageEndPtr2
tya
sta (pageEndPtr2),y
sta nextPageOpen
jsr _showTooManyPages ; then show error
@rts: rts
; ----------------------------------------------------------------------------
L083C: jsr copyCursor1To3 ; 083C 20 B7 28 .(
jsr moveCursor1Ptr_r15 ; 083F 20 AA 27 .'
lda cursor1+cursor::srcline ; 0842 A5 8E ..
sta r3L ; 0844 85 08 ..
jsr L08CD ; 0846 20 CD 08 ..
jsr copyCursor3To1 ; 0849 20 C9 28 .(
jsr copyCursor0ToY ; 084C 20 BD 28 .(
jsr moveCursor0Ptr_r15 ; 084F 20 A1 27 .'
lda cursor0+cursor::srcline ; 0852 A5 84 ..
sta r3L ; 0854 85 08 ..
jsr L08CD ; 0856 20 CD 08 ..
jmp copyCursor3To0 ; 0859 4C CC 28 L.(
;---------------------------------------------------------------
; clearSelection
;
; Function: Clears the current selection if there is one.
;---------------------------------------------------------------
clearSelection:
jsr invertSelectionIfNeeded
jmp copyCursor0To1
; ----------------------------------------------------------------------------
L0862: jsr L083C ; 0862 20 3C 08 <.
jsr cmpCursor0_1Ptr ; 0865 20 E8 27 .'
beq rts3 ; 0868 F0 03 ..
jsr invertSelection ; 086A 20 73 08 s.
rts3: rts ; 086D 60 `
;---------------------------------------------------------------
; invertSelectionIfNeeded
;
; Function: Inverts the current selection if there is one.
;---------------------------------------------------------------
invertSelectionIfNeeded:
jsr cmpCursor0_1Ptr
beq rts3
;---------------------------------------------------------------
; invertSelection
;
; Function: Inverts the current.
;---------------------------------------------------------------
invertSelection:
ldx #cursor0-userzp ; copy range (cursor0:cursor1) to cursor3:cursor2
ldy #cursor3-userzp
jsr copyCursor
ldx #cursor1-userzp
ldy #cursor2-userzp
jsr copyCursor
invertSelection2:
ldx #0
ldy #4
jsr CmpCursor2_3Ptr ; backwards?
bcs :+
ldx #4
ldy #0
: lda cursor3+cursor::px ; r12 = X
sta r12L,x
lda cursor3+cursor::px+1
sta r12H,x
lda cursor3+cursor::py ; r13L = Y
sta r13L,x
lda cursor3+cursor::height ; r13H = height-1
sub #1
sta r13H,x
lda cursor2+cursor::px ; r14 = X
sta r12L,y
lda cursor2+cursor::px+1
sta r12H,y
lda cursor2+cursor::py ; r15L = Y
sta r13L,y
lda cursor2+cursor::height ; r15H = height-1
sub #1
sta r13H,y
IncW r12 ; X += 1
lda r13L ; compare Y
cmp r15L
beq @1
jsr invertSelection_XXX1
jmp invertSelection_XXX2
@1: jmp invertSelection_XXX3
; ----------------------------------------------------------------------------
L08CD: jsr L0937 ; 08CD 20 37 09 7.
stx cursor3+cursor::srcline ; 08D0 86 A2 ..
jsr moveR15_cursor3Ptr ; 08D2 20 B3 27 .'
bcs L08F9 ; 08D5 B0 22 ."
PushW_r15 ; 08D7 20 6C 28 l(
jsr getLineRuler ; 08DA 20 C9 1D ..
ldx cursor3+cursor::srcline ; 08DD A6 A2 ..
jsr justifyText2 ; 08DF 20 18 17 ..
PopW cursor3+cursor::ptr ; 08E3 85 9E ..
jsr L0927 ; 08E8 20 27 09 '.
MoveW r11, r10
jsr screenXFromPageX ; 08F3 20 0F 09 ..
jsr L0902 ; 08F6 20 02 09 ..
L08F9: MoveW r11, cursor3+cursor::px
rts ; 0901 60 `
L0902: MoveB currentMode, cursor3+cursor::mode ; 0904 85 A7 ..
MoveW curFont, cursor3+cursor::font ; 090C 85 A5 ..
L090E: rts ; 090E 60 `
;---------------------------------------------------------------
; screenXFromPageX
;
; Function: Convert a page-relative X coordinate to screen-
; relative. If its outside the screen, return the
; leftmost or rightmost screen X coordinate.
;
; Pass: r11 page x coordinate
;
; Return: c =0: ok, =1: underflow
; r11 screen x coordinate (if not underflow)
;---------------------------------------------------------------
screenXFromPageX:
ldx #r11
jsr subSideFlippingPixelOffset
lda r11H
bpl @1
jsr loadWR11Zero ; underflow, left of screen -> 0
sec
rts
@1: jsr CmpR11ScrWidth
bcc @2 ; is on screen
jmp loadR11ScreenWidthMinus1; clamp to right screen margin
@2: clc
rts
; ----------------------------------------------------------------------------
L0927: jsr CmpR15Cursor3Ptr ; 0927 20 2A 28 *(
bcs L090E ; 092A B0 E2 ..
jsr L14BD ; 092C 20 BD 14 ..
bcs L090E ; 092F B0 DD ..
jsr moveWR2R11 ; 0931 20 C8 27 .'
bra L0927 ; 0935 50 F0 P.
L0937: CmpW r15, topScrTxtPtr ; 093F C5 7C .|
bcs L0953 ; 0941 B0 10 ..
jsr loadWR11Zero ; 0943 20 88 27 .'
lda #36 ; 0946 A9 24 .$
sta cursor3+cursor::py ; 0948 85 A3 ..
ldx #$80 ; 094A A2 80 ..
lda lintab_height ; 094C AD 75 2B .u+
sta cursor3+cursor::height ; 094F 85 A4 ..
sec ; 0951 38 8
rts ; 0952 60 `
; ----------------------------------------------------------------------------
L0953: jsr copyRuler2To1 ; 0953 20 94 28 .(
ldx #$00 ; 0956 A2 00 ..
L0958: lda lintab_height,x ; 0958 BD 75 2B .u+
beq L09A9 ; 095B F0 4C .L
inx ; 095D E8 .
lda r15H ; 095E A5 21 .!
cmp lintab_txtPtr_hi,x ; 0960 DD 4B 2B .K+
bne L096A ; 0963 D0 05 ..
lda r15L ; 0965 A5 20 .
cmp lintab_txtPtr_lo,x ; 0967 DD 36 2B .6+
L096A: bcc L09A6 ; 096A 90 3A .:
bne L0958 ; 096C D0 EA ..
lda r15H ; 096E A5 21 .!
sta r14H ; 0970 85 1F ..
cmp lintab_txtPtr_hi-1,x ; 0972 DD 4A 2B .J+
bne L097E ; 0975 D0 07 ..
lda r15L ; 0977 A5 20 .
cmp lintab_txtPtr_lo-1,x ; 0979 DD 35 2B .5+
beq L09A6 ; 097C F0 28 .(
L097E: ldy r15L ; 097E A4 20 .
bne L0984 ; 0980 D0 02 ..
dec r14H ; 0982 C6 1F ..
L0984: dey ; 0984 88 .
sty r14L ; 0985 84 1E ..
lda lintab_justification-1,x
bmi L0958 ; JST_80
ldy #$00 ; 098C A0 00 ..
lda (r14),y ; 098E B1 1E ..
cmp #$0D ; 0990 C9 0D ..
beq L0958 ; 0992 F0 C4 ..
ldy #$00 ; 0994 A0 00 ..
lda (r15),y ; 0996 B1 20 .
jsr isPageBreakOrNull ; 0998 20 8C 13 ..
bcs L09A6 ; 099B B0 09 ..
lda lintab_height,x ; 099D BD 75 2B .u+
beq L09A6 ; 09A0 F0 04 ..
cpx r3L ; 09A2 E4 08 ..
beq L0958 ; 09A4 F0 B2 ..
L09A6: dex ; 09A6 CA .
clc ; 09A7 18 .
rts ; 09A8 60 `
; ----------------------------------------------------------------------------
L09A9: lda windowBottom ; 09A9 A5 34 .4
sta cursor3+cursor::py ; 09AB 85 A3 ..
ldx #$40 ; 09AD A2 40 .@
loadR11ScreenWidthMinus1: sec ; 09AF 38 8
LoadW r11, SC_PIX_WIDTH-1
rts ; 09B8 60 `
; ----------------------------------------------------------------------------
invertSelection_XXX1:
jsr copyR12R3_R14R4
ldx #>(SC_PIX_WIDTH-1)
stx r4H
ldy #<(SC_PIX_WIDTH-1)
sty r4L
cpx r3H
bne :+
cpy r3L
: bcc @3
MoveB r13L, r2L
add r13H
bcs @1
cmp windowBottom
bcc @2
@1: lda windowBottom
@2: sta r2H
jsr InvertRectangle
@3: jsr copyR12R3_R14R4
jsr loadWR3Zero
lda r15L
sta r2L
add r15H
bcs @4
cmp windowBottom
bcc @5
@4: lda windowBottom
@5: sta r2H
jmp InvertRectangle
; ----------------------------------------------------------------------------
invertSelection_XXX2:
jsr loadWR3Zero ; left = 0
jsr LoadWR4ScPixWidthMinus1 ; right = max x
ldy r15L
dey
sty r2H ; bottom
lda r13L
sec
adc r13H
bcs @1 ; overflow? clamp
cmp windowBottom
bcc @2 ; above max y? clamp
@1: lda windowBottom
@2: sta r2L ; top
cmp r2H
beq @3
bcs rts6 ; negatve height, skip
@3: jmp InvertRectangle
; ----------------------------------------------------------------------------
invertSelection_XXX3:
jsr copyR12R3_R14R4 ; get left and right
CmpW r4, r3 ; negative width? skip
bcc rts6
MoveB r13L, r2L ; top
add r13H ; + height
bcs @2 ; overflow? clamp
cmp windowBottom
bcc @3 ; above max y? clamp
@2: lda windowBottom
@3: sta r2H ; bottom
jmp InvertRectangle
; ----------------------------------------------------------------------------
copyR12R3_R14R4:
MoveW r12, r3
MoveW r14, r4
rts6: rts
;---------------------------------------------------------------
.include "strings1.inc"
;---------------------------------------------------------------
; The app's menu
;---------------------------------------------------------------
menu_main:
.byte 0 ; top
.byte 14 ; bottom
.word 0 ; left
.if LANG=LANG_DE
.word 183 ; right
.else
.word 191
.endif
.byte HORIZONTAL | UN_CONSTRAINED | M_ITEMS
menu_main_items:
.word txt_geos
.byte DYN_SUB_MENU
.word callbackGeos
.word txt_file
.byte DYN_SUB_MENU
.word callbackFile
.word txt_edit
.byte DYN_SUB_MENU
.word callbackEdit
.word txt_options
.byte DYN_SUB_MENU
.word callbackOptions
.word txt_page
.byte DYN_SUB_MENU
.word callbackPage
.word txt_font