?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) ;ok
  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) ;ok
  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) ;ok
  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) ;ok
  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) ;ok
  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) ;ok
  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) ;ok
  280.         ld (src_buf1),a
  281.         ld a,(user_scr1_high) ;ok
  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) ;ok
  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) ;ok
  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) ;ok
  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) ;ok
  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) ;ok
  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) ;ok
  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) ;ok
  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) ;ok
  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) ;ok
  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) ;ok
  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) ;ok
  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) ;ok
  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) ;ok
  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) ;ok
  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) ;ok
  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) ;ok
  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) ;ok
  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) ;ok
  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) ;ok
  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) ;ok
  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) ;ok
  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) ;ok
  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) ;ok
  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) ;ok
  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) ;ok
  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) ;ok
  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) ;ok
  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) ;ok
  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) ;ok
  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) ;ok
  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) ;ok
  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) ;ok
  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. ;in B - y C-x
  1602. ;out   set coordinates for TYPE
  1603.  
  1604. _pradd
  1605.         LD (CORDS),BC
  1606.         SRL     C
  1607.         SBC     A
  1608.         AND %00100000
  1609.         LD      (M111),A
  1610.  
  1611.         PUSH HL
  1612.         LD H,#C0
  1613.         LD A,H
  1614.         OR 0
  1615. M111    EQU $-1
  1616.         LD H,A
  1617.  
  1618.         LD A,C
  1619.         ADD A,4
  1620.         LD L,A
  1621.  
  1622.         LD DE,320
  1623. pradd_l:        
  1624.         ADD HL,DE
  1625.         DJNZ pradd_l
  1626.         ld de,160+320
  1627.         add hl,de
  1628.         LD (COORDS),HL
  1629.         POP HL
  1630.         RET        
  1631. ;---------------        
  1632. ;in A - char to print
  1633. _type
  1634.         ld de,0
  1635. COORDS  equ $-2        
  1636.         ld h,0
  1637.         ld l,a
  1638. M10:
  1639.         ld bc,FONT
  1640.         add hl,hl
  1641.         add hl,hl
  1642.         add hl,hl
  1643.         add hl,hl
  1644.         add hl,bc ;hl addr in FONT
  1645.  
  1646.  ;       ex de,hl
  1647.         push de
  1648.         push hl
  1649.         call setfontpage
  1650.         pop hl
  1651.         ld de,font_buf
  1652.         ld bc,16
  1653.         ldir
  1654.         call unsetfontpage
  1655.  
  1656.  
  1657.         pop hl
  1658.  
  1659.         ld de,font_buf
  1660.         push hl
  1661.         ld a,(user_scr0_low) ;ok
  1662.         SETPGC000
  1663.         ld b,8
  1664. _ppnz2:
  1665.         push bc
  1666.         ld a,(de)
  1667.         ld (hl),a
  1668.         inc de
  1669.         ld bc,40
  1670.         add hl,bc
  1671.         pop bc
  1672.         djnz _ppnz2
  1673.         pop hl
  1674.  
  1675.         push hl
  1676.         ld a,(user_scr0_high) ;ok
  1677.         SETPGC000
  1678.         ld b,8
  1679. _ppnz3:
  1680.         push bc
  1681.         ld a,(de)
  1682.         ld (hl),a
  1683.         inc de
  1684.         ld bc,40
  1685.         add hl,bc
  1686.         pop bc
  1687.         djnz _ppnz3
  1688.         pop hl
  1689.  
  1690.         ld a,h
  1691.         xor 0x20
  1692.         bit 5,h
  1693.         ld h,a
  1694.         jr z,_ppnz4:
  1695.         inc hl
  1696.  
  1697. _ppnz4:        
  1698.         ld (COORDS),hl
  1699.         ld bc,(CORDS)
  1700.         inc c
  1701.         ld (CORDS),bc
  1702.         ld a,c
  1703.         cp 64
  1704.         ret c
  1705.  
  1706.         inc b
  1707.         ld c,0
  1708.         jp _pradd
  1709.  
  1710. UPHL1   CALL UPHL
  1711. UPHL
  1712.         PUSH BC
  1713.         LD BC,40
  1714.         AND A
  1715.         SBC HL,BC
  1716.         POP BC
  1717.         RET
  1718.  
  1719.  
  1720. DHL1    CALL DHL
  1721. DHL
  1722.         PUSH BC
  1723.         LD BC,40
  1724.         ADD HL,BC
  1725.         POP BC
  1726.         RET
  1727. ;;;;;;;;;;;;;;;;;;;;;;;
  1728. clear_whole_screen:
  1729.         call storec000
  1730.         ld a,(user_scr0_high) ;ok
  1731.         SETPGC000
  1732.         LD HL,#C000
  1733.         LD DE,#C001
  1734.         LD BC,16383
  1735.         LD [HL],L
  1736.         LDIR
  1737.         ld a,(user_scr0_low) ;ok
  1738.         SETPGC000
  1739.         LD HL,#C000
  1740.         LD DE,#C001
  1741.         LD BC,16383
  1742.         LD [HL],L
  1743.         LDIR
  1744.         jp restorec000
  1745. ;;;;;;;;;;;;;;;;;;;;;;;;
  1746. _clear_textbox:
  1747.         call storec000
  1748.  
  1749.         ld a,(user_scr0_high) ;ok
  1750.         SETPGC000
  1751. CLEARER_ LD HL,0xda44-160      ;D080
  1752. CLEARER1 LD B,32
  1753.         XOR A
  1754. 25      PUSH HL
  1755.         LD C,32
  1756.         LD (HL),A
  1757.         INC HL
  1758.         DEC C
  1759.         JR NZ,$-3
  1760.         POP HL
  1761.         LD DE,40
  1762.         ADD HL,DE
  1763.         DJNZ 25B
  1764.  
  1765. CLEARER2 LD HL,0xfa44-160   ;F080
  1766. CLEARER3 LD B,32
  1767.         XOR A
  1768. 25      PUSH HL
  1769.         LD C,32
  1770.         LD (HL),A
  1771.         INC HL
  1772.         DEC C
  1773.         JR NZ,$-3
  1774.         POP HL
  1775.         LD DE,40
  1776.         ADD HL,DE
  1777.         DJNZ 25B
  1778.  
  1779.         ld a,(user_scr0_low) ;ok
  1780.         SETPGC000
  1781. CLEARER_A LD HL,0xda44-160
  1782. CLEARER1A LD B,32
  1783.         XOR A
  1784. 25      PUSH HL
  1785.         LD C,32
  1786.         LD (HL),A
  1787.         INC HL
  1788.         DEC C
  1789.         JR NZ,$-3
  1790.         POP HL
  1791.         LD DE,40
  1792.         ADD HL,DE
  1793.         DJNZ 25B
  1794. CLEARER2A LD HL,0xfa44-160
  1795. CLEARER3A LD B,32
  1796.          XOR A
  1797. 25         PUSH HL
  1798.          LD C,32
  1799.          LD (HL),A
  1800.          INC HL
  1801.          DEC C
  1802.          JR NZ,$-3
  1803.          POP HL
  1804.         LD DE,40
  1805.         ADD HL,DE
  1806.          DJNZ 25B
  1807.        
  1808.          jp restorec000
  1809.  
  1810. ;----------------------------------------------------
  1811. ;----------------------------------------------------
  1812. _pre_setup
  1813.         ; ld a,(hl);string length
  1814.         ld a,(hl)
  1815.         ld (_line_lenght),a
  1816.         inc hl
  1817.  
  1818.         ld a,(hl)
  1819.         ld (DOWN_LIMIT),a
  1820.         inc hl
  1821.         push hl
  1822.         xor a
  1823.         ld (CUR_POS),a
  1824.         LD HL,#121A
  1825.         LD (_mnpos),HL
  1826.         pop hl
  1827.         ret
  1828. ;----------------------------------------------------
  1829. _prt_menu
  1830.         ld bc,0
  1831. _mnpos: equ $-2        
  1832.         call _pradd
  1833. prt_m1:
  1834.         ld a,(hl)
  1835.         inc hl
  1836.         and a
  1837.         RET Z
  1838.         cp 1
  1839.         JR Z,PRT_M2
  1840.         cp 128
  1841.         call nc,change_cp
  1842.         CP "#"
  1843.         call z,change_cp1
  1844.         CP "@"
  1845.         call z,change_cp2        
  1846.         SUB 32
  1847.         PUSH HL
  1848.         CALL _type
  1849.         POP HL
  1850.         JR prt_m1
  1851. PRT_M2: LD A,(_mnpos+1)
  1852.         INC A
  1853.         LD (_mnpos+1),A
  1854.         JR _prt_menu
  1855.  
  1856. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1857. _sel_menu:
  1858.         ld hl,0xD691+320+160   ;- left top corner of menus
  1859.         ld a,0
  1860. CUR_POS EQU $-1
  1861.         and a
  1862.         jr z,_sel_m_skip_c
  1863.  
  1864.         ld bc,320
  1865. _sel_menu_clc:
  1866.         add hl,bc
  1867.         dec a
  1868.         jr nz,_sel_menu_clc
  1869.  
  1870. _sel_m_skip_c:
  1871.         ld (SEL_S),hl
  1872.  
  1873.         call _highlight_selected
  1874. _sel_wait_loop:
  1875.         call waitkey
  1876.  
  1877.         cp key_up
  1878.         jr z,_sel_move_up
  1879.         cp key_down
  1880.         jr z,_sel_move_down
  1881.         cp key_enter
  1882.         jr z,_sel_sel_key
  1883.         cp ' '
  1884.         jr z,_sel_sel_key
  1885.         cp key_esc
  1886.         jr z,_sel_esc_key
  1887.         jr _sel_wait_loop
  1888.  
  1889. _sel_move_down
  1890.         ld hl,0
  1891. SEL_S   EQU $-2
  1892.         call _highlight_selected        
  1893.         ld hl,CUR_POS
  1894.         ld a,(hl)
  1895.         cp 0
  1896. DOWN_LIMIT EQU $-1        
  1897.         jp nc,_sel_menu
  1898.         inc (hl)
  1899.         jp _sel_menu
  1900.  
  1901. _sel_move_up
  1902.         ld hl,(SEL_S)
  1903.         call _highlight_selected        
  1904.         ld hl,CUR_POS
  1905.         ld a,(hl)
  1906.         and a
  1907.         jp z,_sel_menu
  1908.         dec (HL)
  1909.         jp _sel_menu
  1910. _sel_sel_key:
  1911.         ld hl,(SEL_S)
  1912.         call _highlight_selected
  1913.         ld a,(CUR_POS)
  1914.         ret
  1915.  
  1916. _sel_esc_key:
  1917. SEL_L  
  1918.         ld hl,(SEL_S)
  1919.         call _highlight_selected
  1920.         ld a,0xff
  1921.         ret
  1922.  
  1923. ;--------------------------------------
  1924. ;in hl adress in screen
  1925. _highlight_selected
  1926. ;LINE1
  1927.         push de
  1928.         push hl
  1929.         call storec000
  1930.         pop hl
  1931.  
  1932.         LD A,0
  1933. _line_lenght equ $-1
  1934.         LD [LINELEN],A
  1935.         LD [LINELEN0],A
  1936.         LD [LINELEN1],A
  1937.         LD [LINELEN2],A
  1938.  
  1939.          LD [LINE1_1],HL
  1940.          set 5,h
  1941.          LD [LINE1_2],HL
  1942.  
  1943.          ld a,(user_scr0_high) ;ok
  1944.          SETPGC000
  1945.  
  1946.          LD HL,0
  1947. LINE1_1  EQU $-2
  1948.          LD B,8
  1949. 0        PUSH BC,HL
  1950.          LD B,6
  1951. LINELEN EQU $-1
  1952. 1        LD A,(HL)
  1953.           xor 0xff ;XOR %00010010
  1954.          LD (HL),A
  1955.          INC HL
  1956.          DJNZ 1B
  1957.          POP HL
  1958.          CALL DHL
  1959.          POP BC
  1960.          DJNZ 0B
  1961.          LD HL,0
  1962. LINE1_2  EQU $-2
  1963.          LD B,8
  1964. 0        PUSH BC,HL
  1965.          LD B,6
  1966. LINELEN0 EQU $-1
  1967. 1        LD A,(HL)
  1968.          xor 0xff ;XOR %00010010
  1969.          LD (HL),A
  1970.          INC HL
  1971.          DJNZ 1B
  1972.          POP HL
  1973.          CALL DHL
  1974.          POP BC
  1975.          DJNZ 0B
  1976.  
  1977.          ld a,(user_scr0_low) ;ok
  1978.          SETPGC000
  1979.  
  1980.          LD HL,(LINE1_1)
  1981.          LD B,8
  1982. 0        PUSH BC,HL
  1983.          LD B,6
  1984. LINELEN1 EQU $-1
  1985. 1        LD A,(HL)
  1986.          xor 0xff ;XOR %00010010
  1987.          LD (HL),A
  1988.          INC HL
  1989.          DJNZ 1B
  1990.          POP HL
  1991.          CALL DHL
  1992.          POP BC
  1993.          DJNZ 0B
  1994.  
  1995.          LD HL,[LINE1_2]
  1996.          LD B,8
  1997. 0        PUSH BC,HL
  1998.          LD B,6
  1999. LINELEN2 EQU $-1
  2000. 1        LD A,(HL)
  2001.          xor 0xff ;XOR %00010010
  2002.          LD (HL),A
  2003.          INC HL
  2004.          DJNZ 1B
  2005.          POP HL
  2006.          CALL DHL
  2007.          POP BC
  2008.          DJNZ 0B
  2009.  
  2010.          call restorec000
  2011.          pop de
  2012.          ret
  2013. ;;;;;;;;;;;;;;;;;;;;;;
  2014. _pre_menu_store_bgnd:
  2015.         push af
  2016.         push hl
  2017.         ;#d680
  2018.         call store8000c000
  2019.  
  2020.         ld a,(src_buf1)
  2021.         SETPG8000
  2022.  
  2023.         ld a,(user_scr0_low) ;ok
  2024.         SETPGC000
  2025.  
  2026.         ld hl,0xd680
  2027.         ld de,0x8000
  2028.         ld bc,320*7
  2029.         ldir
  2030.  
  2031.         ld hl,0xf680
  2032.         ld bc,320*7
  2033.         ldir
  2034.  
  2035.  
  2036.         ld a,(user_scr0_high) ;ok
  2037.         SETPGC000
  2038.         ld hl,0xd680
  2039.         ld bc,320*7
  2040.         ldir
  2041.  
  2042.         ld hl,0xf680
  2043.         ld bc,320*7
  2044.         ldir
  2045.  
  2046.         call restore8000c000
  2047.         pop hl
  2048.         pop af
  2049.         ret
  2050. _pre_menu_restore_bgnd:
  2051.         push af
  2052.         push hl
  2053.         ;#d680
  2054.         call store8000c000
  2055.  
  2056.         ld a,(src_buf1)
  2057.         SETPG8000
  2058.  
  2059.         ld a,(user_scr0_low) ;ok
  2060.         SETPGC000
  2061.  
  2062.         ld hl,0x8000
  2063.         ld de,0xd680
  2064.         ld bc,320*7
  2065.         ldir
  2066.  
  2067.         ld de,0xf680
  2068.         ld bc,320*7
  2069.         ldir
  2070.  
  2071.         ld a,(user_scr0_high) ;ok
  2072.         SETPGC000
  2073.         ld de,0xd680
  2074.         ld bc,320*7
  2075.         ldir
  2076.  
  2077.         ld de,0xf680
  2078.         ld bc,320*7
  2079.         ldir
  2080.         call restore8000c000        
  2081.         pop hl
  2082.         pop af
  2083.         ret
  2084. ;---------------------------
  2085. EXITDARK
  2086.  
  2087.         call palette_precalc
  2088.         call fade_toblack
  2089.  
  2090.        CALL clear_whole_screen
  2091.        JP begin
  2092.  
  2093. ;;;;;;=====
  2094. FLASH
  2095.         ld b,(hl)
  2096.         inc hl
  2097.         push hl
  2098.  
  2099.         push bc
  2100.  
  2101.         ld hl,pal
  2102.         ld de,temppal
  2103.         ld bc,32
  2104.         ldir
  2105.  
  2106.         pop bc
  2107.  
  2108. FLASH_LP:
  2109.         push bc
  2110.  
  2111.         ld hl,whitepal
  2112.         ld de,pal
  2113.         ld bc,32
  2114.         ldir
  2115.  
  2116.         ld a,1
  2117.         ld (setpalflag),a
  2118.  
  2119.         halt
  2120.         halt
  2121.         halt
  2122.         halt
  2123.         halt
  2124.  
  2125.  
  2126.         ld hl,temppal
  2127.         ld de,pal
  2128.         ld bc,32
  2129.         ldir
  2130.  
  2131.         ld a,1
  2132.         ld (setpalflag),a
  2133.  
  2134.         halt
  2135.         halt
  2136.         halt
  2137.         halt
  2138.         halt
  2139.  
  2140.         pop bc
  2141.         djnz FLASH_LP
  2142.         pop hl
  2143.         jp _print
  2144.  
  2145.  
  2146. SHAKE:
  2147.         ld b,(hl)
  2148.         inc hl
  2149.  
  2150.         push hl
  2151.         push bc
  2152.  
  2153.         call store8000c000
  2154.  
  2155.         ld a,(user_scr0_low) ;ok
  2156.         SETPG8000
  2157.         ld a,(user_scr1_low) ;ok
  2158.         SETPGC000
  2159.  
  2160.         ld hl,0x8000+320
  2161.         ld de,0xc000
  2162.         ld bc,8000-320
  2163.         ldir
  2164.         ;ld hl,0x8000
  2165.         ;ld bc,320
  2166.         ;ldir
  2167.  
  2168.         ld hl,0xa000+320
  2169.         ld de,0xe000
  2170.         ld bc,8000-320
  2171.         ldir
  2172.         ;ld hl,0xa000
  2173.         ;ld bc,320
  2174.         ;ldir
  2175.  
  2176.  
  2177.         ld a,(user_scr0_high) ;ok
  2178.         SETPG8000
  2179.         ld a,(user_scr1_high) ;ok
  2180.         SETPGC000
  2181.  
  2182.         ld hl,0x8000+320
  2183.         ld de,0xc000
  2184.         ld bc,8000-320
  2185.         ldir
  2186.         ;ld hl,0x8000
  2187.         ;ld bc,320
  2188.         ;ldir
  2189.  
  2190.         ld hl,0xa000+320
  2191.         ld de,0xe000
  2192.         ld bc,8000-320
  2193.         ldir
  2194.         ;ld hl,0xa000
  2195.         ;ld bc,320
  2196.         ;ldir
  2197.  
  2198.  
  2199.         pop bc
  2200. SHAKE_LP:
  2201.         push bc
  2202.  
  2203.         ld e,1
  2204.         OS_SETSCREEN
  2205.  
  2206.         halt
  2207.         halt
  2208.         halt
  2209.         halt
  2210.         halt
  2211.  
  2212.         ld e,0
  2213.         OS_SETSCREEN
  2214.  
  2215.         halt
  2216.         halt
  2217.         halt
  2218.         halt
  2219.         halt
  2220.  
  2221.         pop bc
  2222.         djnz SHAKE_LP
  2223.  
  2224.         call restore8000c000
  2225.         pop hl
  2226.         jp _print
  2227. ;;;;;;;;;;;;;;;;;;;;;;
  2228. ;-----------------------
  2229. _prt_ingame_menu:
  2230.         ld bc,0
  2231. _ingame_m_mnpos: equ $-2
  2232.         call _pradd
  2233. prt_ingame_m1:
  2234.         ld a,(hl)
  2235.         inc hl
  2236.         and a
  2237.         RET Z
  2238.         cp 1
  2239.         JR Z,prt_ingame_m2
  2240.         cp 128
  2241.         call nc,change_cp
  2242.         CP "#"
  2243.         call z,change_cp1
  2244.         CP "@"
  2245.         call z,change_cp2        
  2246.         SUB 32
  2247.         PUSH HL
  2248.         CALL _type
  2249.         POP HL
  2250.         JR prt_ingame_m1
  2251. prt_ingame_m2:
  2252.         LD A,(_ingame_m_mnpos) ;x-coord
  2253.         add a,16
  2254.         ld (_ingame_m_mnpos),a
  2255.         cp 64
  2256.         jr c,_prt_ingame_menu
  2257.         and 0x3f
  2258.         LD (_ingame_m_mnpos),A
  2259.         ld a,(_ingame_m_mnpos+1)
  2260.         inc a
  2261.         ld (_ingame_m_mnpos+1),a
  2262.         JR _prt_ingame_menu
  2263. ;------------------------------------
  2264.  
  2265. _sel_ingame_menu:
  2266.         ld a,0
  2267. _ingame_m_curpos equ $-1
  2268.         ld hl,MENUCURHELPER
  2269.         call sel_word
  2270.         ld (_sel_ingame_SELS4),hl
  2271.         call _highlight_selected
  2272. _sel_ingame_SELS3:        
  2273.         call waitkey
  2274.  
  2275.         cp key_esc
  2276.         jp z,_sel_ingame_esc
  2277.  
  2278.         cp key_left
  2279.         jr z,_sel_ingame_SELS_keyleft
  2280.         cp key_right
  2281.         jr z,_sel_ingame_SELS_keyright
  2282.  
  2283.         cp key_up
  2284.         jr z,_sel_ingame_SELS_keyup
  2285.         cp key_down
  2286.         jr z,_sel_ingame_SELS_keydown
  2287.  
  2288.         cp key_enter
  2289.         jr z,_sel_ingame_SELECTED
  2290.         cp ' '
  2291.         jr z,_sel_ingame_SELECTED
  2292.         jr _sel_ingame_SELS3        
  2293. _sel_ingame_esc:
  2294.         ld hl,0
  2295. _sel_ingame_SELS4: equ $-2
  2296.         call _highlight_selected
  2297.         ld a,0xff
  2298.         ret
  2299. _sel_ingame_SELS_keyleft:
  2300.         ld hl,(_sel_ingame_SELS4)
  2301.         call _highlight_selected
  2302.  
  2303.         ld hl,_ingame_m_curpos
  2304.         ld a,(hl)
  2305.         and a
  2306.         jp z,_sel_ingame_menu
  2307.         dec (HL)
  2308.         jp _sel_ingame_menu
  2309.  
  2310. _sel_ingame_SELS_keyright:
  2311.         ld hl,(_sel_ingame_SELS4)
  2312.         call _highlight_selected
  2313.         ld hl,_ingame_m_curpos
  2314.         ld a,(hl)
  2315.         cp 0
  2316. _ingame_m_downlimit: EQU $-1        
  2317.  
  2318.         jp nc,_sel_ingame_menu
  2319.         inc (hl)
  2320.         jp _sel_ingame_menu
  2321. _sel_ingame_SELECTED:
  2322.         ld hl,(_sel_ingame_SELS4)
  2323.         call _highlight_selected
  2324.         ld a,(_ingame_m_curpos)
  2325.         ret
  2326.  
  2327. _sel_ingame_SELS_keyup:
  2328.         ld hl,(_sel_ingame_SELS4)
  2329.         call _highlight_selected
  2330.  
  2331.  
  2332.         ld hl,_ingame_m_curpos
  2333.         ld a,(hl)
  2334.         sub 4
  2335.         jp m,_sel_ingame_menu        
  2336.         ld (hl),a
  2337.         jp _sel_ingame_menu
  2338.  
  2339. _sel_ingame_SELS_keydown:
  2340.         ld hl,(_sel_ingame_SELS4)
  2341.         call _highlight_selected
  2342.  
  2343.         ld a,(_ingame_m_downlimit)
  2344.         inc a
  2345.         ld b,a
  2346.  
  2347.         ld hl,_ingame_m_curpos
  2348.         ld a,(hl)
  2349.         add a,4
  2350.         sub b      
  2351.         jp p,_sel_ingame_menu        
  2352.         add a,b
  2353.         ld (hl),a
  2354.  
  2355.         jp _sel_ingame_menu
  2356. ;;;;;;;;;;;;;;;;;;;;;;
  2357. DECR_SPR:
  2358.  
  2359.         ld a,0
  2360. XPOS    EQU $-1
  2361.         SRL A
  2362.         jr nc,xpos1
  2363.         inc a
  2364. xpos1:        
  2365.         ld c,a
  2366.         ld b,0
  2367.  
  2368. ;         LD BC,0
  2369. ;XPOS     EQU $-2
  2370. ;        LD HL,ZONEADR
  2371. ;        ADD HL,BC
  2372. ;        LD C,(HL)
  2373. ;        ld b,0
  2374.  
  2375.         ld (decrspr_offset),bc
  2376.  
  2377.         and a
  2378.         ld hl,30
  2379.         SBC hl,bc
  2380.         ld (dcrspr_len),hl
  2381.  
  2382.         call store8000c000
  2383.  
  2384.         ld a,(scr_buf1)
  2385.         SETPG8000
  2386.         ld a,(load_buf1)
  2387.         SETPGC000
  2388.  
  2389.         ld bc,(decrspr_offset)
  2390.         ld hl,0xc005
  2391.         add hl,bc
  2392.         ld de,0x8005
  2393.  
  2394.         ld b,148
  2395. decr_spr_lp1:
  2396.         push bc
  2397.  
  2398.         push hl
  2399.         push de
  2400.  
  2401.         ld bc,(dcrspr_len)
  2402.         call _iob
  2403.  
  2404.         pop hl ; (de)
  2405.         call DHL
  2406.         ex de,hl
  2407.         pop hl
  2408.         call DHL
  2409.  
  2410.         pop bc
  2411.         djnz decr_spr_lp1
  2412.  
  2413.  
  2414.         ld bc,(decrspr_offset)
  2415.         ld hl,0xe005
  2416.         add hl,bc
  2417.         ld de,0xa005
  2418.  
  2419.         ld b,148
  2420. decr_spr_lp2:
  2421.         push bc
  2422.  
  2423.         push hl
  2424.         push de
  2425.  
  2426.         ld bc,(dcrspr_len)
  2427.         call _iob
  2428.  
  2429.         pop hl ; (de)
  2430.         call DHL
  2431.         ex de,hl
  2432.         pop hl
  2433.         call DHL
  2434.  
  2435.         pop bc
  2436.         djnz decr_spr_lp2
  2437.  
  2438.  
  2439.         ld a,(scr_buf2)
  2440.         SETPG8000
  2441.         ld a,(load_buf2)
  2442.         SETPGC000
  2443.  
  2444.         ld bc,(decrspr_offset)
  2445.         ld hl,0xc005
  2446.         add hl,bc
  2447.         ld de,0x8005
  2448.  
  2449.         ld b,148
  2450. decr_spr_lp3:
  2451.         push bc
  2452.  
  2453.         push hl
  2454.         push de
  2455.  
  2456.         ld bc,(dcrspr_len)
  2457.         call _iob
  2458.  
  2459.         pop hl ; (de)
  2460.         call DHL
  2461.         ex de,hl
  2462.         pop hl
  2463.         call DHL
  2464.  
  2465.         pop bc
  2466.         djnz decr_spr_lp3
  2467.  
  2468.  
  2469.         ld bc,(decrspr_offset)
  2470.         ld hl,0xe005
  2471.         add hl,bc
  2472.         ld de,0xa005
  2473.  
  2474.         ld b,148
  2475. decr_spr_lp4:
  2476.         push bc
  2477.  
  2478.         push hl
  2479.         push de
  2480.  
  2481.         ld bc,(dcrspr_len)
  2482.         call _iob
  2483.  
  2484.         pop hl ; (de)
  2485.         call DHL
  2486.         ex de,hl
  2487.         pop hl
  2488.         call DHL
  2489.  
  2490.         pop bc
  2491.         djnz decr_spr_lp4
  2492.  
  2493.         jp restore8000c000
  2494. decrspr_offset dw 0 ;offset to draw sprite
  2495. dcrspr_len dw 0      ; cutted length
  2496. ;-----------------------
  2497. anim_wait:
  2498.         LD      A,0
  2499.         INC     A
  2500.         AND     3
  2501.         LD      (anim_wait+1),A
  2502.         RET     NZ
  2503.  
  2504.         call store8000c000
  2505.  
  2506.         ld a,(user_scr0_low) ;ok
  2507.         SETPG8000
  2508.  
  2509.         ld a,(user_scr0_high) ;ok
  2510.         SETPGC000
  2511.  
  2512.        
  2513.         ld hl,PUSH_DATA
  2514.         ld de,0x9e23-160
  2515.  
  2516.         ld a,0
  2517. FASE    equ $-1
  2518.  
  2519.         add a,a;x2
  2520.         add a,a;x4
  2521.         add a,a;x8
  2522.         add a,a;x16
  2523.         add a,a;x32
  2524.         ld c,a
  2525.         ld b,0
  2526.         add hl,bc        
  2527.        
  2528.         ex de,hl
  2529.      
  2530.  
  2531.         push hl
  2532.         ld b,8
  2533. export_push_iloop1:
  2534.         ld a,(de)
  2535.         ld (hl),a
  2536.         call DHL
  2537.         inc de
  2538.         djnz export_push_iloop1
  2539.         pop hl
  2540.  
  2541.         set 6,H
  2542.         push hl
  2543.         ld b,8
  2544. export_push_iloop2:
  2545.         ld a,(de)
  2546.         ld (hl),a
  2547.         call DHL
  2548.         inc de
  2549.         djnz export_push_iloop2
  2550.         pop hl
  2551.  
  2552.         res 6,H
  2553.         set 5,H
  2554.  
  2555.         push hl
  2556.         ld b,8
  2557. export_push_iloop3:
  2558.         ld a,(de)
  2559.         ld (hl),a
  2560.         call DHL
  2561.         inc de
  2562.         djnz export_push_iloop3
  2563.         pop hl
  2564.  
  2565.         set 6,H
  2566.  
  2567.         ld b,8
  2568. export_push_iloop4:
  2569.         ld a,(de)
  2570.         ld (hl),a
  2571.         call DHL
  2572.         inc de
  2573.         djnz export_push_iloop4
  2574.  
  2575.         ld a,(FASE)
  2576.         inc a
  2577.         and 7
  2578.         ld (FASE),a
  2579.  
  2580.         jp restore8000c000
  2581. ;-----------------------------
  2582. anim_eyes:
  2583.  
  2584.         LD      A,0
  2585.         INC     A
  2586.         AND     3
  2587.         LD      (anim_eyes+1),A
  2588.         RET     NZ
  2589.  
  2590.  
  2591.  
  2592.         OS_GETMAINPAGES
  2593.         ld a,e
  2594.         ld (im_stor_4000),a
  2595.         ld a,h
  2596.         ld (im_stor_8000),a
  2597.         ld a,l
  2598.         ld (im_stor_c000),a
  2599.  
  2600.         ld a,(font_page)
  2601.         SETPG4000
  2602.         ld a,(user_scr0_low) ;ok
  2603.         SETPG8000
  2604.         ld a,(user_scr0_high) ;ok
  2605.         SETPGC000
  2606.  
  2607.         ld a,(anim_stack_spr_num)
  2608.  
  2609.         ld ix,anim_stack
  2610.  
  2611. anim_eyes_loop:
  2612.         and a
  2613.         jp z,anim_eyes_exit
  2614.         push af        
  2615.  
  2616.         ld a,(ix+8)
  2617.         and a
  2618.         jr z,anim_eyes_mc
  2619.         dec a
  2620.         ld (ix+8),a
  2621.         jp anim_eyes_loop_cont
  2622.  
  2623.  
  2624.  
  2625. anim_eyes_mc:
  2626.             ;select sequence for anim
  2627.             ld a,(ix+6); type . 2 or 3 or 5
  2628.             ld hl,anim1_seq
  2629.             cp 2
  2630.             jr z,2f
  2631.             ld hl,anim2_seq
  2632.             cp 3
  2633.             jr z,2f
  2634.             ld hl,anim3_seq            
  2635.  
  2636.  
  2637. 2           ld (use_seq),hl
  2638.             ld a,(ix+7) ;current phase
  2639.  
  2640.             cp 0xfe ;need init?
  2641.             jr z,anim_mc_fe
  2642.  
  2643.  
  2644.             cp 0xff ;need init?
  2645.             jr nz,anim_mc_cont_print
  2646.  
  2647.             ld (ix+7),0
  2648.             call randr
  2649.             and 0x7f
  2650.             ;add a,a
  2651.             ld (ix+8),a              
  2652.             jp anim_eyes_loop_cont ;setup complete. skip to next anim
  2653.  
  2654.  
  2655.  
  2656. anim_mc_fe:
  2657.             ;initialize
  2658.  
  2659.             ;ld a,(hl)
  2660.             ;ld (ix+7),a
  2661.             ld (ix+7),0
  2662.             ld hl,(use_seq)
  2663.             inc hl
  2664.             ld a,(hl)
  2665.             ld (ix+8),a
  2666.             jp anim_eyes_loop_cont ;setup complete. skip to next anim
  2667.  
  2668. anim_mc_cont_print
  2669.             call anim_mc_print_sub
  2670.  
  2671.                     ;move cursor to next position
  2672.  
  2673. anim_mc_cont:
  2674.             ;move pointer to next
  2675.             ;a = ix+7 cursor position
  2676.             ld hl,(use_seq)
  2677.             ld a,(ix+7)
  2678.             inc a
  2679.             add a,a ; x2
  2680.             ld c,a
  2681.             ld b,0
  2682.             add hl,bc
  2683.             ld a,(hl)
  2684.  
  2685.             cp 0xfe
  2686.             jr c,anim_mc_cont_not_eof ;<254
  2687.  
  2688. anim_mc_cont_eof:
  2689.             ld (ix+7),a
  2690.             jr anim_eyes_loop_cont
  2691.  
  2692. anim_mc_cont_not_eof:
  2693.             inc (ix+7)
  2694.  
  2695. anim_eyes_loop_cont:
  2696.         ld bc,16
  2697.         add ix,bc   ;pointer to next anim
  2698.  
  2699.         pop af
  2700.         dec a
  2701.         jp anim_eyes_loop
  2702.  
  2703. anim_eyes_exit:
  2704.         ld a,0
  2705. im_stor_8000 equ $-1  
  2706.         SETPG8000
  2707.         ld a,0
  2708. im_stor_c000 equ $-1  
  2709.         SETPGC000
  2710.         ld a,0
  2711. im_stor_4000 equ $-1        
  2712.         SETPG4000
  2713.  
  2714.         ret
  2715. use_seq: dw 0
  2716.  
  2717. ;-----------------------------
  2718. anim_mc_print_sub:
  2719.                 ;calculate `skip` bytes
  2720.                 ld c,(ix+5);hgt
  2721.                 ld d,(ix+6)
  2722.                 dec d
  2723.                 call C_Time_D   ;c*d a=result
  2724.                 ld c,a
  2725.                 ld (anim_mc_skip_anim_frame),bc
  2726.  
  2727.  
  2728.  
  2729.                 ;calculate sprite start adress based on current frame
  2730.                 ld l,(ix+0);memory pos
  2731.                 ld h,(ix+1)
  2732.  
  2733.                 ld bc,0x4000;
  2734.                 and a;
  2735.                 sbc hl,bc;TODO - make refactor. store in stack 0x4000 based values
  2736.  
  2737.                 push hl
  2738.                
  2739.                 ld a,(ix+7)
  2740.                 add a,a ;!!!!x2
  2741.                 ld c,a
  2742.                 ld b,0
  2743.                 ld hl,(use_seq)
  2744.                 add hl,bc
  2745.                 ld d,(hl)  ;a = current fase sprite offset
  2746.  
  2747.                 ld c,(ix+5) ;hgt
  2748.                 call C_Time_D   ;c*d
  2749.                 ld c,a
  2750.                 pop hl
  2751.                 add hl,bc   ;hl sprite adress with vertical offset based on current frame
  2752.                 ld (anim_src),hl ;prepare sprite src adress
  2753.  
  2754.  
  2755.  
  2756.  
  2757.                 ld l,(ix+2);screen pos
  2758.                 ld h,(ix+3)
  2759.  
  2760.                 ld de,0
  2761. anim_src    equ $-2
  2762.                 ld b,(ix+4) ;len
  2763.                 srl b
  2764. anim_eyes_inner_loop:
  2765.                 push bc
  2766.  
  2767.                         ;hl ega scr addr
  2768.                         push hl
  2769.                         ld b,(ix+5) ;hgt
  2770. anim_eyes_inner_loop2:
  2771.                         push bc  
  2772.  
  2773.                         call _iob_byte
  2774.  
  2775.                         inc de
  2776.                         call DHL
  2777.  
  2778.                         pop bc
  2779.                         djnz anim_eyes_inner_loop2
  2780.  
  2781.                         pop hl
  2782.                         call p_nextcolumn
  2783.  
  2784.                         ;skip to next column of current frame
  2785.                         ex de,hl
  2786.                         ld bc,0
  2787. anim_mc_skip_anim_frame: equ $-2
  2788.                         add hl,bc
  2789.                         ex de,hl
  2790.  
  2791.  
  2792.                 pop bc
  2793.                 djnz anim_eyes_inner_loop
  2794.  
  2795.                 ret
  2796.  
  2797. ;---
  2798. ;in hl - x-coord 0-319
  2799. ;;out hl -adress in 8000 - ffff atm2 ega screen (x-offset)
  2800. p_calc_x:
  2801.         and a
  2802.         rr h
  2803.         rr l
  2804.         ld a,l
  2805.         rrca
  2806.         rrca
  2807.         ld h,0
  2808.         and a
  2809.         push af
  2810.         rla
  2811.         rr h
  2812.         rla
  2813.         rr h
  2814.         scf
  2815.         rr h
  2816.         pop af
  2817.         and 0x3f
  2818.         ld l,a
  2819.         ret
  2820. ;=============================================      
  2821. ;in hl - x-adress in atm2 ega screen
  2822. ;   a - y coord - 0-199
  2823. ;;out hl -adress in 8000 - ffff atm2 ega screen (xy offset)
  2824. p_calc_y:
  2825.         ld bc,40
  2826. p_calc_y_loop:
  2827.         and a
  2828.         ret z
  2829.         add hl,bc
  2830.         dec a
  2831.         jr p_calc_y_loop        
  2832. ;=============================================      
  2833. p_nextcolumn:
  2834.         bit 6,h
  2835.         set 6,h
  2836.         jr z,1f;shapes_linehorR_incxok
  2837.         ld a,h
  2838.         xor 0x60
  2839.         ld h,a
  2840.         and 0x20
  2841.         jr nz,1f;shapes_linehorR_incxok
  2842.         inc hl
  2843. 1 ;shapes_linehorR_incxok
  2844.     ret
  2845. ;---------------------------------------
  2846.