?login_element?

Subversion Repositories NedoOS

Rev

Rev 657 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
68 Alone 1
        DEVICE ZXSPECTRUM128
76 Alone 2
        ;device pentagon1024
3
 
40 alone 4
        include "../_sdk/sys_h.asm"
5
 
344 alone 6
MAXCMDSZ=COMMANDLINE_sz-1 ;  ନ
40 alone 7
 
518 alone 8
        include "windowsh.asm"
9
 
40 alone 10
scrwid=320
11
scrwid8=scrwid/8
12
scrhgt=200
13
 
14
scrbase=0x8000
15
scrbase16k=0x4000
16
 
344 alone 17
tempc000=0x4000 ;㣫!
40 alone 18
tempe000=0x6000
19
 
20
editpal_c0=0x80
21
editpal_e0=editpal_c0+0x20
22
tabclippal=0xc000
23
 
24
titlehgt=8
25
 
26
workzonex8=4
27
workzoney=8
28
workzonewid8=scrwid/8-workzonex8-4
29
workzonehgt=scrhgt-workzoney
30
 
31
rightpanelx8=workzonex8+workzonewid8
32
 
33
colorx8=0
34
colory=scrhgt-16
35
colorhgt=16
36
 
37
palettey=workzoney
38
palettex8=rightpanelx8
39
 
40
navigatorx=rightpanelx8*8
1410 alone 41
navigatory=palettey+(8*5)
344 alone 42
navigatorhgt=31 ;  㢥稢, ⮡  뫮 ९  㬭  bitmapwid (max 2048)
40 alone 43
navigatorwid=31
44
 
45
coordsx=navigatorx
46
coordsy=navigatory+navigatorhgt+1
47
coordswindowx=coordsx
48
coordswindowy=coordsy+16
49
coordswindowwid=32
50
coordswindowhgt=32
51
 
52
ZONE_NO=0
53
ZONE_TOP=1
54
ZONE_LEFT=2
55
ZONE_RIGHT=3
56
ZONE_WORK=4
57
ZONE_PAL=5
58
ZONE_NAVIGATOR=6
59
 
60
TOOL_WINDOW=0
61
TOOL_PENCIL=1
62
TOOL_BRUSH=2
63
TOOL_LINE=3
64
TOOL_FILL=4
65
TOOL_TEXT=5
66
NTOOLS=6
67
 
657 alone 68
;backcolor=0x3f;%00111111
40 alone 69
 
70
bmpmaxpages=251
71
maxbitmaps=4
72
 
500 alone 73
nofocuskey=0xff
74
 
40 alone 75
        macro SHAPESPROC name
76
;_=$
77
        ;org _curorg
78
name
79
        ;call setpgshapes
80
        ;jp _
81
;_curorg=$
82
        ;org _
83
        endm
84
 
85
        macro SETPGBITMAPLOW
86
        ld ($+4),a
87
        ld a,(tbitmappages)
88
        SETPG32KLOW
89
        endm
90
 
91
        ;macro SETPGBITMAPHIGH
92
        ;ld ($+4),a
93
        ;ld a,(tbitmappages)
94
        ;SETPG32KHIGH
95
        ;endm
96
 
97
        org PROGSTART
98
gfxeditor_begin
99
main_go
1410 alone 100
        jp main_go2
101
        ds 256
102
main_go2
344 alone 103
        ld sp,0x4000 ;  ᪠  0x3b00!    OS
576 alone 104
        OS_HIDEFROMPARENT
40 alone 105
        ld e,0 ;EGA
106
        OS_SETGFX
505 alone 107
        ;OS_GETSCREENPAGES
344 alone 108
;de=࠭ 0- ࠭ (d=), hl=࠭ 1- ࠭ (h=)
505 alone 109
        ;ld a,e
110
        ;ld (setpgs_scr_low),a
111
        ;ld a,d
112
        ;ld (setpgs_scr_high),a
40 alone 113
 
114
        OS_GETMAINPAGES
344 alone 115
;dehl= ࠭  0000,4000,8000,c000
40 alone 116
        ld a,e
117
        ld (curpgshapes),a
118
        ld a,h
119
        ld (curpgpal),a
120
        ld a,l
121
        ld (curpgtemp),a
122
 
657 alone 123
        call cls
124
        ;call setpgs_scr
125
        ;call setpgshapes
126
        ;xor a
127
        ;call shapes_cls
40 alone 128
 
129
        ld hl,COMMANDLINE ;command line
130
        call skipword
131
        call skipspaces
132
        ld a,(hl)
133
        or a
134
        jr z,noautoload
135
;command line = "scratch <file to load>"
136
        push hl
137
        call findlastslash. ;de=after last slash or beginning of path
138
        pop hl
139
        push de
140
        dec de
141
        ld a,(de)
142
        cp '/'
143
        jr nz,$+4
144
        xor a
344 alone 145
        ld (de),a ;१  䠩
40 alone 146
        inc de
344 alone 147
        ex de,hl;ld de,wordbuf ;ASCIIZ string for parsing ( 0xc000...)
40 alone 148
        ;push de
149
        jr nz,autoload_nopath
150
        OS_CHDIR
151
autoload_nopath
152
        ;pop hl
153
        ;call findlastslash.
154
        pop de ;de=after last slash
155
 
156
        ld hl,fcb_filename ;Pointer to 11 byte buffer
157
        OS_PARSEFNAME
631 alone 158
        call fcbtoname_temppicname ;de=temppicname
159
        ;ld de,fcb
160
        ;OS_FOPEN
161
        OS_OPENHANDLE
40 alone 162
        or a
163
        jr nz,noautoload;error
631 alone 164
        ld a,b
165
        ld (curhandle),a
344 alone 166
        call readbmp ;nz=訡 (⮣    䠩)
62 Alone 167
        jr nz,autoloaderror
168
 
169
        ld hl,fcb_filename ;Pointer to 11 byte buffer
170
        ld de,curpicname
171
        call cpmname_to_dotname
172
 
173
autoloaderror
40 alone 174
        ld de,fcb
175
        OS_FCLOSE
176
        jr autoloadq
177
noautoload
178
        ld bc,320 ;wid
179
        ld de,200 ;hgt
180
        xor a ;color
181
        call newbitmap
182
autoloadq
183
 
55 Alone 184
        ld de,pathbuf_forBDOS ;de=pointer to 64 byte (MAXPATH_sz!) buf
40 alone 185
        OS_GETPATH
186
        ld a,(de)
187
        sub '0'
188
        ld (curdrive),a
189
 
190
        ;call initcontrol
191
 
192
        call showworkscreen
193
 
194
mainloop
505 alone 195
        call setpgs_scr
344 alone 196
;1.  뢮
197
;2.  ᮡ⨥
198
;3.  ࠥ
199
;4. ࠡ뢠 ᮡ⨥
40 alone 200
        call ahl_coords
344 alone 201
        call invarrzone ;㥬 㭪  ५
40 alone 202
        call ahl_coords
344 alone 203
        call showline ;㥬  
40 alone 204
        call ahl_coords
344 alone 205
        call showwindow ;㥬  
40 alone 206
        call ahl_coords
344 alone 207
        call showcopywindow ;㥬   ஢
40 alone 208
        call ahl_coords
209
        call checkfirezone
210
        ld (prarr_zone),a
211
 
212
        call setpgshapes
213
 
214
        call ahl_coords
215
        call showbitmapcoords
216
        call ahl_coords
217
        call shapes_memorizearr
218
        call ahl_coords
344 alone 219
        call shapes_prarr ;㥬 ५
40 alone 220
 
344 alone 221
        call waitsomething ;  ६ ५ 
222
;-  - ࠥ ५  ஥ ,  ५, 㥬    ५
40 alone 223
 
224
        call setpgshapes
225
 
226
        call ahl_oldcoords
344 alone 227
        call shapes_rearr ;ࠥ ५
40 alone 228
        call ahl_oldcoords
344 alone 229
        call showcopywindow ;ࠥ ஥  ஢
