?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. clear_screen:
  2.         ld e,0
  3.         OS_CLS
  4.         ret
  5.  
  6. setpal_proc
  7. ;       call makefadepixel
  8. ;       call makewhitepixel
  9. ;       call makefonttable
  10. ;       ld de,(fadecolor)
  11. ;       OS_SETBORDER
  12.         ld de,pal
  13.         OS_SETPAL
  14.         xor a
  15.         ld (setpalflag),a
  16.         ret        
  17.  
  18.  
  19. print_hl
  20.         ld a,(hl)
  21.         or a
  22.         ret z
  23.         push hl
  24.         PRCHAR
  25.         pop hl
  26.         inc hl
  27.         jp print_hl
  28.         ret
  29.  
  30. ;---------------------------------------
  31. ;for 320x200
  32. _immed_big:
  33.         ld a,1
  34.         ld (setpalflag),a
  35.         call store8000c000
  36.  
  37.         halt
  38.         ld a,(load_buf1)
  39.         SETPG8000
  40.         ld a,(user_scr0_low)
  41.         SETPGC000
  42.  
  43.  
  44.         ld hl,0x8000
  45.         ld de,0xc000
  46.         ld bc,8000
  47.         ldir
  48.  
  49.  
  50.        
  51.         ld a,(load_buf2)
  52.         SETPG8000
  53.         ld a,(user_scr0_high)
  54.         SETPGC000
  55.  
  56.  
  57.         ld hl,0x8000
  58.         ld de,0xc000
  59.         ld bc,8000
  60.         ldir
  61.  
  62.        
  63.         ld a,(load_buf1)
  64.         SETPG8000
  65.         ld a,(user_scr0_low)
  66.         SETPGC000
  67.  
  68.  
  69.         ld hl,0xa000
  70.         ld de,0xe000
  71.         ld bc,8000
  72.         ldir
  73.  
  74.  
  75.        
  76.         ld a,(load_buf2)
  77.         SETPG8000
  78.         ld a,(user_scr0_high)
  79.         SETPGC000
  80.  
  81.  
  82.         ld hl,0xa000
  83.         ld de,0xe000
  84.         ld bc,8000
  85.         ldir
  86.  
  87.         jp restore8000c000
  88. ;-------------
  89. ;------------------------------------------------------------------        
  90. ; 320x200
  91. ;left to right and right to left same time (interleave)
  92. ;mode  ????
  93. _sidas_big:
  94.         xor a
  95.         ld (mask_mode),a
  96.  
  97.         ld a,(load_buf1)
  98.         ld (src_buf1),a
  99.         ld a,(load_buf2)
  100.         ld (src_buf2),a
  101.  
  102.         ld a,1
  103.         ld (setpalflag),a
  104.         call store8000c000
  105.  
  106.  
  107.         ld hl,0x8000
  108.         ld (sidas_l1),hl
  109.         ld hl,0x8000+39
  110.         ld (sidas_r1),hl
  111.  
  112.         ld b,40
  113. _sidas_loop1      
  114.         push bc
  115.  
  116.  
  117.         ld a,(src_buf1)
  118.         SETPG8000
  119.         ld a,(user_scr0_low)
  120.         SETPGC000
  121.  
  122.  
  123.         halt
  124.  
  125.         ld hl,0
  126. sidas_l1 equ $-2        
  127.         push hl
  128.         pop de
  129.         set 6,D
  130.  
  131.         push hl
  132.         push de
  133.  
  134.         ld b,200
  135.         call _down_cpy
  136.  
  137.         pop de
  138.         pop hl
  139.         push hl
  140.  
  141.         set 5,H
  142.         set 5,D
  143.  
  144.         ld b,200
  145.         call _down_cpy
  146.  
  147.         pop  hl
  148.         inc hl
  149.         ld (sidas_l1),hl
  150.  
  151.  
  152.         ld a,(src_buf2)
  153.         SETPG8000
  154.         ld a,(user_scr0_high)
  155.         SETPGC000
  156.  
  157.         ld hl,0
  158. sidas_r1 equ $-2        
  159.         push hl
  160.         pop de
  161.         set 6,D
  162.  
  163.         set 5,H
  164.         set 5,D
  165.  
  166.         push hl
  167.         push de
  168.  
  169.         ld b,200
  170.         call _down_cpy
  171.  
  172.         pop de
  173.         pop hl
  174.         push hl
  175.  
  176.         res 5,H
  177.         res 5,D
  178.  
  179.         ld b,200
  180.         call _down_cpy
  181.  
  182.         pop  hl
  183.         dec hl
  184.         ld (sidas_r1),hl
  185.  
  186.  
  187.         pop bc
  188.         dec b
  189.         jp nz,_sidas_loop1
  190.  
  191.         jp restore8000c000
  192. ;------------------------------------------------------------------        
  193. ;------------------------------------------------------------------        
  194. ;copy image to screen by mask (9 color in palette is mask)
  195. _iob_byte:
  196.         ld a,(de)
  197.         cp 0b11000000   ;double transparent bytes
  198.         jr z,_iob_next_b
  199.         push af
  200.         and 0b10111000
  201.         cp  0b10000000
  202.         jr z,_iob_left_transparent
  203.         pop  af
  204.         push af
  205.         and 0b01000111
  206.         cp  0b01000000
  207.         jr z,_iob_right_transparent
  208.         pop af
  209.         ld (hl),a; all solid. copy
  210. _iob_next_b
  211.         ret        
  212.  
  213. _iob
  214. _iob_loop        
  215.         call _iob_byte
  216.         inc de
  217.         inc hl
  218.         dec bc
  219.         ld a,b
  220.         or c
  221.         jr nz,_iob_loop
  222.         ret
  223. _iob_left_transparent
  224.         ld a,0b10111000 ;
  225.         and (hl)
  226.         ld (hl),a
  227.         pop af
  228.         and 0b01000111
  229.         or (hl)
  230.         ld (hl),a
  231.         jr _iob_next_b
  232. _iob_right_transparent
  233.         ld a,0b01000111
  234.         and (hl)
  235.         ld (hl),a
  236.         pop af
  237.         and 0b10111000
  238.         or (hl)
  239.         ld (hl),a
  240.         jr _iob_next_b  
  241. ;----------------------------------------
  242. mask_mode db 0
  243. _sprite_output_mask_no_pal:
  244.         ld a,1
  245.         jr _sprite_output_o
  246. sprite_output_no_pal:
  247.         xor a
  248. _sprite_output_o:        
  249.         ld (mask_mode),a
  250.  
  251.         ld a,(scr_buf1)
  252.         ld (src_buf1),a
  253.         ld a,(scr_buf2)
  254.         ld (src_buf2),a
  255.  
  256.         jr _mb_output
  257. _memory_output_mask:
  258.         ld a,1
  259.         jr _memory_output_o
  260. _memory_output:
  261.         xor a
  262. _memory_output_o:        
  263.         ld (mask_mode),a
  264.  
  265.         ld a,(mem_buf1)
  266.         ld (src_buf1),a
  267.         ld a,(mem_buf2)
  268.         ld (src_buf2),a
  269.  
  270.         ld hl,mempal
  271.         ld de,pal
  272.         ld bc,32
  273.         ldir            ;copy palette for image in membuf
  274.  
  275.         jr _mb_output
  276. _2ndscreen_output:
  277.         xor a
  278.         ld (mask_mode),a
  279.         ld a,(user_scr1_low)
  280.         ld (src_buf1),a
  281.         ld a,(user_scr1_high)
  282.         ld (src_buf2),a
  283.         jr _mb_output
  284. _buffer_output_mask:
  285.         ld a,1
  286.         jr _buffer_output_o
  287. _buffer_output
  288.         xor a
  289. _buffer_output_o:        
  290.         ld (mask_mode),a
  291. _buffer_output_op:              
  292.         ld a,(load_buf1)
  293.         ld (src_buf1),a
  294.         ld a,(load_buf2)
  295.         ld (src_buf2),a
  296. _mb_output:
  297.         ld a,0
  298. outtyp equ $-1
  299.         cp 0
  300.         jp z,_immed
  301.         cp 4
  302.         jp z,_sidas
  303.         cp 5
  304.         jp z,_jaluzi
  305.         cp 6
  306.         jp z,_sidas
  307.         cp 7
  308.         jp z,_cntsds
  309.         cp 8
  310.         jp z,_dn_up
  311.         cp 9
  312.         jp z,_immed
  313.         cp 10
  314.         jp z,_jaluzi
  315.         cp 11
  316.         jp z,_lftrgt
  317.         cp 12
  318.         jp z,_cntsds_r
  319.         cp 13
  320.         jp z,_ud_nd
  321.         jp _jaluzi
  322. ;------------------------------------------------------------------        
  323. ; 240x148
  324. ;mode 0x32
  325. _immed:
  326.         ld a,1
  327.         ld (setpalflag),a
  328.         call store8000c000
  329.  
  330.  
  331.         halt
  332.         ld a,(src_buf1)
  333.         SETPG8000
  334.         ld a,(user_scr0_low)
  335.         SETPGC000
  336.  
  337.         ld hl,0x8005
  338.         ld b,148
  339. _immed_v1:
  340.         push bc
  341.         push hl
  342.         pop de
  343.  
  344.         ex de,hl
  345.         set 6,h
  346.         ld bc,320
  347.         add hl,bc
  348.         ex de,hl
  349.  
  350.         call _ldi_30
  351.         ld bc,10
  352.         add hl,bc
  353.         pop bc
  354.         djnz _immed_v1
  355.  
  356.  
  357.  
  358.         halt
  359.         ld a,(src_buf2)
  360.         SETPG8000
  361.         ld a,(user_scr0_high)
  362.         SETPGC000
  363.  
  364.         ld hl,0x8005
  365.         ld b,148
  366. _immed_v2:
  367.         push bc
  368.         push hl
  369.         pop de
  370.  
  371.         ex de,hl
  372.         set 6,h
  373.         ld bc,320
  374.         add hl,bc
  375.         ex de,hl
  376.  
  377.         call _ldi_30
  378.         ld bc,10
  379.         add hl,bc
  380.         pop bc
  381.         djnz _immed_v2
  382.  
  383.         halt
  384.         ld a,(src_buf1)
  385.         SETPG8000
  386.         ld a,(user_scr0_low)
  387.         SETPGC000
  388.  
  389.         ld hl,0xa005
  390.         ld b,148
  391. _immed_v3:
  392.         push bc
  393.         push hl
  394.         pop de
  395.  
  396.         ex de,hl
  397.         set 6,h
  398.         ld bc,320
  399.         add hl,bc
  400.         ex de,hl
  401.  
  402.         call _ldi_30
  403.         ld bc,10
  404.         add hl,bc
  405.         pop bc
  406.         djnz _immed_v3
  407.  
  408.         halt
  409.         ld a,(src_buf2)
  410.         SETPG8000
  411.         ld a,(user_scr0_high)
  412.         SETPGC000        
  413.  
  414.         ld hl,0xa005
  415.         ld b,148
  416. _immed_v4:
  417.         push bc
  418.         push hl
  419.         pop de
  420.  
  421.         ex de,hl
  422.         set 6,h
  423.         ld bc,320
  424.         add hl,bc
  425.         ex de,hl
  426.  
  427.         call _ldi_30
  428.         ld bc,10
  429.         add hl,bc
  430.         pop bc
  431.         djnz _immed_v4
  432.         jp restore8000c000
  433.  
  434. ;------------------------------------------------------------------        
  435. _ldi_30
  436.         ld a,(mask_mode)
  437.         and a
  438.         jr nz,_ldi_30_iob
  439.         dup 30
  440.         ldi
  441.         edup
  442.         ret
  443. _ldi_30_iob
  444.         ex de,hl
  445.         dup 30
  446.         call _iob_byte
  447.         inc hl
  448.         inc de
  449.         edup
  450.         ex de,hl
  451.         ret
  452. ;----
  453. ;hl-src de-dest b,counter
  454. _down_cpy:
  455.         ld a,(mask_mode)
  456.         and a
  457.         jr nz,_down_cpy_iob
  458.  
  459.         push bc
  460.         ld a,(hl)
  461.         ld (de),a
  462.         call DHL
  463.         ex de,hl
  464.         call DHL
  465.         ex de,hl
  466.         pop bc
  467.         djnz _down_cpy
  468.         ret
  469. _down_cpy_iob:
  470.         push bc
  471.  
  472.         ex de,hl
  473.         call _iob_byte
  474.         ex de,hl
  475.  
  476.         call DHL
  477.         ex de,hl
  478.         call DHL
  479.         ex de,hl
  480.         pop bc
  481.         djnz _down_cpy
  482.         ret
  483. ;------------------------------------------------------------------        
  484. ; 240x148
  485. ;left to right
  486. ;mode  ????? ;0x3d
  487. _lftrgt:
  488.         ld a,1
  489.         ld (setpalflag),a
  490.         call store8000c000
  491.  
  492.  
  493.         ld hl,0x8005
  494.  
  495.         ld b,30
  496. _lftrgt_loop        
  497.         push bc
  498.  
  499.         push hl
  500.         pop de
  501.  
  502.         ex de,hl
  503.         set 6,h
  504.         ld bc,320
  505.         add hl,bc
  506.         ex de,hl
  507.  
  508.  
  509.         push hl
  510.         push de
  511.  
  512.         halt
  513.         ld a,(src_buf1)
  514.         SETPG8000
  515.         ld a,(user_scr0_low)
  516.         SETPGC000
  517.  
  518.  
  519.         ld b,148
  520.         call _down_cpy
  521.  
  522.         pop de
  523.         pop hl
  524.         push hl
  525.         push de
  526.  
  527.         halt
  528.         ld a,(src_buf2)
  529.         SETPG8000
  530.         ld a,(user_scr0_high)
  531.         SETPGC000
  532.  
  533.         ld b,148
  534.         call _down_cpy
  535.  
  536.  
  537.         pop de
  538.         pop hl
  539.  
  540.         set 5,H
  541.         set 5,D
  542.  
  543.         push hl
  544.         push de
  545.  
  546.         halt
  547.         ld a,(src_buf1)
  548.         SETPG8000
  549.         ld a,(user_scr0_low)
  550.         SETPGC000
  551.  
  552.  
  553.         ld b,148
  554.         call _down_cpy
  555.  
  556.         pop de
  557.         pop hl
  558.         push hl
  559.         push de
  560.  
  561.         halt
  562.         ld a,(src_buf2)
  563.         SETPG8000
  564.         ld a,(user_scr0_high)
  565.         SETPGC000
  566.  
  567.         ld b,148
  568.         call _down_cpy
  569.  
  570.         pop de
  571.         pop hl
  572.         res 5,h
  573.         inc hl
  574.  
  575.  
  576.         pop bc
  577.         dec b
  578.         jp nz,_lftrgt_loop
  579.  
  580.         jp restore8000c000
  581. ;------------------------------------------------------------------        
  582. ; 240x148
  583. ;left to right and right to left same time (interleave)
  584. ;mode  ????
  585. _sidas:
  586.         ld a,1
  587.         ld (setpalflag),a
  588.         call store8000c000
  589.  
  590.  
  591.         ld hl,0x8005
  592.         ld (sidas_l),hl
  593.         ld hl,0x8005+29
  594.         ld (sidas_r),hl
  595.  
  596.         ld b,30
  597. _sidas_loop        
  598.         push bc
  599.  
  600.  
  601.         ld a,(src_buf1)
  602.         SETPG8000
  603.         ld a,(user_scr0_low)
  604.         SETPGC000
  605.  
  606.  
  607.         halt
  608.  
  609.         ld hl,0
  610. sidas_l equ $-2        
  611.         push hl
  612.         pop de
  613.  
  614.         ex de,hl
  615.         set 6,h
  616.         ld bc,320
  617.         add hl,bc
  618.         ex de,hl
  619.  
  620.         push hl
  621.         push de
  622.  
  623.         ld b,148
  624.         call _down_cpy
  625.  
  626.         pop de
  627.         pop hl
  628.         push hl
  629.  
  630.         set 5,H
  631.         set 5,D
  632.  
  633.         ld b,148
  634.         call _down_cpy
  635.  
  636.         pop  hl
  637.         inc hl
  638.         ld (sidas_l),hl
  639.  
  640.  
  641.         ld a,(src_buf2)
  642.         SETPG8000
  643.         ld a,(user_scr0_high)
  644.         SETPGC000
  645.  
  646.         ld hl,0
  647. sidas_r equ $-2        
  648.         push hl
  649.         pop de
  650.  
  651.         ex de,hl
  652.         set 6,h
  653.         ld bc,320
  654.         add hl,bc
  655.         ex de,hl
  656.  
  657.         set 5,H
  658.         set 5,D
  659.  
  660.         push hl
  661.         push de
  662.  
  663.         ld b,148
  664.         call _down_cpy
  665.  
  666.         pop de
  667.         pop hl
  668.         push hl
  669.  
  670.         res 5,H
  671.         res 5,D
  672.  
  673.         ld b,148
  674.         call _down_cpy
  675.  
  676.         pop  hl
  677.         dec hl
  678.         ld (sidas_r),hl
  679.  
  680.  
  681.         pop bc
  682.         dec b
  683.         jp nz,_sidas_loop
  684.  
  685.         jp restore8000c000
  686. ;------------------------------------------------------------------        
  687. ; 240x148
  688. ;top to middle and bottom to middle same time
  689. ;mode ???
  690. _ud_nd:
  691.         ld a,1
  692.         ld (setpalflag),a
  693.         call store8000c000
  694.  
  695.  
  696.         ld hl,0x8005
  697.         ld (_ud_nd_top),hl
  698.         ld hl,0x8005+(147*40)
  699.         ld (_ud_nd_btm),hl
  700.  
  701.  
  702.         ld b,148/2 ;160/2
  703. _ud_nd_loop:        
  704.         halt
  705.         push bc
  706.  
  707.  
  708.  
  709.         ld a,(src_buf1)
  710.         SETPG8000
  711.         ld a,(user_scr0_low)
  712.         SETPGC000
  713.  
  714.  
  715.         ld hl,0
  716. _ud_nd_top: equ $-2
  717.  
  718.         push hl
  719.         pop de        
  720.  
  721.         ex de,hl
  722.         set 6,h
  723.         ld bc,320
  724.         add hl,bc
  725.         ex de,hl
  726.  
  727.         push hl
  728.         push de
  729.  
  730.         call _ldi_30
  731.  
  732.         pop de
  733.         pop hl
  734.  
  735.  
  736.         set 5,h
  737.         set 5,d
  738.  
  739.         call _ldi_30
  740.  
  741.         ld hl,0
  742. _ud_nd_btm: equ $-2
  743.  
  744.         push hl
  745.         pop de        
  746.  
  747.         ex de,hl
  748.         set 6,h
  749.         ld bc,320
  750.         add hl,bc
  751.         ex de,hl
  752.  
  753.         push hl
  754.         push de
  755.  
  756.         call _ldi_30
  757.  
  758.         pop de
  759.         pop hl
  760.  
  761.  
  762.         set 5,h
  763.         set 5,d
  764.  
  765.         call _ldi_30
  766.  
  767.         ld a,(src_buf2)
  768.         SETPG8000
  769.         ld a,(user_scr0_high)
  770.         SETPGC000
  771.  
  772.  
  773.         ld hl,(_ud_nd_top)
  774.  
  775.         push hl
  776.         pop de        
  777.  
  778.         ex de,hl
  779.         set 6,h
  780.         ld bc,320
  781.         add hl,bc
  782.         ex de,hl
  783.  
  784.         push hl
  785.         push de
  786.  
  787.         call _ldi_30
  788.  
  789.         pop de
  790.         pop hl
  791.         push hl
  792.  
  793.         set 5,h
  794.         set 5,d
  795.  
  796.         call _ldi_30
  797.  
  798.         pop hl
  799.         call DHL
  800.         ld (_ud_nd_top),hl
  801.  
  802.         ld hl,(_ud_nd_btm)
  803.  
  804.         push hl
  805.         pop de        
  806.  
  807.         ex de,hl
  808.         set 6,h
  809.         ld bc,320
  810.         add hl,bc
  811.         ex de,hl
  812.  
  813.         push hl
  814.         push de
  815.  
  816.         call _ldi_30
  817.  
  818.         pop de
  819.         pop hl
  820.  
  821.         push hl
  822.         set 5,h
  823.         set 5,d
  824.  
  825.         call _ldi_30
  826.  
  827.         pop hl
  828.         call UPHL
  829.         ld (_ud_nd_btm),hl
  830.  
  831.  
  832.         pop bc
  833.         dec b
  834.         jp nz,_ud_nd_loop
  835.  
  836.         jp restore8000c000
  837. ;------------------------------------------------------------------              
  838. ; 240x148
  839. ;from center up and down same time
  840. ;mode 0x3a
  841. _dn_up:
  842.         ld a,1
  843.         ld (setpalflag),a
  844.         call store8000c000
  845.  
  846.  
  847.         ld hl,0x8005+(74*40)
  848.         ld (_dn_up_top),hl
  849.         ld hl,0x8005+(73*40)
  850.         ld (_dn_up_btm),hl
  851.  
  852.  
  853.         ld b,74 ;148/2
  854. _dn_up_loop:        
  855.         halt
  856.         push bc
  857.  
  858.  
  859.  
  860.         ld a,(src_buf1)
  861.         SETPG8000
  862.         ld a,(user_scr0_low)
  863.         SETPGC000
  864.  
  865.  
  866.         ld hl,0
  867. _dn_up_top: equ $-2
  868.  
  869.         push hl
  870.         pop de        
  871.  
  872.         ex de,hl
  873.         set 6,h
  874.         ld bc,320
  875.         add hl,bc
  876.         ex de,hl
  877.  
  878.         push hl
  879.         push de
  880.  
  881.         call _ldi_30
  882.  
  883.         pop de
  884.         pop hl
  885.  
  886.  
  887.         set 5,h
  888.         set 5,d
  889.  
  890.         call _ldi_30
  891.  
  892.         ld hl,0
  893. _dn_up_btm: equ $-2
  894.  
  895.         push hl
  896.         pop de        
  897.  
  898.         ex de,hl
  899.         set 6,h
  900.         ld bc,320
  901.         add hl,bc
  902.         ex de,hl
  903.  
  904.         push hl
  905.         push de
  906.  
  907.         call _ldi_30
  908.  
  909.         pop de
  910.         pop hl
  911.  
  912.  
  913.         set 5,h
  914.         set 5,d
  915.  
  916.         call _ldi_30
  917.  
  918.         ld a,(src_buf2)
  919.         SETPG8000
  920.         ld a,(user_scr0_high)
  921.         SETPGC000
  922.  
  923.  
  924.         ld hl,(_dn_up_top)
  925.  
  926.         push hl
  927.         pop de        
  928.  
  929.         ex de,hl
  930.         set 6,h
  931.         ld bc,320
  932.         add hl,bc
  933.         ex de,hl
  934.  
  935.         push hl
  936.         push de
  937.  
  938.         call _ldi_30
  939.  
  940.         pop de
  941.         pop hl
  942.         push hl
  943.  
  944.         set 5,h
  945.         set 5,d
  946.  
  947.         call _ldi_30
  948.  
  949.         pop hl
  950.         call DHL
  951.         ld (_dn_up_top),hl
  952.  
  953.         ld hl,(_dn_up_btm)
  954.  
  955.         push hl
  956.         pop de        
  957.  
  958.         ex de,hl
  959.         set 6,h
  960.         ld bc,320
  961.         add hl,bc
  962.         ex de,hl
  963.  
  964.         push hl
  965.         push de
  966.  
  967.         call _ldi_30
  968.  
  969.         pop de
  970.         pop hl
  971.  
  972.         push hl
  973.         set 5,h
  974.         set 5,d
  975.  
  976.         call _ldi_30
  977.  
  978.         pop hl
  979.         call UPHL
  980.         ld (_dn_up_btm),hl
  981.  
  982.  
  983.         pop bc
  984.         dec b
  985.         jp nz,_dn_up_loop
  986.  
  987.         jp restore8000c000
  988. ;------------------------------------------------------------------        
  989. ; 240x148
  990. ;jaluzi top to bottom and bottom to top same tome interleave
  991. ;mode 0x3c
  992. _jaluzi:
  993.         ld a,1
  994.         ld (setpalflag),a
  995.         call store8000c000
  996.  
  997.  
  998.  
  999.         ld hl,0x8005
  1000.         ld (_jaluzi_top),hl
  1001.         ld hl,0x8005+(147*40)
  1002.         ld (_jaluzi_btm),hl
  1003.  
  1004.  
  1005.         ld b,74 ;148/2
  1006. _jaluzi_loop:
  1007.         halt
  1008.         push bc
  1009.  
  1010.         ld a,(src_buf1)
  1011.         SETPG8000
  1012.         ld a,(user_scr0_low)
  1013.         SETPGC000
  1014.  
  1015.  
  1016.         ld hl,0
  1017. _jaluzi_top: equ $-2
  1018.  
  1019.         push hl
  1020.         pop de        
  1021.  
  1022.         ex de,hl
  1023.         set 6,h
  1024.         ld bc,320
  1025.         add hl,bc
  1026.         ex de,hl
  1027.  
  1028.         push hl
  1029.         push de
  1030.  
  1031.         call _ldi_30
  1032.  
  1033.         pop de
  1034.         pop hl
  1035.  
  1036.  
  1037.         set 5,h
  1038.         set 5,d
  1039.  
  1040.         call _ldi_30
  1041.  
  1042.         ld hl,0
  1043. _jaluzi_btm: equ $-2
  1044.  
  1045.         push hl
  1046.         pop de        
  1047.  
  1048.         ex de,hl
  1049.         set 6,h
  1050.         ld bc,320
  1051.         add hl,bc
  1052.         ex de,hl
  1053.  
  1054.         push hl
  1055.         push de
  1056.  
  1057.         call _ldi_30
  1058.  
  1059.         pop de
  1060.         pop hl
  1061.  
  1062.  
  1063.         set 5,h
  1064.         set 5,d
  1065.  
  1066.         call _ldi_30
  1067.  
  1068.         ld a,(src_buf2)
  1069.         SETPG8000
  1070.         ld a,(user_scr0_high)
  1071.         SETPGC000
  1072.  
  1073.  
  1074.         ld hl,(_jaluzi_top)
  1075.  
  1076.         push hl
  1077.         pop de        
  1078.  
  1079.         ex de,hl
  1080.         set 6,h
  1081.         ld bc,320
  1082.         add hl,bc
  1083.         ex de,hl
  1084.  
  1085.         push hl
  1086.         push de
  1087.  
  1088.         call _ldi_30
  1089.  
  1090.         pop de
  1091.         pop hl
  1092.         push hl
  1093.  
  1094.         set 5,h
  1095.         set 5,d
  1096.  
  1097.         call _ldi_30
  1098.  
  1099.         pop hl
  1100.         call DHL1
  1101.         ld (_jaluzi_top),hl
  1102.  
  1103.         ld hl,(_jaluzi_btm)
  1104.  
  1105.         push hl
  1106.         pop de        
  1107.  
  1108.         ex de,hl
  1109.         set 6,h
  1110.         ld bc,320
  1111.         add hl,bc
  1112.         ex de,hl
  1113.  
  1114.         push hl
  1115.         push de
  1116.  
  1117.         call _ldi_30
  1118.  
  1119.         pop de
  1120.         pop hl
  1121.  
  1122.         push hl
  1123.         set 5,h
  1124.         set 5,d
  1125.  
  1126.         call _ldi_30
  1127.  
  1128.         pop hl
  1129.         call UPHL1
  1130.         ld (_jaluzi_btm),hl
  1131.  
  1132.         pop bc
  1133.         dec b
  1134.         jp nz,_jaluzi_loop
  1135.  
  1136.         jp restore8000c000
  1137. ;------------------------------------------------------------------        
  1138. ; 240x148
  1139. ;from center to sides left and right same time
  1140. ;mode 0x39
  1141. _cntsds:
  1142.         ld a,1
  1143.         ld (setpalflag),a
  1144.         call store8000c000
  1145.  
  1146.  
  1147.         ld hl,0x8005+14  ;to left
  1148.         ld (_cntsds_lft),hl
  1149.  
  1150.         ld hl,0x8005+15 ;to right
  1151.         ld (_cntsds_rgt),hl
  1152.  
  1153.         xor a
  1154.         ld (_cntsds_fsa),a
  1155.  
  1156.  
  1157.         ld b,60  ; 256 /2 /2
  1158. _cntsds_loop:
  1159.         halt
  1160.         push bc
  1161.  
  1162.         ld hl,_cntsds_loop_end
  1163.         push hl
  1164.  
  1165.  
  1166.         ld a,0
  1167. _cntsds_fsa: equ $-1
  1168.         and a
  1169.         jp z,_cntsds_f0
  1170.         cp 1
  1171.         jp z,_cntsds_f1
  1172.         cp 2
  1173.         jp z,_cntsds_f2
  1174.         cp 3
  1175.         jp z,_cntsds_f3
  1176.  
  1177.  
  1178. _cntsds_loop_end:
  1179.         ld a,(_cntsds_fsa)
  1180.         inc a
  1181.         and 3
  1182.         ld (_cntsds_fsa),a
  1183.         pop bc
  1184.         dec b
  1185.         jp nz,_cntsds_loop
  1186.  
  1187.  
  1188.         jp restore8000c000
  1189.  
  1190. ;----
  1191. _cntsds_f0:
  1192.         ld a,(src_buf2)
  1193.         SETPG8000
  1194.         ld a,(user_scr0_high)
  1195.         SETPGC000
  1196.  
  1197.         ld hl,0
  1198. _cntsds_lft: equ $-2
  1199.         push hl
  1200.         pop de
  1201.  
  1202.         ex de,hl
  1203.         set 6,h
  1204.         ld bc,320
  1205.         add hl,bc
  1206.         ex de,hl
  1207.  
  1208.         set 5,h
  1209.         set 5,d
  1210.  
  1211.         ld b,148
  1212.         call _down_cpy
  1213.  
  1214.         ld a,(src_buf1)
  1215.         SETPG8000
  1216.         ld a,(user_scr0_low)
  1217.         SETPGC000
  1218.  
  1219.         ld hl,0
  1220. _cntsds_rgt: equ $-2
  1221.         push hl
  1222.         pop de
  1223.  
  1224.         ex de,hl
  1225.         set 6,h
  1226.         ld bc,320
  1227.         add hl,bc
  1228.         ex de,hl
  1229.  
  1230.         ld b,148
  1231.         jp _down_cpy
  1232.  
  1233.  
  1234. ;----
  1235. _cntsds_f2:
  1236.         ld a,(src_buf2)
  1237.         SETPG8000
  1238.         ld a,(user_scr0_high)
  1239.         SETPGC000
  1240.  
  1241.         ld hl,(_cntsds_lft)
  1242.         push hl
  1243.         pop de
  1244.  
  1245.         ex de,hl
  1246.         set 6,h
  1247.         ld bc,320
  1248.         add hl,bc
  1249.         ex de,hl
  1250.  
  1251.         ld b,148
  1252.         call _down_cpy
  1253.  
  1254.         ld a,(src_buf1)
  1255.         SETPG8000
  1256.         ld a,(user_scr0_low)
  1257.         SETPGC000
  1258.  
  1259.         ld hl,(_cntsds_rgt)
  1260.         push hl
  1261.         pop de
  1262.  
  1263.         ex de,hl
  1264.         set 6,h
  1265.         ld bc,320
  1266.         add hl,bc
  1267.         ex de,hl
  1268.  
  1269.         set 5,h
  1270.         set 5,d
  1271.  
  1272.         ld b,148
  1273.         jp _down_cpy
  1274.  
  1275.  
  1276. ;----
  1277. _cntsds_f1:
  1278.         ld a,(src_buf1)
  1279.         SETPG8000
  1280.         ld a,(user_scr0_low)
  1281.         SETPGC000
  1282.  
  1283.         ld hl,(_cntsds_lft)
  1284.         push hl
  1285.         pop de
  1286.  
  1287.         ex de,hl
  1288.         set 6,h
  1289.         ld bc,320
  1290.         add hl,bc
  1291.         ex de,hl
  1292.  
  1293.         set 5,h
  1294.         set 5,d
  1295.  
  1296.         ld b,148
  1297.         call _down_cpy
  1298.  
  1299.         ld a,(src_buf2)
  1300.         SETPG8000
  1301.         ld a,(user_scr0_high)
  1302.         SETPGC000
  1303.  
  1304.         ld hl,(_cntsds_rgt)
  1305.         push hl
  1306.         pop de
  1307.  
  1308.         ex de,hl
  1309.         set 6,h
  1310.         ld bc,320
  1311.         add hl,bc
  1312.         ex de,hl
  1313.  
  1314.         ld b,148
  1315.         jp _down_cpy
  1316. ;----
  1317. _cntsds_f3:
  1318.         ld a,(src_buf1)
  1319.         SETPG8000
  1320.         ld a,(user_scr0_low)
  1321.         SETPGC000
  1322.  
  1323.         ld hl,(_cntsds_lft)
  1324.         push hl
  1325.         push hl
  1326.         pop de
  1327.  
  1328.         ex de,hl
  1329.         set 6,h
  1330.         ld bc,320
  1331.         add hl,bc
  1332.         ex de,hl
  1333.  
  1334.         ld b,148
  1335.         call _down_cpy
  1336.  
  1337.         pop hl
  1338.         dec hl
  1339.         ld (_cntsds_lft),hl
  1340.  
  1341.         ld a,(src_buf2)
  1342.         SETPG8000
  1343.         ld a,(user_scr0_high)
  1344.         SETPGC000
  1345.  
  1346.         ld hl,(_cntsds_rgt)
  1347.         push hl
  1348.         push hl
  1349.         pop de
  1350.  
  1351.         ex de,hl
  1352.         set 6,h
  1353.         ld bc,320
  1354.         add hl,bc
  1355.         ex de,hl
  1356.  
  1357.         set 5,h
  1358.         set 5,d
  1359.  
  1360.  
  1361.         ld b,148
  1362.         call _down_cpy
  1363.  
  1364.         pop hl
  1365.         inc hl
  1366.         ld (_cntsds_rgt),hl
  1367.         ret
  1368. ;------------------------------------------------------------------        
  1369. ; 240x148
  1370. ;from sides left and right  to center same time
  1371. ;mode 0x39
  1372. _cntsds_r:
  1373.         ld a,1
  1374.         ld (setpalflag),a
  1375.         call store8000c000
  1376.  
  1377.  
  1378.         ld hl,0x8005  ;to left
  1379.         ld (_cntsds_lft_r),hl
  1380.  
  1381.         ld hl,0x8005+29 ;to right
  1382.         ld (_cntsds_rgt_r),hl
  1383.  
  1384.         xor a
  1385.         ld (_cntsds_fsa_r),a
  1386.  
  1387.  
  1388.         ld b,64  ; 256 /2 /2
  1389. _cntsds_loop_r:
  1390.         halt
  1391.         push bc
  1392.  
  1393.         ld hl,_cntsds_loop_end_r
  1394.         push hl
  1395.  
  1396.  
  1397.         ld a,0
  1398. _cntsds_fsa_r: equ $-1
  1399.         and a
  1400.         jp z,_cntsds_f3_r
  1401.         cp 1
  1402.         jp z,_cntsds_f2_r
  1403.         cp 2
  1404.         jp z,_cntsds_f1_r
  1405.         cp 3
  1406.         jp z,_cntsds_f0_r
  1407.  
  1408.  
  1409. _cntsds_loop_end_r:
  1410.         ld a,(_cntsds_fsa_r)
  1411.         inc a
  1412.         and 3
  1413.         ld (_cntsds_fsa_r),a
  1414.         pop bc
  1415.         dec b
  1416.         jp nz,_cntsds_loop_r
  1417.  
  1418.  
  1419.         jp restore8000c000
  1420.  
  1421. ;----
  1422. _cntsds_f0_r:
  1423.         ld a,(src_buf2)
  1424.         SETPG8000
  1425.         ld a,(user_scr0_high)
  1426.         SETPGC000
  1427.  
  1428.         ld hl,0
  1429. _cntsds_lft_r: equ $-2
  1430.         push hl
  1431.         push hl
  1432.         pop de
  1433.  
  1434.         ex de,hl
  1435.         set 6,h
  1436.         ld bc,320
  1437.         add hl,bc
  1438.         ex de,hl
  1439.  
  1440.         set 5,h
  1441.         set 5,d
  1442.  
  1443.         ld b,148
  1444.         call _down_cpy
  1445.  
  1446.         pop hl
  1447.         inc hl
  1448.         ld (_cntsds_lft_r),hl
  1449.  
  1450.         ld a,(src_buf1)
  1451.         SETPG8000
  1452.         ld a,(user_scr0_low)
  1453.         SETPGC000
  1454.  
  1455.         ld hl,0
  1456. _cntsds_rgt_r: equ $-2
  1457.  
  1458.         push hl
  1459.         push hl
  1460.         pop de
  1461.  
  1462.         ex de,hl
  1463.         set 6,h
  1464.         ld bc,320
  1465.         add hl,bc
  1466.         ex de,hl
  1467.  
  1468.         ld b,148
  1469.         call _down_cpy
  1470.         pop hl
  1471.         dec hl
  1472.         ld (_cntsds_rgt_r),hl
  1473.         ret
  1474.  
  1475.  
  1476. ;----
  1477. _cntsds_f2_r:
  1478.         ld a,(src_buf2)
  1479.         SETPG8000
  1480.         ld a,(user_scr0_high)
  1481.         SETPGC000
  1482.  
  1483.         ld hl,(_cntsds_lft_r)
  1484.         push hl
  1485.         pop de
  1486.  
  1487.         ex de,hl
  1488.         set 6,h
  1489.         ld bc,320
  1490.         add hl,bc
  1491.         ex de,hl
  1492.  
  1493.         ld b,148
  1494.         call _down_cpy
  1495.  
  1496.         ld a,(src_buf1)
  1497.         SETPG8000
  1498.         ld a,(user_scr0_low)
  1499.         SETPGC000
  1500.  
  1501.         ld hl,(_cntsds_rgt_r)
  1502.         push hl
  1503.         pop de
  1504.  
  1505.         ex de,hl
  1506.         set 6,h
  1507.         ld bc,320
  1508.         add hl,bc
  1509.         ex de,hl
  1510.  
  1511.         set 5,h
  1512.         set 5,d
  1513.  
  1514.         ld b,148
  1515.         jp _down_cpy
  1516.  
  1517.  
  1518. ;----
  1519. _cntsds_f1_r:
  1520.         ld a,(src_buf1)
  1521.         SETPG8000
  1522.         ld a,(user_scr0_low)
  1523.         SETPGC000
  1524.  
  1525.         ld hl,(_cntsds_lft_r)
  1526.         push hl
  1527.         pop de
  1528.  
  1529.         ex de,hl
  1530.         set 6,h
  1531.         ld bc,320
  1532.         add hl,bc
  1533.         ex de,hl
  1534.  
  1535.         set 5,h
  1536.         set 5,d
  1537.  
  1538.         ld b,148
  1539.         call _down_cpy
  1540.  
  1541.         ld a,(src_buf2)
  1542.         SETPG8000
  1543.         ld a,(user_scr0_high)
  1544.         SETPGC000
  1545.  
  1546.         ld hl,(_cntsds_rgt_r)
  1547.         push hl
  1548.         pop de
  1549.  
  1550.         ex de,hl
  1551.         set 6,h
  1552.         ld bc,320
  1553.         add hl,bc
  1554.         ex de,hl
  1555.  
  1556.         ld b,148
  1557.         jp _down_cpy
  1558. ;----
  1559. _cntsds_f3_r:
  1560.         ld a,(src_buf1)
  1561.         SETPG8000
  1562.         ld a,(user_scr0_low)
  1563.         SETPGC000
  1564.  
  1565.         ld hl,(_cntsds_lft_r)
  1566.         push hl
  1567.         pop de
  1568.  
  1569.         ex de,hl
  1570.         set 6,h
  1571.         ld bc,320
  1572.         add hl,bc
  1573.         ex de,hl
  1574.  
  1575.         ld b,148
  1576.         call _down_cpy
  1577.  
  1578.         ld a,(src_buf2)
  1579.         SETPG8000
  1580.         ld a,(user_scr0_high)
  1581.         SETPGC000
  1582.  
  1583.         ld hl,(_cntsds_rgt_r)
  1584.  
  1585.         push hl
  1586.         pop de
  1587.  
  1588.         ex de,hl
  1589.         set 6,h
  1590.         ld bc,320
  1591.         add hl,bc
  1592.         ex de,hl
  1593.  
  1594.         set 5,h
  1595.         set 5,d
  1596.  
  1597.  
  1598.         ld b,148
  1599.         jp _down_cpy
  1600. ;------------------------------------------------------------------  
  1601. _pradd2
  1602.         LD (CORDS),BC
  1603.         SRL     C
  1604.         SBC     A
  1605.         AND %00100000
  1606.         LD      (.M111),A
  1607.  
  1608.         PUSH HL
  1609.         LD H,#C0
  1610.         LD A,H
  1611.         OR 0
  1612. .M111    EQU $-1
  1613.         LD H,A
  1614.  
  1615.         LD A,C
  1616. ;        ADD A,4
  1617.         LD L,A
  1618.  
  1619.         ld a,b
  1620.         and a
  1621.         jr z,.skip
  1622.         LD DE,320
  1623. .pradd_l:        
  1624.         ADD HL,DE
  1625.         DJNZ .pradd_l
  1626. .skip
  1627.         LD (COORDS),HL
  1628.         POP HL
  1629.         RET        
  1630. ;------------------------------------------------------------------  
  1631. _pradd_p:
  1632.         LD (CORDS_P),BC
  1633.         SRL     C
  1634.         SBC     A
  1635.         AND %00100000
  1636.         LD      (.M111),A
  1637.  
  1638.         PUSH HL
  1639.         LD H,#80
  1640.         LD A,H
  1641.         OR 0
  1642. .M111    EQU $-1
  1643.         LD H,A
  1644.  
  1645.         LD A,C
  1646.         ADD A,4
  1647.         LD L,A
  1648.  
  1649.         ld a,b
  1650.         and a
  1651.         jr z,.skip
  1652.         LD DE,320
  1653. .pradd_l:        
  1654.         ADD HL,DE
  1655.         DJNZ .pradd_l
  1656. .skip
  1657.         LD (COORDS_P),HL
  1658.         POP HL
  1659.         RET        
  1660.  
  1661.  
  1662. _pradd_p2:
  1663.         LD (CORDS_P),BC
  1664.         SRL     C
  1665.         SBC     A
  1666.         AND %00100000
  1667.         LD      (.M111),A
  1668.  
  1669.         PUSH HL
  1670.         LD H,#80
  1671.         LD A,H
  1672.         OR 0
  1673. .M111    EQU $-1
  1674.         LD H,A
  1675.  
  1676.         LD A,C
  1677.         ADD A,4
  1678.         LD L,A
  1679.  
  1680.         ld a,b
  1681.         and a
  1682.         jr z,.skip
  1683.         LD DE,320
  1684. .pradd_l:        
  1685.         ADD HL,DE
  1686.         DJNZ .pradd_l
  1687. .skip
  1688.         ld de,160+320
  1689.         add hl,de
  1690.         LD (COORDS_P),HL
  1691.         POP HL
  1692.         RET        
  1693. ;------------------------------------------------------------------  
  1694. ;in B - y C-x
  1695. ;out   set coordinates for TYPE
  1696.  
  1697. _pradd
  1698.         LD (CORDS),BC
  1699.         SRL     C
  1700.         SBC     A
  1701.         AND %00100000
  1702.         LD      (M111),A
  1703.  
  1704.         PUSH HL
  1705.         LD H,#C0
  1706.         LD A,H
  1707.         OR 0
  1708. M111    EQU $-1
  1709.         LD H,A
  1710.  
  1711.         LD A,C
  1712.         ADD A,4
  1713.         LD L,A
  1714.  
  1715.         LD DE,320
  1716. pradd_l:        
  1717.         ADD HL,DE
  1718.         DJNZ pradd_l
  1719.         ld de,160+320
  1720.         add hl,de
  1721.         LD (COORDS),HL
  1722.         POP HL
  1723.         RET        
  1724. ;---------------        
  1725. ;in A - char to print
  1726. _type
  1727.         ld de,0
  1728. COORDS  equ $-2        
  1729.         ld h,0
  1730.         ld l,a
  1731. M10:
  1732.         ld bc,FONT
  1733.         add hl,hl
  1734.         add hl,hl
  1735.         add hl,hl
  1736.         add hl,hl
  1737.         add hl,bc ;hl addr in FONT
  1738.  
  1739.  ;       ex de,hl
  1740.         push de
  1741.         push hl
  1742.         call setfontpage
  1743.         pop hl
  1744.         ld de,font_buf
  1745.         ld bc,16
  1746.         ldir
  1747.         call unsetfontpage
  1748.  
  1749.  
  1750.         pop hl
  1751.  
  1752.         ld de,font_buf
  1753.         push hl
  1754.         ld a,(user_scr0_low)
  1755.         SETPGC000
  1756.         ld b,8
  1757. _ppnz2:
  1758.         push bc
  1759.         ld a,(de)
  1760. clr1   dw 0
  1761.         ld (hl),a
  1762.         inc de
  1763.         ld bc,40
  1764.         add hl,bc
  1765.         pop bc
  1766.         djnz _ppnz2
  1767.         pop hl
  1768.  
  1769.         push hl
  1770.         ld a,(user_scr0_high)
  1771.         SETPGC000
  1772.         ld b,8
  1773. _ppnz3:
  1774.         push bc
  1775.         ld a,(de)
  1776. clr2   dw 0
  1777.         ld (hl),a
  1778.         inc de
  1779.         ld bc,40
  1780.         add hl,bc
  1781.         pop bc
  1782.         djnz _ppnz3
  1783.         pop hl
  1784.  
  1785.         ld a,h
  1786.         xor 0x20
  1787.         bit 5,h
  1788.         ld h,a
  1789.         jr z,_ppnz4:
  1790.         inc hl
  1791.  
  1792. _ppnz4:        
  1793.         ld (COORDS),hl
  1794.         ld bc,(CORDS)
  1795.         inc c
  1796.         ld (CORDS),bc
  1797.  
  1798.         ret ;////// disable auto CR
  1799.  
  1800.         ld a,c
  1801.         cp 64
  1802.         ret c
  1803.  
  1804.         inc b
  1805.         ld c,0
  1806.         jp _pradd
  1807.  
  1808. UPHL1   CALL UPHL
  1809. UPHL
  1810.         PUSH BC
  1811.         LD BC,40
  1812.         AND A
  1813.         SBC HL,BC
  1814.         POP BC
  1815.         RET
  1816.  
  1817.  
  1818. DHL1    CALL DHL
  1819. DHL
  1820.         PUSH BC
  1821.         LD BC,40
  1822.         ADD HL,BC
  1823.         POP BC
  1824.         RET
  1825.  
  1826. ;;;;;;;;;;;;;;;;;;;;;;;
  1827. prcharprop_shch
  1828.         ;ld a,'Щ'
  1829.         call prcharprop_do
  1830.         ld a,255
  1831.         jr prcharprop_do
  1832.  
  1833. _type_p:
  1834.         ld hl,0
  1835. COORDS_P equ $-2
  1836. prcharprop_do
  1837. ;print with proportional font (any char width)
  1838. ;hl=screen addr
  1839. ;c=phase (even=left, odd=right pixel)
  1840. ;a=char
  1841.        push hl
  1842.  
  1843.         call setfontpage
  1844.  
  1845.         ld l,a
  1846.         ld h,FONT2/256  ;propfont
  1847.         ld de,font_buf  ;chardata
  1848. ;1. copy char data
  1849. ;shift 1 pix right if needed
  1850.         bit 0,c
  1851.         jr z,prcharprop_copyfontnoscroll
  1852.         dup 7
  1853.         ld a,(hl)
  1854.         rrca
  1855.         ld (de),a
  1856.         inc h
  1857.         inc e
  1858.         edup
  1859.         ld a,(hl)
  1860.         rrca
  1861.         jp prcharprop_copyfontq
  1862. prcharprop_copyfontnoscroll
  1863.         dup 7
  1864.         ld a,(hl)
  1865.         ld (de),a
  1866.         inc h
  1867.         inc e
  1868.         edup
  1869.         ld a,(hl)
  1870. prcharprop_copyfontq
  1871.         ld (de),a
  1872.         inc h
  1873.         ld b,(hl) ;charwidth
  1874.         ld a,c ;phase
  1875.         add a,b
  1876.         ld ly,a ;next phase = phase + charwidth
  1877.         ld a,c ;phase
  1878.         and 1 ;phase&1
  1879.         inc a
  1880.         add a,b ;charwidth
  1881.         rra
  1882.         ld hy,a ;number of 2 pixel columns = (charwidth + (phase&1) + 1)/2
  1883.  
  1884.        call unsetfontpage
  1885.  
  1886.         ld a,(user_scr0_low) ;ok
  1887.         SETPG8000
  1888.         ld a,(user_scr0_high) ;ok
  1889.         SETPGC000
  1890.  
  1891.        pop hl
  1892. ;hl=screen addr
  1893. ;hy=number of 2 pixel columns = (charwidth + (phase&1) + 1)/2
  1894. ;ly=next phase (even=left, odd=right pixel)
  1895. ;2. print 2 pixel vertical line (scroll left bits 7,6 in char data)
  1896.         ld bc,40
  1897. prcharprop_columns0
  1898.         push hl
  1899.         ld de,font_buf
  1900.         dup 7
  1901.         ex de,hl
  1902.         ld a,(de)
  1903.         rl (hl) ;CY=left pixel
  1904.         jr nc,$+4
  1905.         or 0x47 ;hx
  1906.         rl (hl) ;CY=right pixel
  1907.         jr nc,$+4
  1908.         or 0xb8 ;lx
  1909.         ld (de),a
  1910.         ex de,hl
  1911.         add hl,bc
  1912.         inc e
  1913.         edup
  1914.         ex de,hl
  1915.         ld a,(de)
  1916.         rl (hl) ;CY=left pixel
  1917.         jr nc,$+4
  1918.         or 0x47 ;hx
  1919.         rl (hl) ;CY=right pixel
  1920.         jr nc,$+4
  1921.         or 0xb8 ;lx
  1922.         ld (de),a
  1923. ;3. next column and loop
  1924.         pop hl
  1925.         ld d,h
  1926.         ld e,l ;this will be next screen addr if the char ends in odd column ((ly&1) = 1)
  1927.         bit 6,h
  1928.         set 6,h
  1929.         jr z,$+2+4+2+2+1
  1930.          ld a,h
  1931.          xor 0x60
  1932.          ld h,a
  1933.          and 0x20
  1934.          jr nz,$+3
  1935.          inc hl
  1936.         dec hy
  1937.         jp nz,prcharprop_columns0
  1938.         ld c,ly
  1939. ;c=next phase (even=left, odd=right pixel)
  1940.         bit 0,c
  1941.         ;ret z
  1942.         jr z,_skpp
  1943.         ex de,hl ;old screen addr if the char ends in odd column ((ly&1) = 1)
  1944. ;hl=next screen addr
  1945. ;        ret
  1946.  
  1947.  
  1948.  
  1949. _skpp:
  1950.         push bc
  1951.         ld (COORDS_P),hl
  1952.         ld bc,(CORDS_P)
  1953.         inc c
  1954.         ld (CORDS_P),bc
  1955.         pop bc
  1956.         ret
  1957.  
  1958. ;;;;;;;;;;;;;;;;;;;;;;;
  1959. clear_whole_screen:
  1960.         call storec000
  1961.         ld a,(user_scr0_high)
  1962.         SETPGC000
  1963.         LD HL,#C000
  1964.         LD DE,#C001
  1965.         LD BC,16383
  1966.         LD [HL],L
  1967.         LDIR
  1968.         ld a,(user_scr0_low)
  1969.         SETPGC000
  1970.         LD HL,#C000
  1971.         LD DE,#C001
  1972.         LD BC,16383
  1973.         LD [HL],L
  1974.         LDIR
  1975.         jp restorec000
  1976. ;;;;;;;;;;;;;;;;;;;;;;;;
  1977. _clear_textbox:
  1978.         call storec000
  1979.  
  1980.         ld a,(user_scr0_high)
  1981.         SETPGC000
  1982. CLEARER_ LD HL,0xda44-160-320-2      ;D080
  1983. CLEARER1 LD B,32
  1984.         XOR A
  1985. 25      PUSH HL
  1986.         LD C,32+4
  1987.         LD (HL),A
  1988.         INC HL
  1989.         DEC C
  1990.         JR NZ,$-3
  1991.         POP HL
  1992.         LD DE,40
  1993.         ADD HL,DE
  1994.         DJNZ 25B
  1995.  
  1996. CLEARER2 LD HL,0xfa44-160-320-2   ;F080
  1997. CLEARER3 LD B,32
  1998.         XOR A
  1999. 25      PUSH HL
  2000.         LD C,32+4
  2001.         LD (HL),A
  2002.         INC HL
  2003.         DEC C
  2004.         JR NZ,$-3
  2005.         POP HL
  2006.         LD DE,40
  2007.         ADD HL,DE
  2008.         DJNZ 25B
  2009.  
  2010.  
  2011.  
  2012. ;///////
  2013.         xor a
  2014.         ld hl,0xde23-160
  2015.  
  2016.         push hl
  2017.         ld b,8
  2018. .ep1:
  2019.         ld (hl),a
  2020.         call DHL
  2021.         djnz .ep1
  2022.         pop hl
  2023.  
  2024.         ld hl,0xfe23-160
  2025.  
  2026.         push hl
  2027.         ld b,8
  2028. .ep2:
  2029.         ld (hl),a
  2030.         call DHL
  2031.         djnz .ep2
  2032.         pop hl
  2033. ;////////////////////
  2034.  
  2035.  
  2036.  
  2037.  
  2038.  
  2039.         ld a,(user_scr0_low)
  2040.         SETPGC000
  2041. CLEARER_A LD HL,0xda44-160-320-2
  2042. CLEARER1A LD B,32
  2043.         XOR A
  2044. 25      PUSH HL
  2045.         LD C,32+4
  2046.         LD (HL),A
  2047.         INC HL
  2048.         DEC C
  2049.         JR NZ,$-3
  2050.         POP HL
  2051.         LD DE,40
  2052.         ADD HL,DE
  2053.         DJNZ 25B
  2054. CLEARER2A LD HL,0xfa44-160-320-2
  2055. CLEARER3A LD B,32
  2056.          XOR A
  2057. 25         PUSH HL
  2058.          LD C,32+4
  2059.          LD (HL),A
  2060.          INC HL
  2061.          DEC C
  2062.          JR NZ,$-3
  2063.          POP HL
  2064.         LD DE,40
  2065.         ADD HL,DE
  2066.          DJNZ 25B
  2067.        
  2068.  
  2069. ;///////
  2070.         xor a
  2071.         ld hl,0xde23-160
  2072.  
  2073.         push hl
  2074.         ld b,8
  2075. .ep3:
  2076.         ld (hl),a
  2077.         call DHL
  2078.         djnz .ep3
  2079.         pop hl
  2080.  
  2081.         ld hl,0xfe23-160
  2082.  
  2083.         push hl
  2084.         ld b,8
  2085. .ep4:
  2086.         ld (hl),a
  2087.         call DHL
  2088.         djnz .ep4
  2089.         pop hl
  2090. ;////////////////////
  2091.          jp restorec000
  2092.  
  2093. ;----------------------------------------------------
  2094. ;----------------------------------------------------
  2095. _pre_setup
  2096.         ; ld a,(hl);string length
  2097.         ld a,(hl)
  2098.         ld (_line_lenght),a
  2099.         inc hl
  2100.  
  2101.         ld a,(hl)
  2102.         ld (DOWN_LIMIT),a
  2103.         inc hl
  2104.         push hl
  2105.         xor a
  2106.         ld (CUR_POS),a
  2107.         LD HL,#121A
  2108.         LD (_mnpos),HL
  2109.         pop hl
  2110.         ret
  2111. ;----------------------------------------------------
  2112. _prt_menu
  2113.         ld bc,0
  2114. _mnpos: equ $-2        
  2115.         call _pradd
  2116. prt_m1:
  2117.         ld a,(hl)
  2118.         inc hl
  2119.         and a
  2120.         RET Z
  2121.         cp 1
  2122.         JR Z,PRT_M2
  2123.         cp 128
  2124.         call nc,change_cp
  2125.         CP "#"
  2126.         call z,change_cp1
  2127.         CP "@"
  2128.         call z,change_cp2        
  2129.         SUB 32
  2130.         PUSH HL
  2131.         CALL _type
  2132.         POP HL
  2133.         JR prt_m1
  2134. PRT_M2: LD A,(_mnpos+1)
  2135.         INC A
  2136.         LD (_mnpos+1),A
  2137.         JR _prt_menu
  2138.  
  2139. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2140. _sel_menu:
  2141.         ld hl,0xD691+320+160   ;- left top corner of menus
  2142.         ld a,0
  2143. CUR_POS EQU $-1
  2144.         and a
  2145.         jr z,_sel_m_skip_c
  2146.  
  2147.         ld bc,320
  2148. _sel_menu_clc:
  2149.         add hl,bc
  2150.         dec a
  2151.         jr nz,_sel_menu_clc
  2152.  
  2153. _sel_m_skip_c:
  2154.         ld (SEL_S),hl
  2155.  
  2156.         call _highlight_selected
  2157. _sel_wait_loop:
  2158.         call waitkey
  2159.  
  2160.         cp key_up
  2161.         jr z,_sel_move_up
  2162.         cp key_down
  2163.         jr z,_sel_move_down
  2164.         cp key_enter
  2165.         jr z,_sel_sel_key
  2166.         cp ' '
  2167.         jr z,_sel_sel_key
  2168.         cp key_esc
  2169.         jr z,_sel_esc_key
  2170.         jr _sel_wait_loop
  2171.  
  2172. _sel_move_down
  2173.         ld hl,0
  2174. SEL_S   EQU $-2
  2175.         call _highlight_selected        
  2176.         ld hl,CUR_POS
  2177.         ld a,(hl)
  2178.         cp 0
  2179. DOWN_LIMIT EQU $-1        
  2180.         jp nc,_sel_menu
  2181.         inc (hl)
  2182.         jp _sel_menu
  2183.  
  2184. _sel_move_up
  2185.         ld hl,(SEL_S)
  2186.         call _highlight_selected        
  2187.         ld hl,CUR_POS
  2188.         ld a,(hl)
  2189.         and a
  2190.         jp z,_sel_menu
  2191.         dec (HL)
  2192.         jp _sel_menu
  2193. _sel_sel_key:
  2194.         ld hl,(SEL_S)
  2195.         call _highlight_selected
  2196.         ld a,(CUR_POS)
  2197.         ret
  2198.  
  2199. _sel_esc_key:
  2200. SEL_L  
  2201.         ld hl,(SEL_S)
  2202.         call _highlight_selected
  2203.         ld a,0xff
  2204.         ret
  2205.  
  2206. ;--------------------------------------
  2207. ;in hl adress in screen
  2208. _highlight_selected
  2209. ;LINE1
  2210.         push de
  2211.         push hl
  2212.         call storec000
  2213.         pop hl
  2214.  
  2215.         LD A,0
  2216. _line_lenght equ $-1
  2217.         LD [LINELEN],A
  2218.         LD [LINELEN0],A
  2219.         LD [LINELEN1],A
  2220.         LD [LINELEN2],A
  2221.  
  2222.          LD [LINE1_1],HL
  2223.          set 5,h
  2224.          LD [LINE1_2],HL
  2225.  
  2226.          ld a,(user_scr0_high)
  2227.          SETPGC000
  2228.  
  2229.          LD HL,0
  2230. LINE1_1  EQU $-2
  2231.          LD B,8
  2232. 0        PUSH BC,HL
  2233.          LD B,6
  2234. LINELEN EQU $-1
  2235. 1        LD A,(HL)
  2236.           xor %00010010;0xff ;XOR %00010010
  2237.          LD (HL),A
  2238.          INC HL
  2239.          DJNZ 1B
  2240.          POP HL
  2241.          CALL DHL
  2242.          POP BC
  2243.          DJNZ 0B
  2244.          LD HL,0
  2245. LINE1_2  EQU $-2
  2246.          LD B,8
  2247. 0        PUSH BC,HL
  2248.          LD B,6
  2249. LINELEN0 EQU $-1
  2250. 1        LD A,(HL)
  2251.          xor %00010010;0xff ;XOR %00010010
  2252.          LD (HL),A
  2253.          INC HL
  2254.          DJNZ 1B
  2255.          POP HL
  2256.          CALL DHL
  2257.          POP BC
  2258.          DJNZ 0B
  2259.  
  2260.          ld a,(user_scr0_low)
  2261.          SETPGC000
  2262.  
  2263.          LD HL,(LINE1_1)
  2264.          LD B,8
  2265. 0        PUSH BC,HL
  2266.          LD B,6
  2267. LINELEN1 EQU $-1
  2268. 1        LD A,(HL)
  2269.          xor %00010010;0xff ;XOR %00010010
  2270.          LD (HL),A
  2271.          INC HL
  2272.          DJNZ 1B
  2273.          POP HL
  2274.          CALL DHL
  2275.          POP BC
  2276.          DJNZ 0B
  2277.  
  2278.          LD HL,[LINE1_2]
  2279.          LD B,8
  2280. 0        PUSH BC,HL
  2281.          LD B,6
  2282. LINELEN2 EQU $-1
  2283. 1        LD A,(HL)
  2284.          xor %00010010;0xff ;XOR %00010010
  2285.          LD (HL),A
  2286.          INC HL
  2287.          DJNZ 1B
  2288.          POP HL
  2289.          CALL DHL
  2290.          POP BC
  2291.          DJNZ 0B
  2292.  
  2293.          call restorec000
  2294.          pop de
  2295.          ret
  2296. ;;;;;;;;;;;;;;;;;;;;;;
  2297. _pre_menu_store_bgnd:
  2298.         push af
  2299.         push hl
  2300.         ;#d680
  2301.         call store8000c000
  2302.  
  2303.         ld a,(src_buf1)
  2304.         SETPG8000
  2305.  
  2306.         ld a,(user_scr0_low)
  2307.         SETPGC000
  2308.  
  2309.         ld hl,0xd680
  2310.         ld de,0x8000
  2311.         ld bc,320*7
  2312.         ldir
  2313.  
  2314.         ld hl,0xf680
  2315.         ld bc,320*7
  2316.         ldir
  2317.  
  2318.  
  2319.         ld a,(user_scr0_high)
  2320.         SETPGC000
  2321.         ld hl,0xd680
  2322.         ld bc,320*7
  2323.         ldir
  2324.  
  2325.         ld hl,0xf680
  2326.         ld bc,320*7
  2327.         ldir
  2328.  
  2329.         call restore8000c000
  2330.         pop hl
  2331.         pop af
  2332.         ret
  2333. _pre_menu_restore_bgnd:
  2334.         push af
  2335.         push hl
  2336.         ;#d680
  2337.         call store8000c000
  2338.  
  2339.         ld a,(src_buf1)
  2340.         SETPG8000
  2341.  
  2342.         ld a,(user_scr0_low)
  2343.         SETPGC000
  2344.  
  2345.         ld hl,0x8000
  2346.         ld de,0xd680
  2347.         ld bc,320*7
  2348.         ldir
  2349.  
  2350.         ld de,0xf680
  2351.         ld bc,320*7
  2352.         ldir
  2353.  
  2354.         ld a,(user_scr0_high)
  2355.         SETPGC000
  2356.         ld de,0xd680
  2357.         ld bc,320*7
  2358.         ldir
  2359.  
  2360.         ld de,0xf680
  2361.         ld bc,320*7
  2362.         ldir
  2363.         call restore8000c000        
  2364.         pop hl
  2365.         pop af
  2366.         ret
  2367. ;;;;;;;;;;;;;;;;;;;;;;
  2368. DECR_SPR:
  2369.  
  2370.         ld a,0
  2371. XPOS    EQU $-1
  2372.         SRL A
  2373.         jr nc,xpos1
  2374.         inc a
  2375. xpos1:        
  2376.         ld c,a
  2377.         ld b,0
  2378.  
  2379.  
  2380.         ld (decrspr_offset),bc
  2381.  
  2382.         and a
  2383.         ld hl,30
  2384.         SBC hl,bc
  2385.         ld (dcrspr_len),hl
  2386.  
  2387.         call store8000c000
  2388.  
  2389.         ld a,(scr_buf1)
  2390.         SETPG8000
  2391.         ld a,(load_buf1)
  2392.         SETPGC000
  2393.  
  2394.         ld bc,(decrspr_offset)
  2395.         ld hl,0xc005
  2396.         add hl,bc
  2397.         ld de,0x8005
  2398.  
  2399.         ld b,148
  2400. decr_spr_lp1:
  2401.         push bc
  2402.  
  2403.         push hl
  2404.         push de
  2405.  
  2406.         ld bc,(dcrspr_len)
  2407.         call _iob
  2408.  
  2409.         pop hl ; (de)
  2410.         call DHL
  2411.         ex de,hl
  2412.         pop hl
  2413.         call DHL
  2414.  
  2415.         pop bc
  2416.         djnz decr_spr_lp1
  2417.  
  2418.  
  2419.         ld bc,(decrspr_offset)
  2420.         ld hl,0xe005
  2421.         add hl,bc
  2422.         ld de,0xa005
  2423.  
  2424.         ld b,148
  2425. decr_spr_lp2:
  2426.         push bc
  2427.  
  2428.         push hl
  2429.         push de
  2430.  
  2431.         ld bc,(dcrspr_len)
  2432.         call _iob
  2433.  
  2434.         pop hl ; (de)
  2435.         call DHL
  2436.         ex de,hl
  2437.         pop hl
  2438.         call DHL
  2439.  
  2440.         pop bc
  2441.         djnz decr_spr_lp2
  2442.  
  2443.  
  2444.         ld a,(scr_buf2)
  2445.         SETPG8000
  2446.         ld a,(load_buf2)
  2447.         SETPGC000
  2448.  
  2449.         ld bc,(decrspr_offset)
  2450.         ld hl,0xc005
  2451.         add hl,bc
  2452.         ld de,0x8005
  2453.  
  2454.         ld b,148
  2455. decr_spr_lp3:
  2456.         push bc
  2457.  
  2458.         push hl
  2459.         push de
  2460.  
  2461.         ld bc,(dcrspr_len)
  2462.         call _iob
  2463.  
  2464.         pop hl ; (de)
  2465.         call DHL
  2466.         ex de,hl
  2467.         pop hl
  2468.         call DHL
  2469.  
  2470.         pop bc
  2471.         djnz decr_spr_lp3
  2472.  
  2473.  
  2474.         ld bc,(decrspr_offset)
  2475.         ld hl,0xe005
  2476.         add hl,bc
  2477.         ld de,0xa005
  2478.  
  2479.         ld b,148
  2480. decr_spr_lp4:
  2481.         push bc
  2482.  
  2483.         push hl
  2484.         push de
  2485.  
  2486.         ld bc,(dcrspr_len)
  2487.         call _iob
  2488.  
  2489.         pop hl ; (de)
  2490.         call DHL
  2491.         ex de,hl
  2492.         pop hl
  2493.         call DHL
  2494.  
  2495.         pop bc
  2496.         djnz decr_spr_lp4
  2497.  
  2498.         jp restore8000c000
  2499. decrspr_offset dw 0 ;offset to draw sprite
  2500. dcrspr_len dw 0      ; cutted length
  2501. ;-----------------------
  2502. anim_wait:
  2503.         LD      A,0
  2504.         INC     A
  2505.         AND     3
  2506.         LD      (anim_wait+1),A
  2507.         RET     NZ
  2508.  
  2509.         call store8000c000
  2510.  
  2511.         ld a,(user_scr0_low)
  2512.         SETPG8000
  2513.  
  2514.         ld a,(user_scr0_high)
  2515.         SETPGC000
  2516.  
  2517.        
  2518.         ld hl,PUSH_DATA
  2519.         ld de,0x9e23-160
  2520.  
  2521.         ld a,0
  2522. FASE    equ $-1
  2523.  
  2524.         add a,a;x2
  2525.         add a,a;x4
  2526.         add a,a;x8
  2527.         add a,a;x16
  2528.         add a,a;x32
  2529.         ld c,a
  2530.         ld b,0
  2531.         add hl,bc        
  2532.        
  2533.         ex de,hl
  2534.      
  2535.  
  2536.         push hl
  2537.         ld b,8
  2538. export_push_iloop1:
  2539.         ld a,(de)
  2540.         ld (hl),a
  2541.         call DHL
  2542.         inc de
  2543.         djnz export_push_iloop1
  2544.         pop hl
  2545.  
  2546.         set 6,H
  2547.         push hl
  2548.         ld b,8
  2549. export_push_iloop2:
  2550.         ld a,(de)
  2551.         ld (hl),a
  2552.         call DHL
  2553.         inc de
  2554.         djnz export_push_iloop2
  2555.         pop hl
  2556.  
  2557.         res 6,H
  2558.         set 5,H
  2559.  
  2560.         push hl
  2561.         ld b,8
  2562. export_push_iloop3:
  2563.         ld a,(de)
  2564.         ld (hl),a
  2565.         call DHL
  2566.         inc de
  2567.         djnz export_push_iloop3
  2568.         pop hl
  2569.  
  2570.         set 6,H
  2571.  
  2572.         ld b,8
  2573. export_push_iloop4:
  2574.         ld a,(de)
  2575.         ld (hl),a
  2576.         call DHL
  2577.         inc de
  2578.         djnz export_push_iloop4
  2579.  
  2580.         ld a,(FASE)
  2581.         inc a
  2582.         and 7
  2583.         ld (FASE),a
  2584.  
  2585.         jp restore8000c000
  2586. ;-----------------------------
  2587.  
  2588. ;---
  2589. ;in hl - x-coord 0-319
  2590. ;;out hl -adress in 8000 - ffff atm2 ega screen (x-offset)
  2591. p_calc_x:
  2592.         and a
  2593.         rr h
  2594.         rr l
  2595.         ld a,l
  2596.         rrca
  2597.         rrca
  2598.         ld h,0
  2599.         and a
  2600.         push af
  2601.         rla
  2602.         rr h
  2603.         rla
  2604.         rr h
  2605.         scf
  2606.         rr h
  2607.         pop af
  2608.         and 0x3f
  2609.         ld l,a
  2610.         ret
  2611. ;=============================================      
  2612. ;in hl - x-adress in atm2 ega screen
  2613. ;   a - y coord - 0-199
  2614. ;;out hl -adress in 8000 - ffff atm2 ega screen (xy offset)
  2615. p_calc_y:
  2616.         ld bc,40
  2617. p_calc_y_loop:
  2618.         and a
  2619.         ret z
  2620.         add hl,bc
  2621.         dec a
  2622.         jr p_calc_y_loop        
  2623. ;=============================================      
  2624. p_nextcolumn:
  2625.         bit 6,h
  2626.         set 6,h
  2627.         jr z,1f;shapes_linehorR_incxok
  2628.         ld a,h
  2629.         xor 0x60
  2630.         ld h,a
  2631.         and 0x20
  2632.         jr nz,1f;shapes_linehorR_incxok
  2633.         inc hl
  2634. 1 ;shapes_linehorR_incxok
  2635.     ret
  2636. ;---------------------------------------
  2637.