40 alone 230
        call ahl_oldcoords
344 alone 231
        call showwindow ;ࠥ ஥ 
40 alone 232
        call ahl_oldcoords
344 alone 233
        call showline ;ࠥ  
40 alone 234
        call ahl_oldcoords
344 alone 235
        call invarrzone ;⠭ (㥬) 㭪  ५
516 alone 236
 
237
        ;call window_messages ;TODO
40 alone 238
        call control_mousebuttons
239
        call control_keys
240
 
241
        jp mainloop
657 alone 242
 
40 alone 243
ahl_coords
244
        ld a,(arry)
245
        ld hl,(arrx)
246
        ret
247
ahl_oldcoords
248
        ld a,(oldarry)
249
        ld hl,(oldarrx)
250
        ret
251
 
252
showline
344 alone 253
;hl=x  ࠭
254
;a=y  ࠭
40 alone 255
curlinestate=$+1
256
        ld c,0
257
        dec c
258
        ret nz
259
        call checkfirezone
260
        cp ZONE_WORK
261
        ret nz
344 alone 262
;out: bc=x cur, de=y cur   ( ஢  workzone)          
40 alone 263
        ;push bc
264
        ;push de
265
        ld (curlinex2),bc
266
        ld (curliney2),de
267
 
268
curlinex=$+1
344 alone 269
        ld bc,-1 ; 㬮砭  १ shift 㯭
40 alone 270
curliney=$+1
271
        ld de,0
344 alone 272
;bc=x  bitmap
273
;de=y  bitmap
40 alone 274
        call calccoords_frombitmapcoords_noclip ;hl=x, de=y
275
 
276
        push hl ;x
277
        push de ;y
278
 
279
curlinex2=$+1
280
        ld bc,0
281
curliney2=$+1
282
        ld de,0
283
        call calccoords_frombitmapcoords_noclip ;hl=x2, de=y2
284
        ex de,hl ;hl=y2
285
        push de
286
        pop ix ;iy=x2
287
 
288
        pop de ;y
289
        pop bc ;x
290
 
291
        call setpgshapes
344 alone 292
;bc=x ( ᪮ ࠭,    ⥫)
293
;de=y ( ᪮ ࠭,    ⥫)
40 alone 294
;ix=x2
295
;hl=y2
296
        jp shapes_line
1410 alone 297
 
40 alone 298
invarrzone
344 alone 299
;஢ 㭪  ५
300
;hl=x  ࠭
301
;a=y  ࠭
40 alone 302
        push af ;y
303
        call checkfirezone
304
        pop bc ;b=y
305
        cp ZONE_LEFT
306
        ret nz
307
        ld a,b;(arry)
308
        call calccurtool
344 alone 309
        ret nc ; ⠪ 㫧
40 alone 310
        add a,a
311
        add a,a
312
        add a,a
313
        add a,a
314
        add a,workzoney
315
        ld b,a ;y
316
        ld c,0 ;x/8
147 alone 317
        ld de,0x1004 ;d=hgt ;e=wid
40 alone 318
        call setpgshapes
657 alone 319
        call getcontrastcolors
40 alone 320
        jp shapes_invbox
321
 
322
control_mousebuttons
323
        ld a,(mousebuttons)
324
        cpl
325
        and 7
326
        cp 3
344 alone 327
        jr nc,mmb ;LMB+RMB  MMB
40 alone 328
        rra
329
        jp c,fire
330
        rra
331
        jr c,rmb
344 alone 332
        ret ;
40 alone 333
 
334
isitclick
335
        ld a,(oldmousebuttons)
336
        cpl
337
        and 7
344 alone 338
        ret ;nz= 㦥 ঠ
40 alone 339
 
340
mmb
341
        call ahl_coords
344 alone 342
        call checkfirezone ;out: a= 
40 alone 343
        cp ZONE_WORK
344
        jr z,mmb_work
345
        cp ZONE_PAL
344 alone 346
        ret nz ; 
40 alone 347
        call ahl_coords
348
        sub palettey
349
        cp 4*8
344 alone 350
        ret nc ; 
40 alone 351
        rra
147 alone 352
        and 0x0c
40 alone 353
        ld c,a
354
        ld a,l
355
        srl h
356
        rra
357
        srl h
358
        rra
359
        srl h
360
        rra
361
        sub palettex8
344 alone 362
        ret c ; 
40 alone 363
        ;a=x8-palettex8
364
        add a,c
365
        add a,a
366
        ld l,a
367
        ld h,0
368
        ld bc,workpal
344 alone 369
        add hl,bc ;hl=㪠⥫  ⥪騩 梥  
40 alone 370
        ld (mmb_setpal_coloraddr),hl
371
        ld a,(hl)
372
        inc hl
373
        ld h,(hl)
374
        ld l,a
375
        call editpal
376
mmb_setpal_coloraddr=$+1
377
        ld (0),hl
657 alone 378
        jp showworkscreen
40 alone 379
mmb_work
344 alone 380
;ᮢ ⪮
381
;bc=x  bitmap, de=y  bitmap
40 alone 382
        ld a,(curcolor1)
383
        ld (curcolorA),a
384
        ld a,(curcolor2)
385
        ld (curcolorB),a
386
        ld a,(curtool1)
387
        ld (curtool),a
388
        xor a
389
        ld (curmousebutton),a
390
        jr fire_or_rmb_action_
391
 
392
rmb
393
        ld a,(curcolor2)
394
        ld (curcolorA),a
395
        ld (curcolorB),a
396
        ld a,(curtool2)
397
        ld (curtool),a
398
        ld a,1
399
        ld (curmousebutton),a
400
 
401
fire_or_rmb_action_
402
        call ahl_coords
344 alone 403
        call checkfirezone ;out: a= 
40 alone 404
        cp ZONE_LEFT
405
        jp z,setcurtool
406
        cp ZONE_PAL
407
        jp z,setcurcolor
408
        cp ZONE_NAVIGATOR
409
        jp z,fire_or_rmb_navigator
410
        cp ZONE_TOP
411
        jp z,filemenu
412
        cp ZONE_WORK
413
        ret nz
414
        xor a
344 alone 415
        ld (windowcopymode),a ;塞 ⨭ - 몫砥 ० ஢
416
;bc=x  bitmap, de=y  bitmap
40 alone 417
        ld a,(curtool)
418
        cp TOOL_PENCIL
419
        jp z,fire_or_rmb_pencil
420
        cp TOOL_LINE
421
        jp z,fire_or_rmb_line
422
        cp TOOL_FILL
423
        jp z,fire_or_rmb_fill
424
        cp TOOL_WINDOW
425
        jp z,fire_or_rmb_window
426
        cp TOOL_BRUSH
427
        jp z,fire_or_rmb_brush
428
        ret
429
 
430
fire_or_rmb_fill
431
        ld a,(curcolorA)
432
        ex af,af'
433
        ld a,(curcolorB)
434
        call fillbitmap
435
        call setpgs_scr
436
        jp showbitmap
437
 
438
fire
439
        ld a,(curcolor1)
440
        ld (curcolorA),a
441
        ld (curcolorB),a
442
        ld a,(curtool1)
443
        ld (curtool),a
444
        xor a
445
        ld (curmousebutton),a
446
        jr fire_or_rmb_action_
447
 
448
fire_or_rmb_line
344 alone 449
;bc=x  bitmap, de=y  bitmap
40 alone 450
        call isitclick
1410 alone 451
        ret nz ; 㦥 ঠ
40 alone 452
        ld hl,(curlinestate)
453
        dec l
454
        jr z,fire_or_rmb_line_finish
455
        ld a,1
456
        ld (curlinestate),a
457
        ld (curlinex),bc
458
        ld (curliney),de
459
        ret
460
fire_or_rmb_line_finish
461
        ld hl,(curliney)
462
        ld ix,(curlinex)
463
        ld a,(curcolorA)
464
        ex af,af'
465
        ld a,(curcolorB)
466
        call prlinebitmap
467
        xor a
468
        ld (curlinestate),a
469
        jp showbitmap
470
 
471
fire_or_rmb_brush
344 alone 472
;bc=x  bitmap, de=y  bitmap
40 alone 473
        ld (minx),bc
474
        ld (maxx),bc
475
        ld (miny),de
476
        ld (maxy),de
477
 
478
        ;call ahl_oldcoords
344 alone 479
        ;call checkfirezone ;out: a= 
40 alone 480
        ;cp ZONE_WORK
344 alone 481
        ;jr nz,firebrushpixel ;஥  뫮  ࠡ祩  -   (TODO ஢ )
40 alone 482
 
483
        call ahl_oldcoords
344 alone 484
        call calcbitmapcoords ;out: bc=x  bitmap, de=y  bitmap
40 alone 485
        push bc ;x2
486
        push de ;y2
487
        call ahl_coords
344 alone 488
        call calcbitmapcoords ;out: bc=x  bitmap, de=y  bitmap
40 alone 489
        ld (curlinex),bc
490
        ld (curliney),de
491
        pop hl ;y2
492
        or a
493
        sbc hl,de
494
        ld (brushlinedy),hl
495
        pop hl ;x2
496
        or a
497
        sbc hl,bc
498
        ld (brushlinedx),hl
499
 
500
;firebrushpixel
501
        ;call ahl_coords
344 alone 502
        ;call calcbitmapcoords ;out: bc=x  bitmap, de=y  bitmap
503
;bc=x  bitmap, de=y  bitmap
40 alone 504
        call firepixelpp
505
        dec bc
506
        call firepixelpp
507
        dec de
508
        call firepixelpp
509
        inc bc
510
        call firepixelpp
511
        inc bc
512
        call firepixelpp
513
        inc de
514
        call firepixelpp
515
        inc de
516
        call firepixelpp
517
        dec bc
518
        call firepixelpp
519
        dec bc
520
        call firepixelpp
521
 
522
        jp fire_scrupdate
523
 
524
firepixelpp
525
        call checkminmaxxy
344 alone 526
;bc=x  bitmap ( )
527
;de=y  bitmap ( )
40 alone 528
        ;jr $
529
        push bc
530
        push de
531
brushlinedx=$+2
532
        ld ix,0
533
        add ix,bc
534
brushlinedy=$+1
535
        ld hl,0
536
        add hl,de
537
 
538
        push bc
539
        push de
540
        push ix
541
        pop bc
542
        ex de,hl
344 alone 543
        call checkminmaxxy ; hl
40 alone 544
        ex de,hl
545
        pop de
546
        pop bc
547
 
548
        ld a,(curcolorA)
549
        ex af,af'
550
        ld a,(curcolorB)
551
        ;call setpixel_fast_coloraa
552
        call prlinebitmap
553
 
554
        pop de
555
        pop bc
556
        ret
557
 
558
fire_or_rmb_pencil        
344 alone 559
;bc=x  bitmap, de=y  bitmap (ᥣ ⥫, ..   workzone - TODO  㤥ঠ ० ᮢ  ⥫)
40 alone 560
        ld (minx),bc
561
        ld (maxx),bc
562
        ld (miny),de
563
        ld (maxy),de
564
 
565
        ;call ahl_oldcoords
344 alone 566
        ;call checkfirezone ;out: a= 
40 alone 567
        ;cp ZONE_WORK
344 alone 568
        ;jr nz,firepixel ;஥  뫮  ࠡ祩  -  
40 alone 569
fireline
147 alone 570
        ;ld a,0xfe
571
        ;in a,(0xfe)
40 alone 572
         ld a,(cur_cs_halfrow)
573
        rra ;Caps Shift
574
        jr c,fireline_noshift
575
        ld bc,(curlinex)
576
        ld a,b
577
        inc a
344 alone 578
        ret z ;0xffxx -  ।饩 窨
40 alone 579
        ld de,(curliney)
580
        jr fireline_noshiftq
581
fireline_noshift
582
        call ahl_oldcoords
344 alone 583
        call calcbitmapcoords ;out: bc=x  bitmap, de=y  bitmap
40 alone 584
fireline_noshiftq
585
        call checkminmaxxy
586
        push bc ;x2
587
        push de ;y2
588
        call ahl_coords
344 alone 589
        call calcbitmapcoords ;out: bc=x  bitmap, de=y  bitmap
40 alone 590
        ld (curlinex),bc
591
        ld (curliney),de
592
        call checkminmaxxy
593
        pop hl ;y2
594
        pop ix ;x2
595
        ld a,(curcolorA)
596
        ex af,af'
597
        ld a,(curcolorB)
598
        call prlinebitmap
599
 
600
        if 1==0
601
 
602
        jr fire_scrupdate
603
 
604
firepixel
605
        call ahl_coords
344 alone 606
        call calcbitmapcoords ;out: bc=x  bitmap, de=y  bitmap
40 alone 607
        call checkminmaxxy
344 alone 608
;bc=x  bitmap ( )
609
;de=y  bitmap ( )
40 alone 610
        ld a,(curcolorA)
611
        ex af,af'
612
        ld a,(curcolorB)
613
        call setpixel_fast_coloraa
614
 
615
        endif
616
 
617
fire_scrupdate
344 alone 618
;  ࠭
40 alone 619
;bc=minx
620
;de=miny
621
;hl=maxx, maxy
622
        call setpgs_scr
623
minx=$+1
624
        ld bc,0
625
miny=$+1
626
        ld de,0
627
        call calccoords_frombitmapcoords ;hl=x,a=y(min)
628
        dup 3
629
        srl h
630
        rr l
631
        edup
632
        push af
633
        push hl ;x/8(min)
634
maxx=$+1
635
        ld bc,0
636
maxy=$+1
637
        ld de,0
344 alone 638
;ᥪ न ᢥ, ⮡     ࠧ  checkminmaxxy
40 alone 639
        ld hl,(curbitmapwid_edit)
640
        dec hl
641
        call minhl_bc_tobc
642
        ld hl,(curbitmaphgt)
643
        dec hl
644
        or a
645
        sbc hl,de
646
        add hl,de
647
        jr nc,$+3 ;de<=hl
648
        ex de,hl
649
        call calccoords_frombitmapcoords ;hl=x,a=y(max)
650
        dup 3
651
        srl h
652
        rr l
653
        edup
344 alone 654
        inc hl ;hl=x/8(max)  㣫   ஭
40 alone 655
        pop de ;x/8(min)
656
        pop bc ;y(min)
344 alone 657
        inc a ;y(max)  㣫   ஭
40 alone 658
        sub b ;y(max)-y(min)
659
         ;jr z,$ ;ret z
660
        ld hy,a ;hy=hgt
344 alone 661
        ld a,l ;x/8(max)  㣫   ஭
40 alone 662
        sub e ;x/8(min)
663
         ;jr z,$ ;ret z
664
        ld lx,a ;lx=wid(chr)
665
        ld l,e
666
        ld h,b
344 alone 667
        push hl ;h=y  ࠭, l=x  ࠭
40 alone 668
        ex de,hl
669
        add hl,hl
670
        add hl,hl
671
        add hl,hl ;hl=x(min)
672
        ld a,b ;a=y(min)
673
        call calcbitmapcoords
674
        ld h,b
344 alone 675
        ld l,c ;hl=x  bitmap ;de=y  bitmap
676
        pop bc ;b=y  ࠭, c=x  ࠭
40 alone 677
        jp prbitmapbox
678
 
679
setcurcolor
680
        call isitclick
1410 alone 681
        ret nz ; 㦥 ঠ
40 alone 682
        ld a,(curmousebutton)
683
        or a
684
        ld de,curcolor1
685
        jr z,$+5
686
        ld de,curcolor2
687
        call ahl_coords
688
        sub palettey
689
        rra
1410 alone 690
       cp 0x10
691
       jr c,$+4
692
       ld a,0x10 ;transparent color 16
693
        and 0x1c;0x0c
40 alone 694
        ld bc,-palettex8*8
695
        add hl,bc
696
        srl l
697
        srl l
698
        srl l
699
        add a,l
700
        ld (de),a
701
        jp showcurcolor
702
 
703
checkfirecoords
344 alone 704
;hl=x  ࠭, a=y  ࠭
705
;out: CY= 
706
;bc=x  bitmap, de=y  bitmap
707
        call calcbitmapcoords ;out: bc=x  bitmap, de=y  bitmap
40 alone 708
        ld hl,(curbitmapwid_edit)
709
        scf
710
        sbc hl,bc
711
        ret c ;x>(bitmapwid-1) => x>=bitmapwid
712
        ld hl,(curbitmaphgt)
713
        scf
714
        sbc hl,de
715
        ret ;CY: y>(bitmaphgt-1) => y>=bitmaphgt
716
 
717
checkminmaxxy
344 alone 718
;bc=x, de=y (  ⥫) ( )
40 alone 719
        bit 7,b
720
        jr nz,checkminmaxxy_nox
721
        ld hl,(maxx)
722
        or a
723
        sbc hl,bc
724
        jr nc,$+6
725
        ld (maxx),bc
726
        ld hl,(minx)
727
        or a
728
        sbc hl,bc
729
        jr c,$+6
730
        ld (minx),bc
731
        jr checkminmaxxy_xq
732
checkminmaxxy_nox
733
        ld hl,0
734
        ld (minx),hl
735
checkminmaxxy_xq
736
        bit 7,d
737
        jr nz,checkminmaxxy_noy
738
        ld hl,(maxy)
739
        or a
740
        sbc hl,de
741
        jr nc,$+6
742
        ld (maxy),de
743
        ld hl,(miny)
744
        or a
745
        sbc hl,de
746
        ret c
747
        ld (miny),de
748
        ret
749
checkminmaxxy_noy
750
        ld hl,0
751
        ld (miny),hl
752
        ret
753
 
754
control_keys
755
key=$+1
756
        ld a,0
116 alone 757
        cp key_left
40 alone 758
        jp z,control_keys_left
116 alone 759
        cp key_down
40 alone 760
        jp z,control_keys_down
116 alone 761
        cp key_up
40 alone 762
        jp z,control_keys_up
116 alone 763
        cp key_right
40 alone 764
        jp z,control_keys_right
765
        cp '+'
766
        jp z,control_keys_plus
767
        cp '-'
768
        jp z,control_keys_minus
516 alone 769
        cp 'n'
770
        jp z,control_keys_new
40 alone 771
        cp 'c'
772
        jp z,control_keys_clear
773
        cp 'w'
774
        jp z,window_allpicture
775
        cp 'v'
776
        jp z,window_copy
777
        cp 'V'
778
        jp z,window_copy
779
        cp 'z'
780
        jp z,control_keys_swapcolors
781
        cp 'x'
782
        jp z,window_mirrhor
783
        cp 'y'
784
        jp z,window_mirrver
785
        cp key_redraw
786
        jp z,showworkscreen
787
        sub '1'
788
        cp 4
516 alone 789
        jp c,control_keys_selectbmp
40 alone 790
 
791
        ret
792
 
516 alone 793
control_keys_new
529 alone 794
        ;ld lx,0b00111111 ;background fill color byte 0bRLrrrlll
795
        ;ld hx,0b00000000 ;11111111 ;brush color byte 0bRLrrrlll
796
        call getcontrastcolors
516 alone 797
        ld iy,win_new
798
        call window_start
518 alone 799
        call window_mainloop
800
;restore screen:
801
        call showworkscreen
516 alone 802
        ret
803
 
1410 alone 804
getcontrastcolors ;out: lx=background fill color byte 0bRLrrrlll, hx=brush color byte 0bRLrrrlll
657 alone 805
        push bc
806
        push de
807
        push hl
529 alone 808
        ld hl,workpal
809
;DDp palette: %grbG11RB(low),%grbG11RB(high), 
810
;high B, high b, low B, low b
811
        ld ix,0x00ff ;hx=current max, lx=current min
812
        ;ld iy,0x0000 ;hy=current max index, ly=current min index
813
        ld c,16
814
getcontrastcolors0
815
        ld e,(hl)
816
        inc hl
817
        ld d,(hl)
818
        inc hl
819
        push hl
820
        ex de,hl
821
        call calchexcolor
822
;b=0xBB
823
;d=0xRR
824
;e=0xGG
825
        ld a,b
657 alone 826
        and 0x0f
827
        ld b,a
529 alone 828
        ld a,d
657 alone 829
        and 0x0f
830
        ld d,a
529 alone 831
        ld a,e
657 alone 832
        and 0x0f
833
        ld e,a
834
        add a,b
835
        add a,d
529 alone 836
        cp hx ;current max
837
        jr c,getcontrastcolors_nmax
838
        ld hx,a
839
        ld hy,c
840
getcontrastcolors_nmax
841
        cp lx ;current min
842
        jr nc,getcontrastcolors_nmin
843
        ld lx,a
844
        ld ly,c
845
getcontrastcolors_nmin
846
        pop hl
847
        dec c
848
        jr nz,getcontrastcolors0
849
;hy=current max index (for background), ly=current min index (for brush)
850
        ld h,tpixelrecode/256
851
        ld a,16
852
        sub hy
853
        ld l,a
854
        ld a,(hl)
855
        ld lx,a
856
        ld a,16
857
        sub ly
858
        ld l,a
859
        ld a,(hl)
860
        ld hx,a
861
        ;ld lx,0b00111111 ;background fill color byte 0bRLrrrlll
862
        ;ld hx,0b00000000 ;11111111 ;brush color byte 0bRLrrrlll
657 alone 863
        pop hl
864
        pop de
865
        pop bc
529 alone 866
        ret
657 alone 867
 
1410 alone 868
getgreycolor ;TODO  ᠬ ન   ᠬ , ᫨ 
657 alone 869
        ld a,0b00111111
870
        ret
871
 
872
getblackongrey
873
        call getcontrastcolors
874
        call getgreycolor
875
        ld lx,a
876
        ret
877
 
526 alone 878
buttoncancel_unclick
518 alone 879
        jp window_close
526 alone 880
buttonok_unclick
881
;TODO check sizes
882
        ld hl,win_new_twid
883
        call strtoint
884
        dec hl
885
        ld bc,2048
886
        or a
887
        sbc hl,bc
888
        add hl,bc
889
        inc hl
890
        ret nc ;wrong number
891
         ld (buttonok_wid),hl
892
        ld hl,win_new_thgt
893
        call strtoint
894
        dec hl
895
        ld bc,2048
896
        or a
897
        sbc hl,bc
898
        add hl,bc
899
        inc hl
900
        ret nc ;wrong number
901
;new image:
902
        push hl
903
        call delbitmap ;㤠 ⥪ ⨭  ᢮ ࠭窨
904
buttonok_wid=$+1
905
        ld hl,0
906
        ld (curbitmapwid_edit),hl
907
        pop hl
908
        ld (curbitmaphgt),hl
909
        call reserve_bmp_pages ;⠬ genmuldewid_ahl
910
 
911
        ld bc,0 ;bc=x in bitmap
912
        ld de,0 ;de=y in bitmap
913
        ld hl,(curbitmapwid_edit) ;hl=wid
914
        ld ix,(curbitmaphgt) ;ix=hgt
529 alone 915
 
535 alone 916
        ld a,(win_new_flag0color_flags)
529 alone 917
        bit WINELEMENT_FLAG_CHECKED,a
535 alone 918
        ld a,0
919
        jr nz,newimage_q
920
        ld a,(win_new_flagbrushcolor_flags)
921
        bit WINELEMENT_FLAG_CHECKED,a
529 alone 922
        ld a,(curcolor1) ;a=color1
923
        jr nz,$+5
526 alone 924
        ld a,(curcolor2) ;a=color1
535 alone 925
newimage_q
526 alone 926
        call bitmap_fillbox
927
 
928
        jp window_close
516 alone 929
reter
930
        ret
931
 
932
win_new
933
;x/2,y,wid/2,hgt
526 alone 934
        db 52,10,64,64
518 alone 935
        db 0b1000 ;flags
936
; Bit 0 - ࠬ   (don't draw frame)
937
; Bit 1 - reserved
938
; Bit 2 - ᪠   ࠭ (movable window)
939
; Bit 3 - 室  -⪭ ⮫쪮   । (CANCEL by clicking outside the window) 
940
 
516 alone 941
;;window elements (linked list)
942
;link16 ;0=end of list
943
;x/2,y,wid/2,hgt
944
;type
945
;checked
946
;hidden
947
;disabled
948
;onclick16
949
;onunclick16
950
;onmove16
526 alone 951
win_new_title
518 alone 952
        STARTWINELEMENT
535 alone 953
        dw win_new_flagbgcolor ;0=end of list
526 alone 954
        db 24,3,9*2,8
955
        db T_LABEL
956
        db 0b0000 ;b0:checked, b1:hidden, b2:disabled, b3:invertible
957
        db 0 ;hotkey
958
        dw reter ;onclick16
959
        dw reter ;onunclick16
960
        dw reter ;onmove16
961
        PADWINELEMENT
962
        db "New image",0
963
 
535 alone 964
win_new_flagbgcolor
529 alone 965
        STARTWINELEMENT
535 alone 966
        dw win_new_flagbrushcolor ;0=end of list
967
        db 24,14,4,8
968
        db T_RADIO
969
win_new_flagbgcolor_flags
529 alone 970
        db 0b1001 ;b0:checked, b1:hidden, b2:disabled, b3:invertible
971
        db 0 ;hotkey
972
        dw reter ;onclick16
973
        dw reter ;onunclick16
974
        dw reter ;onmove16
975
        PADWINELEMENT
535 alone 976
        db "Background color",0
977
 
978
win_new_flagbrushcolor
979
        STARTWINELEMENT
980
        dw win_new_flag0color ;0=end of list
981
        db 24,22,4,8
982
        db T_RADIO
983
win_new_flagbrushcolor_flags
984
        db 0b1000 ;b0:checked, b1:hidden, b2:disabled, b3:invertible
985
        db 0 ;hotkey
986
        dw reter ;onclick16
987
        dw reter ;onunclick16
988
        dw reter ;onmove16
989
        PADWINELEMENT
529 alone 990
        db "Brush color",0
991
 
535 alone 992
win_new_flag0color
993
        STARTWINELEMENT
994
        dw win_new_labelhgt ;0=end of list
995
        db 24,30,4,8
996
        db T_RADIO
997
win_new_flag0color_flags
998
        db 0b1000 ;b0:checked, b1:hidden, b2:disabled, b3:invertible
999
        db 0 ;hotkey
1000
        dw reter ;onclick16
1001
        dw reter ;onunclick16
1002
        dw reter ;onmove16
1003
        PADWINELEMENT
1004
        db "Color 0",0
1005
 
526 alone 1006
win_new_labelhgt
1007
        STARTWINELEMENT
1008
        dw win_new_edithgt ;0=end of list
1009
        db 8,14,8,8
1010
        db T_LABEL
1011
        db 0b0000 ;b0:checked, b1:hidden, b2:disabled, b3:invertible
1012
        db 0 ;hotkey
1013
        dw reter ;onclick16
1014
        dw reter ;onunclick16
1015
        dw reter ;onmove16
1016
        PADWINELEMENT
1017
        db "Hgt=",0
1018
 
1019
win_new_edithgt
1020
        STARTWINELEMENT
1021
        dw win_new_labelwid ;0=end of list
1022
        db 16,14,8,8
1023
        db T_EDIT
521 alone 1024
        db 0b1000 ;b0:checked, b1:hidden, b2:disabled, b3:invertible
518 alone 1025
        db 0 ;hotkey
526 alone 1026
        dw reter ;onclick16
1027
        dw reter ;onunclick16
516 alone 1028
        dw reter ;onmove16
518 alone 1029
        PADWINELEMENT
526 alone 1030
win_new_thgt
535 alone 1031
        db "192 ",0
526 alone 1032
 
1033
win_new_labelwid
1034
        STARTWINELEMENT
1035
        dw win_new_editwid ;0=end of list
1036
        db 8,24,8,8
1037
        db T_LABEL
1038
        db 0b0000 ;b0:checked, b1:hidden, b2:disabled, b3:invertible
1039
        db 0 ;hotkey
1040
        dw reter ;onclick16
1041
        dw reter ;onunclick16
1042
        dw reter ;onmove16
1043
        PADWINELEMENT
1044
        db "Wid=",0
1045
 
1046
win_new_editwid
1047
        STARTWINELEMENT
1048
        dw win_new_buttonok ;0=end of list
1049
        db 16,24,8,8
1050
        db T_EDIT
1051
        db 0b1000 ;b0:checked, b1:hidden, b2:disabled, b3:invertible
1052
        db 0 ;hotkey
1053
        dw reter ;onclick16
1054
        dw reter ;onunclick16
1055
        dw reter ;onmove16
1056
        PADWINELEMENT
1057
win_new_twid
535 alone 1058
        db "256 ",0
526 alone 1059
 
1060
win_new_buttonok
1061
        STARTWINELEMENT
1062
        dw win_new_buttoncancel ;0=end of list
1063
        db 8,40,20,16
1064
        db T_BUTTON
1065
        db 0b0000 ;b0:checked, b1:hidden, b2:disabled, b3:invertible
1066
        db 0 ;hotkey
1067
        dw reter ;onclick16
1068
        dw buttonok_unclick ;onunclick16
1069
        dw reter ;onmove16
1070
        PADWINELEMENT
518 alone 1071
        db "OK",0
1072
 
526 alone 1073
win_new_buttoncancel
518 alone 1074
        STARTWINELEMENT
516 alone 1075
        dw 0 ;0=end of list
526 alone 1076
        db 36,40,20,16
1077
        db T_BUTTON
521 alone 1078
        db 0b0000 ;b0:checked, b1:hidden, b2:disabled, b3:invertible
518 alone 1079
        db 0 ;hotkey
526 alone 1080
        dw reter ;onclick16
1081
        dw buttoncancel_unclick ;onunclick16
516 alone 1082
        dw reter ;onmove16
518 alone 1083
        PADWINELEMENT
1084
        db "Cancel",0
516 alone 1085
 
1086
 
1087
 
40 alone 1088
control_keys_swapcolors
1089
        ld hl,(curcolor1) ;1, 2
1090
        ld a,l
1091
        ld l,h
1092
        ld h,a
1093
        ld (curcolor1),hl
1094
        jp showworkscreen
1095
 
1096
control_keys_selectbmp
1097
        call selectbmp
1098
        call kill_unfinished_shapes
1099
        jp showworkscreen ;control_scale_checksize
1100
 
1101
kill_unfinished_shapes
1102
        xor a
344 alone 1103
        ld (curlinestate),a ;㡨 । 
40 alone 1104
        dec a
344 alone 1105
        ld (curlinex+1),a ;⬥塞 砫   १ shift
40 alone 1106
         ld a,(curwindowstate)
1107
         dec a
344 alone 1108
         call z,clearwindowstate ;㡨 ।񭭮 
40 alone 1109
        ret
1110
 
1111
findcurbitmap
344 alone 1112
;a=
40 alone 1113
        ld c,a
1114
        ld b,0
1115
        ld de,bitmapstruct_sz
1116
        call mulbcde_ahl
1117
        ld bc,bitmaps
1118
        add hl,bc
1119
        ret
1120
 
1121
control_keys_right
1122
        call control_getscrollvalue ;de=scrollvalue
1123
        ld hl,(curbitmapxscroll)
1124
        add hl,de
1125
control_keys_setxscroll
1126
        ld (curbitmapxscroll),hl
302 alone 1127
control_scroll_emptyqueue_checksize
1128
         ;call emptykeyqueue
1129
emptykeyqueue0
1130
        GET_KEY
1131
        or a
1132
        jr nz,emptykeyqueue0
40 alone 1133
control_scroll_checksize
1134
        call control_scroll_checksizepp
1135
        call shownavigator
1136
        call showtitle
1137
        jp showbitmap
1138
control_scroll_checksizepp
1139
        ld hl,+(workzonex8+workzonewid8)*8 ;hl=x
1140
        ld a,workzoney+workzonehgt ;a=y        
344 alone 1141
        call calcbitmapcoords ;out: bc=x  bitmap, de=y  bitmap
40 alone 1142
 
1143
        ld hl,(curbitmaphgt)
1144
        or a
1145
        sbc hl,de
1146
        jr nc,control_scroll_nocorrecty ;hgt>=y
344 alone 1147
;hl<0 (᪮쪮 譨 ᥫ bitmap  y)
1148
; bitmaphgt-(workzonehgt/scale) = bitmaphgt+hl
40 alone 1149
        ld de,workzonehgt
1150
        call scalescrcoords
1151
        ld hl,(curbitmaphgt)
1152
        call subhldecheck0
1153
        ld (curbitmapyscroll),hl
1154
control_scroll_nocorrecty
1155
        ld hl,(curbitmapwid_edit)
1156
        or a
1157
        sbc hl,bc
1158
        ret nc ;wid>=x
344 alone 1159
;hl<0 (᪮쪮 譨 ᥫ bitmap  x)
1160
; bitmapwid-(workzonewid/scale) = bitmapwid+hl
40 alone 1161
        ld de,workzonewid8*8
1162
        call scalescrcoords
1163
        ld hl,(curbitmapwid_edit)
1164
        call subhldecheck0
1165
        ld (curbitmapxscroll),hl
1166
        ret
1167
 
1168
control_keys_left
1169
        call control_getscrollvalue ;de=scrollvalue
1170
        ld hl,(curbitmapxscroll)
1171
        ;or a
1172
        ;sbc hl,de
1173
        ;jr nc,$+5
1174
        ;ld hl,0
1175
        call subhldecheck0
1176
        jr control_keys_setxscroll
1177
 
1178
control_keys_down
1179
        call control_getscrollvalue ;de=scrollvalue
1180
        ld hl,(curbitmapyscroll)
1181
        add hl,de
1182
control_keys_setyscroll
1183
        ld (curbitmapyscroll),hl
302 alone 1184
        jr control_scroll_emptyqueue_checksize
40 alone 1185
 
1186
control_keys_up
1187
        call control_getscrollvalue ;de=scrollvalue
1188
        ld hl,(curbitmapyscroll)
1189
        ;or a
1190
        ;sbc hl,de
1191
        ;jr nc,$+5
1192
        ;ld hl,0
1193
        call subhldecheck0
1194
        jr control_keys_setyscroll
1195
 
1196
control_getscrollvalue
1197
        ld de,64
1198
        jp scalescrcoords
1199
 
1200
control_scale_checksize
1201
        call control_scroll_checksizepp
1202
 
1203
        call setpgshapes
1204
 
1205
        ld bc,workzoney*256 + workzonex8 ;b=y ;c=x/8
1206
        ld de,workzonehgt*256 + workzonewid8 ;d=hgt ;e=wid8
147 alone 1207
        ld a,0x3f;%00111111 ;a=%33210210
40 alone 1208
        call shapes_fillbox
1209
        jp control_scroll_checksize;showworkscreen
1210
control_keys_plus
1211
        ld a,(curbitmapscale)
1212
        inc a
1213
        cp 5+1
1214
        jr c,$+3
1215
        dec a
1216
        ld (curbitmapscale),a
344 alone 1217
        jp control_scroll_checksize ; 㦭 ९뢠 ⮥ 
40 alone 1218
control_keys_minus
1219
        ld a,(curbitmapscale)
1220
        dec a
1221
        jr nz,$+3
1222
        inc a
1223
        ld (curbitmapscale),a
1224
        jp control_scale_checksize
1225
 
1226
control_keys_clear
1227
        ld a,(curwindowstate)
1228
        cp 2
1229
        ret nz
344 alone 1230
        ld bc,(curwindowx) ;bc=x  bitmap
1231
        ld de,(curwindowy) ;de=y  bitmap
40 alone 1232
        ld hl,(curwindowwid) ;hl=wid
1233
        ld ix,(curwindowhgt) ;ix=hgt
1234
        ld a,(curcolor2)
1235
        ex af,af'
1236
        ld a,(curcolor2)
1237
;a=color1
1238
;a'=color2
1239
        call bitmap_fillbox
1240
        jp showbitmap
1241
 
1242
checkfirezone
1243
;hl=x
1244
;a=y
344 alone 1245
;out: a=    ZONE_WORK: bc=x  bitmap, de=y  bitmap
40 alone 1246
        ld c,a
1247
        cp workzoney
1248
        ld a,ZONE_TOP
1249
        ret c ;top
1250
        ld a,ZONE_LEFT
1251
        ld de,workzonex8*8
1252
        ;or a
1253
        sbc hl,de
1254
        add hl,de
1255
        ret c ;left
1256
        ld de,+(workzonex8+workzonewid8)*8
1257
        ;or a
1258
        sbc hl,de
1259
        add hl,de
1260
        ld a,c
1261
        jr nc,checkfirezone_right ;right
344 alone 1262
        call checkfirecoords ;CY= 
40 alone 1263
        ld a,ZONE_NO
344 alone 1264
        ret c ;bc=x  bitmap, de=y  bitmap
40 alone 1265
        ld a,ZONE_WORK
1266
        ret
1267
checkfirezone_right
1268
        cp navigatory
1269
        ld a,ZONE_PAL
1270
        ret c ;pal
1271
        cp navigatory+navigatorhgt
1272
        ld a,ZONE_NAVIGATOR
1273
        ret c ;navigator
1274
        ld a,ZONE_RIGHT
1275
        ret ;right
1276
 
1277
showworkscreen
1278
        call setpgs_scr
1279
        call setpgshapes
657 alone 1280
        call getgreycolor ;ld a,backcolor
40 alone 1281
        call shapes_cls
1282
 
1283
        call showtitle
1284
        call showbitmap
1285
        call showtools
1286
        call showcurcolor
1287
        call showpalette
1288
 
1289
        jp shownavigator
1290
 
1291
showcurcolor
1292
        call setpgshapes
1293
 
1294
        ld de,256*colorhgt+2
1295
        push de ;y
1296
        ld bc,256*colory+colorx8
1410 alone 1297
        ld hl,(curcolor1)
1298
        ld h,tpixelrecode/256
1299
        ld a,(hl)
1300
        ;call shapes_colortocolormask
40 alone 1301
        call shapes_prbox
1302
        ;ld de,256*colorhgt+2
1303
        pop de ;y
1304
        ld bc,256*colory+colorx8+2
1410 alone 1305
        ld hl,(curcolor2)
1306
        ld h,tpixelrecode/256
1307
        ld a,(hl)
1308
        ;call shapes_colortocolormask
40 alone 1309
        jp shapes_prbox
1310
 
1311
calccurtool
1312
;a=y
344 alone 1313
;।  㫧  न⠬ ५
40 alone 1314
;out: a=tool, NC: a>=NTOOLS
1315
        sub 8
1316
        rra
1317
        rra
1318
        rra
1319
        rra
147 alone 1320
        and 0x0f
40 alone 1321
        cp NTOOLS
1322
        ret
1323
 
1324
setcurtool
1325
        call isitclick
657 alone 1326
        ret nz ; 㦥 ঠ
40 alone 1327
        xor a
344 alone 1328
        ld (curlinestate),a ;⬥ । 
40 alone 1329
curmousebutton=$+1 ;0=LMB
1330
        or 0
1331
        ld hl,curtool1
1332
        jr z,$+5
1333
        ld hl,curtool2
1334
        ld a,(arry)
1335
        call calccurtool
1336
        ret nc ;>=NTOOLS
1337
        ld (hl),a
1338
        cp TOOL_WINDOW
1339
        jr nz,showcurtool
1340
        ld a,1
1341
        ld (windowcopymode),a
1342
        ;jp showcurtool
1343
showcurtool
1344
        call setpgshapes
1345
 
1346
        ld bc,256*(colory-10)+colorx8+1
1347
        call calcscr_from_xchr_y        
1348
        ld de,text_ntool
1349
        ld a,(curtool1)
1350
        add a,'0'
1351
        ld (de),a
1352
        inc de
1353
        inc de
1354
        ld a,(curtool2)
1355
        add a,'0'
1356
        ld (de),a
1357
        dec de
1358
        dec de
657 alone 1359
        call getcontrastcolors ;ld ix,0xff00+backcolor
516 alone 1360
        jp shapes_prtext48ega;_oncolor
40 alone 1361
 
1362
text_ntool
1363
        db "0 0",0
1364
 
1365
showtools
1366
        call setpgshapes
657 alone 1367
        call getcontrastcolors ;ld ix,0x0000+backcolor
1368
        call getgreycolor ;ld a,backcolor
1369
        ld lx,a
40 alone 1370
        ld de,ttools
1371
        ld bc,256*workzoney+0
1372
showtools0
1373
        push bc
1374
        push de
147 alone 1375
        ld de,0x1004
657 alone 1376
        call getgreycolor ;ld a,backcolor
40 alone 1377
        call shapes_prbox
1378
        pop de
1379
        pop bc
1380
        push bc
1381
        ld a,b
1382
        add a,4
1383
        ld b,a
1384
        call calcscr_from_xchr_y
344 alone 1385
        set 5,h ; 4 ᥫ ࠢ
516 alone 1386
        call shapes_prtext48ega;_black
40 alone 1387
        pop bc
1388
        ld a,b
147 alone 1389
        add a,0x10
40 alone 1390
        ld b,a
1391
        inc de
1392
        ld a,(de)
1393
        inc a
1394
        jr nz,showtools0
1395
        ret
1396
 
1397
showpalette
1398
        call setpgshapes
1399
 
1400
        xor a
1401
        ld b,workzoney ;b
1402
        ld e,4
1403
prpal0
1404
        ld c,palettex8
1405
        ld d,4
1406
prpal1
1407
        push af
1408
        push de
147 alone 1409
        ld de,0x0801 ;hgt, wid(chr)
40 alone 1410
        push bc
1410 alone 1411
        ld l,a
1412
        ld h,tpixelrecode/256
1413
        ld a,(hl)
1414
        ;call shapes_colortocolormask
40 alone 1415
        call shapes_prbox
1416
        pop bc
1417
        pop de
1418
        pop af
1419
        inc c
1420
        inc a
1421
        dec d
1422
        jr nz,prpal1
1423
        push af
1424
        ld a,b
1425
        add a,8
1426
        ld b,a ;y
1427
        pop af
1428
        dec e
1429
        jr nz,prpal0
1430
        ret
1431
 
1432
showtitle
1433
        call setpgshapes
1434
 
1435
        ld bc,0 ;b=y ;c=x/8
1436
        ld de,titlehgt*256 + scrwid8 ;d=hgt ;e=wid8
657 alone 1437
        ;xor a ;a=%33210210
1438
        call getcontrastcolors
1439
         ld a,hx
40 alone 1440
        call shapes_fillbox
516 alone 1441
        ;ld hl,prchar48ega_whiteoncolor
1442
        ;ld (prchar48ega_colorproc),hl
657 alone 1443
        ;call getcontrastcolors ;ld ix,0xff00 ;lx=䮭 梥
1444
         ld a,lx
1445
         ld lx,hx
1446
         ld hx,a
40 alone 1447
        ld hl,scrbase ;scr
1448
        ld a,(curbmp)
1449
        add a,'1'
516 alone 1450
        call shapes_prchar48ega;_oncolor
40 alone 1451
        ld a,':'
516 alone 1452
        call shapes_prchar48ega;_oncolor
40 alone 1453
        ld de,curpicname
516 alone 1454
        call shapes_prtext48ega;_oncolor
40 alone 1455
        ld a,' '
516 alone 1456
        call shapes_prchar48ega;_oncolor
40 alone 1457
        ex de,hl
1458
        ld hl,(curbitmapwid_edit)
516 alone 1459
        call shapes_prnum;_oncolor
40 alone 1460
        ex de,hl
1461
        ld a,'x'
516 alone 1462
        call shapes_prchar48ega;_oncolor
40 alone 1463
        ex de,hl
1464
        ld hl,(curbitmaphgt)
516 alone 1465
        call shapes_prnum;_oncolor
40 alone 1466
        ex de,hl
1467
        ld a,' '
516 alone 1468
        call shapes_prchar48ega;_oncolor
40 alone 1469
        ex de,hl
1470
        ld a,(curbitmapscale)
1471
        ld l,a
1472
        ld h,0
1473
        add hl,hl
1474
        add hl,hl
1475
        ld bc,tscalesnames-4
1476
        add hl,bc
1477
        ex de,hl
516 alone 1478
        call shapes_prtext48ega;_oncolor
40 alone 1479
 
1480
        ld a,'%'
516 alone 1481
        jp shapes_prchar48ega;_oncolor
40 alone 1482
 
1483
 
1484
tscalesnames
1485
        db " 25",0
1486
        db " 50",0
1487
        db "100",0
1488
        db "200",0
1489
        db "400",0
1490
 
1410 alone 1491
setpal_de
1492
        OS_SETPAL
1493
        ret
40 alone 1494
showbitmap
1410 alone 1495
        ld de,workpal
1496
        call setpal_de
40 alone 1497
        call setpgs_scr
1498
        ld hl,(curbitmapwid_edit)
1499
        ld de,(curbitmaphgt)
1500
        ld a,d
1501
        or e
344 alone 1502
        ret z ;⮩ 
40 alone 1503
        call scalebitmapcoords ;hl=wid, de=hgt
1504
        inc hl
1505
        srl h
1506
        rr l
1507
        inc hl
1508
        srl h
1509
        rr l
1510
        inc hl
1511
        srl h
1512
        rr l ;wid(chr)
1513
        ld bc,workzonewid8
1514
        or a
1515
        sbc hl,bc
1516
        add hl,bc
344 alone 1517
        jr nc,$+3 ;wid>=workzonewid =>  ਭ ࠡ祩 
1518
        ld c,l ;wid<workzonewid =>  wid 
40 alone 1519
        ld lx,c;workzonewid8 ;lx=wid(chr)
1520
        ex de,hl
1521
        ld bc,workzonehgt
1522
        or a
1523
        sbc hl,bc
1524
        add hl,bc
344 alone 1525
        jr nc,$+3 ;hgt>=workzonehgt =>  ਭ ࠡ祩 
1526
        ld c,l ;hgt<workzonehgt =>  hgt 
40 alone 1527
        ld hy,c;workzonehgt ;hy=hgt
1528
 
344 alone 1529
        ld hl,(curbitmapxscroll) ;hl=x  bitmap
1530
        ld de,(curbitmapyscroll) ;de=y  bitmap
1531
        ld bc,workzoney*256+workzonex8 ;c=x/8  ࠭, b=y  ࠭
40 alone 1532
        jp prbitmapbox
1533
 
1534
calcscr_from_xchr_y
1535
;b=y
1536
;c=x/8
1537
;out: hl=scraddr
344 alone 1538
;  de
40 alone 1539
         ld a,c
1540
calcscr_from_xchr_ya
1541
        ld l,b
1542
        ld h,0
1543
         ld b,scrbase/256/8
1544
         ld c,l
1545
        add hl,hl
1546
        add hl,hl
1547
        add hl,bc;de ;y*5
1548
        add hl,hl
1549
        add hl,hl
1550
        add hl,hl ;y*40 + scrbase
1551
         add a,l
1552
         ld l,a
1553
         ret nc
1554
         inc h
1555
        ret
1556
 
1557
cls
1558
        call setpgs_scr
1559
        call setpgshapes
1560
        xor a
1561
        jp shapes_cls
1562
 
1563
        align 256
1564
tmirror
1565
_=0
1566
        dup 256
1567
_0=_&1
1568
_1=_>>1&1
1569
_2=_>>2&1
1570
_3=_>>3&1
1571
_4=_>>4&1
1572
_5=_>>5&1
1573
_6=_>>6&1
1574
_7=_>>7&1
1575
        db (_0<<7)+(_1<<6)+(_2<<5)+(_3<<4)+(_4<<3)+(_5<<2)+(_6<<1)+(_7)
1576
_=_+1
1577
        edup
1578
 
1579
ttools
1580
        db "Window",0
1581
        db "Pencil",0
1582
        db "Brush",0
1583
        db "Line",0
1584
        db "Fill",0
1585
        db "Text",0
1586
        db -1
1587
 
1588
curtool
1589
        db 0
1590
curtool1
1591
        db 1
1592
curtool2
1593
        db 0
1594
curcolorA
1595
        db 0
1596
curcolorB
1597
        db 0
1598
curcolor1
1599
        db 15
1600
curcolor2
1601
        db 0
1602
 
1603
prarr_zone
1604
        db 0
1605
 
1606
setpgs_scr
505 alone 1607
;setpgs_scr_low=$+1
1608
;        ld a,0;pgscr0_0 ;scr0_0
1609
        ld a,(user_scr0_low)
40 alone 1610
        SETPG32KLOW
505 alone 1611
;setpgs_scr_high=$+1
1612
;        ld a,0;pgscr0_1 ;scr0_1
1613
        ld a,(user_scr0_high)
40 alone 1614
        SETPG32KHIGH
1615
        ret
1616
 
1617
setpgshapes
1618
        push bc
1619
curpgshapes=$+1
1620
        ld a,0;pgshapes
1410 alone 1621
        SETPG4000
40 alone 1622
        pop bc
1623
        ret
1624
 
1625
setpgpal
1626
        push bc
1627
curpgpal=$+1
1628
        ld a,0;pgshapes
1629
        SETPG32KLOW
1630
        pop bc
1631
        ret
1632
 
1633
setpgtemp
1634
        push bc
1635
curpgtemp=$+1
1636
        ld a,0;pgshapes
1637
        SETPG32KHIGH
1638
        pop bc
1639
        ret
1640
 
1641
        include "window.asm"
1642
        include "navigator.asm"
1643
 
1410 alone 1644
        ;include "pal.asm"
40 alone 1645
 
1646
        include "bitmap.asm"
1647
 
1648
        include "prbitmap.asm"
1649
 
1650
        include "control.asm"
1651
        include "math.asm"
1652
 
1653
        include "files.asm"
1654
 
518 alone 1655
        include "windows.asm"
1656
 
40 alone 1657
skipword
1658
;hl=string
1659
;out: hl=terminator/space addr
1660
getword0
1661
        ld a,(hl)
1662
        or a
1663
        ret z
1664
        cp ' '
1665
        ret z
1666
        inc hl
1667
        jr getword0
1668
 
1669
skipspaces
1670
;hl=string
1671
;out: hl=after last space
1672
        ld a,(hl)
1673
        cp ' '
1674
        ret nz
1675
        inc hl
1676
        jr skipspaces
1677
 
1678
;hl = poi to filename in string
1679
findlastslash.
1680
nfopenfnslash.
1681
        ld d,h
1682
        ld e,l ;de = after last slash
1683
;find last slash
1684
nfopenfnslash0.
1685
        ld a,[hl]
1686
        inc hl
1687
        or a
1688
        jr z,nfopenfnslashq.
1689
        cp '/'
1690
        jr nz,nfopenfnslash0.
1691
        jr nfopenfnslash.
1692
nfopenfnslashq.
1693
;de = after last slash or beginning of path
1694
        ret
1695
 
1696
wordbuf
1697
        ds MAXCMDSZ+1
1698
 
1699
pathbuf_forBDOS
344 alone 1700
        ds MAXPATH_sz ;ᥩ ᯮ ⮫쪮  樠樨 ( ⥪騩 ࠩ)
40 alone 1701
 
289 dimkam 1702
        ;display "$ before align=",/h,$
40 alone 1703
 
1704
        .align 256
344 alone 1705
;;;;;;;;;;;;;;;;;;; ⠡  prbitmap
1410 alone 1706
tpixelrecode ; 㢥祭 ⠡ (  ᥫ   )
40 alone 1707
;%00003210 => %33210210
1410 alone 1708
        dup 16
40 alone 1709
_3=$&8
1710
_210=$&7
147 alone 1711
        db (_3*0x18) + (_210*0x09)
40 alone 1712
        edup
1410 alone 1713
        dup 256-16
1714
        db 0b10111000 ;TODO patched maxbrightL+minbrightR/minbrightL+maxbrightR
1715
        edup
1716
 
1717
;  ⠡ -  100%  㬥襭 ⠡
40 alone 1718
tpixelrecodeLEFT
1719
;%00003210 => %.3...210
1410 alone 1720
        dup 16
40 alone 1721
_3=$&8
1722
_210=$&7
147 alone 1723
        db (_3*0x08) + (_210*0x01)
40 alone 1724
        edup
1410 alone 1725
        dup 256-16
1726
        db 0 ;TODO patched maxbrightL/minrightL
1727
        edup
1728
 
40 alone 1729
tpixelrecodeRIGHT
1730
;%00003210 => %3.210...
1410 alone 1731
        dup 16
40 alone 1732
_3=$&8
1733
_210=$&7
147 alone 1734
        db (_3*0x10) + (_210*0x08)
40 alone 1735
        edup
1410 alone 1736
        dup 256-16
1737
        db 0b10111000 ;TODO patched minbrightR/maxbrightR
1738
        edup
1739
 
1740
tbitmappages
1741
        ;display "tbitmappages=",tbitmappages
1742
        ds bmpmaxpages,0x7f
40 alone 1743
 
1410 alone 1744
activeend
1745
        display "activeend=",activeend
1746
        ds 0x4000-$
1747
SHAPES_begin
1748
        include "prshapes.asm"
1749
        include "prarrow.asm"
1750
        include "prtext.asm"
1751
        include "pal.asm"
1752
        .align 256
344 alone 1753
;;;;;;;;;;;;;;;;;;; ⠡  
40 alone 1754
tsin
1755
        incbin "tsin200"
1756
tarcsin
1757
        incbin "tarcsin"
1758
tsqr
344 alone 1759
;㬥 +-0..127 (ᮮ⢥ -1..+1)
1760
;१ 0..127 (ᮮ⢥ -1..+1)
40 alone 1761
_=0
1762
        dup 128
1763
        db (_*_)/128
1764
_=_+1
1765
        edup
1766
_=128
1767
        dup 128
1768
        db (_*_)/128
1769
_=_-1
1770
        edup
1771
tsqrt
344 alone 1772
;㬥 0..255 (ᮮ⢥ 0..2)
1773
;१ 0..127 (ᮮ⢥ 0..1)  
64 Alone 1774
        incbin "sqrtmax2"
40 alone 1775
        .align 256
1776
font48
55 Alone 1777
        incbin "64qua.fnt"
40 alone 1778
SHAPES_sz=$-SHAPES_begin
516 alone 1779
        display "Shapes size ",/d,SHAPES_sz," bytes"
40 alone 1780
 
1781
gfxeditor_end
1782
 
1783
        display "Size ",/d,gfxeditor_end-gfxeditor_begin," bytes"
289 dimkam 1784
        ;display "Free (incl. stack) ",/d,0x4000-activeend," bytes"
40 alone 1785
 
1786
        savebin "scratch.com",gfxeditor_begin,gfxeditor_end-gfxeditor_begin
1787
 
657 alone 1788
        LABELSLIST "../../us/user.l"