?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 %00010010;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 %00010010;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 %00010010;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 %00010010;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. FLASH
  2086.         ld b,(hl)
  2087.         inc hl
  2088.         push hl
  2089.  
  2090.         push bc
  2091.  
  2092.         ld hl,pal
  2093.         ld de,temppal
  2094.         ld bc,32
  2095.         ldir
  2096.  
  2097.         pop bc
  2098.  
  2099. FLASH_LP:
  2100.         push bc
  2101.  
  2102.         ld hl,whitepal
  2103.         ld de,pal
  2104.         ld bc,32
  2105.         ldir
  2106.  
  2107.         ld a,1
  2108.         ld (setpalflag),a
  2109.  
  2110.         halt
  2111.         halt
  2112.         halt
  2113.         halt
  2114.         halt
  2115.  
  2116.  
  2117.         ld hl,temppal
  2118.         ld de,pal
  2119.         ld bc,32
  2120.         ldir
  2121.  
  2122.         ld a,1
  2123.         ld (setpalflag),a
  2124.  
  2125.         halt
  2126.         halt
  2127.         halt
  2128.         halt
  2129.         halt
  2130.  
  2131.         pop bc
  2132.         djnz FLASH_LP
  2133.         pop hl
  2134.         jp _print
  2135.  
  2136.  
  2137. SHAKE:
  2138.         ld b,(hl)
  2139.         inc hl
  2140.  
  2141.         push hl
  2142.         push bc
  2143.  
  2144.         call store8000c000
  2145.  
  2146.         ld a,(user_scr0_low) ;ok
  2147.         SETPG8000
  2148.         ld a,(user_scr1_low) ;ok
  2149.         SETPGC000
  2150.  
  2151.         ld hl,0x8000+320
  2152.         ld de,0xc000
  2153.         ld bc,8000-320
  2154.         ldir
  2155.         ;ld hl,0x8000
  2156.         ;ld bc,320
  2157.         ;ldir
  2158.  
  2159.         ld hl,0xa000+320
  2160.         ld de,0xe000
  2161.         ld bc,8000-320
  2162.         ldir
  2163.         ;ld hl,0xa000
  2164.         ;ld bc,320
  2165.         ;ldir
  2166.  
  2167.  
  2168.         ld a,(user_scr0_high) ;ok
  2169.         SETPG8000
  2170.         ld a,(user_scr1_high) ;ok
  2171.         SETPGC000
  2172.  
  2173.         ld hl,0x8000+320
  2174.         ld de,0xc000
  2175.         ld bc,8000-320
  2176.         ldir
  2177.         ;ld hl,0x8000
  2178.         ;ld bc,320
  2179.         ;ldir
  2180.  
  2181.         ld hl,0xa000+320
  2182.         ld de,0xe000
  2183.         ld bc,8000-320
  2184.         ldir
  2185.         ;ld hl,0xa000
  2186.         ;ld bc,320
  2187.         ;ldir
  2188.  
  2189.  
  2190.         pop bc
  2191. SHAKE_LP:
  2192.         push bc
  2193.  
  2194.         ld e,1
  2195.         OS_SETSCREEN
  2196.  
  2197.         halt
  2198.         halt
  2199.         halt
  2200.         halt
  2201.         halt
  2202.  
  2203.         ld e,0
  2204.         OS_SETSCREEN
  2205.  
  2206.         halt
  2207.         halt
  2208.         halt
  2209.         halt
  2210.         halt
  2211.  
  2212.         pop bc
  2213.         djnz SHAKE_LP
  2214.  
  2215.         call restore8000c000
  2216.         pop hl
  2217.         jp _print
  2218. ;;;;;;;;;;;;;;;;;;;;;;
  2219. ;-----------------------
  2220. _prt_ingame_menu:
  2221.         ld bc,0
  2222. _ingame_m_mnpos: equ $-2
  2223.         call _pradd
  2224. prt_ingame_m1:
  2225.         ld a,(hl)
  2226.         inc hl
  2227.         and a
  2228.         RET Z
  2229.         cp 1
  2230.         JR Z,prt_ingame_m2
  2231.         cp 128
  2232.         call nc,change_cp
  2233.         CP "#"
  2234.         call z,change_cp1
  2235.         CP "@"
  2236.         call z,change_cp2        
  2237.         SUB 32
  2238.         PUSH HL
  2239.         CALL _type
  2240.         POP HL
  2241.         JR prt_ingame_m1
  2242. prt_ingame_m2:
  2243.         LD A,(_ingame_m_mnpos) ;x-coord
  2244.         add a,16
  2245.         ld (_ingame_m_mnpos),a
  2246.         cp 64
  2247.         jr c,_prt_ingame_menu
  2248.         and 0x3f
  2249.         LD (_ingame_m_mnpos),A
  2250.         ld a,(_ingame_m_mnpos+1)
  2251.         inc a
  2252.         ld (_ingame_m_mnpos+1),a
  2253.         JR _prt_ingame_menu
  2254. ;------------------------------------
  2255.  
  2256. _sel_ingame_menu:
  2257.         ld a,0
  2258. _ingame_m_curpos equ $-1
  2259.         ld hl,MENUCURHELPER
  2260.         call sel_word
  2261.         ld (_sel_ingame_SELS4),hl
  2262.         call _highlight_selected
  2263. _sel_ingame_SELS3:        
  2264.         call waitkey
  2265.  
  2266.         cp key_esc
  2267.         jp z,_sel_ingame_esc
  2268.  
  2269.         cp key_left
  2270.         jr z,_sel_ingame_SELS_keyleft
  2271.         cp key_right
  2272.         jr z,_sel_ingame_SELS_keyright
  2273.  
  2274.         cp key_up
  2275.         jr z,_sel_ingame_SELS_keyup
  2276.         cp key_down
  2277.         jr z,_sel_ingame_SELS_keydown
  2278.  
  2279.         cp key_enter
  2280.         jr z,_sel_ingame_SELECTED
  2281.         cp ' '
  2282.         jr z,_sel_ingame_SELECTED
  2283.         jr _sel_ingame_SELS3        
  2284. _sel_ingame_esc:
  2285.         ld hl,0
  2286. _sel_ingame_SELS4: equ $-2
  2287.         call _highlight_selected
  2288.         ld a,0xff
  2289.         ret
  2290. _sel_ingame_SELS_keyleft:
  2291.         ld hl,(_sel_ingame_SELS4)
  2292.         call _highlight_selected
  2293.  
  2294.         ld hl,_ingame_m_curpos
  2295.         ld a,(hl)
  2296.         and a
  2297.         jp z,_sel_ingame_menu
  2298.         dec (HL)
  2299.         jp _sel_ingame_menu
  2300.  
  2301.  
  2302. _sel_ingame_SELS_keyright:
  2303.         ld hl,(_sel_ingame_SELS4)
  2304.         call _highlight_selected
  2305.         ld hl,_ingame_m_curpos
  2306.         ld a,(hl)
  2307.  
  2308.         cp 0
  2309. _ingame_m_downlimit: EQU $-1        
  2310.  
  2311.         jp nc,_sel_ingame_menu
  2312.         inc (hl)
  2313.         jp _sel_ingame_menu
  2314. _sel_ingame_SELECTED:
  2315.         ld hl,(_sel_ingame_SELS4)
  2316.         call _highlight_selected
  2317.         ld a,(_ingame_m_curpos)
  2318.         ret
  2319.  
  2320.  
  2321. _sel_ingame_SELS_keyup:
  2322.         ld hl,(_sel_ingame_SELS4)
  2323.         call _highlight_selected
  2324.  
  2325.  
  2326.         ld hl,_ingame_m_curpos
  2327.         ld a,(hl)
  2328.         sub 4
  2329.         jp m,_sel_ingame_menu        
  2330.         ld (hl),a
  2331.         jp _sel_ingame_menu
  2332.  
  2333. _sel_ingame_SELS_keydown:
  2334.         ld hl,(_sel_ingame_SELS4)
  2335.         call _highlight_selected
  2336.  
  2337.         ld a,(_ingame_m_downlimit)
  2338.         inc a
  2339.         ld b,a
  2340.  
  2341.         ld hl,_ingame_m_curpos
  2342.         ld a,(hl)
  2343.         add a,4
  2344.         sub b      
  2345.         jp p,_sel_ingame_menu        
  2346.         add a,b
  2347.         ld (hl),a
  2348.  
  2349.         jp _sel_ingame_menu
  2350. ;;;;;;;;;;;;;;;;;;;;;;
  2351. DECR_SPR:
  2352.  
  2353.         ld a,0
  2354. XPOS    EQU $-1
  2355.         SRL A
  2356.         jr nc,xpos1
  2357.         inc a
  2358. xpos1:        
  2359.         ld c,a
  2360.         ld b,0
  2361.  
  2362. ;         LD BC,0
  2363. ;XPOS     EQU $-2
  2364. ;        LD HL,ZONEADR
  2365. ;        ADD HL,BC
  2366. ;        LD C,(HL)
  2367. ;        ld b,0
  2368.  
  2369.         ld (decrspr_offset),bc
  2370.  
  2371.         and a
  2372.         ld hl,30
  2373.         SBC hl,bc
  2374.         ld (dcrspr_len),hl
  2375.  
  2376.         call store8000c000
  2377.  
  2378.         ld a,(scr_buf1)
  2379.         SETPG8000
  2380.         ld a,(load_buf1)
  2381.         SETPGC000
  2382.  
  2383.         ld bc,(decrspr_offset)
  2384.         ld hl,0xc005
  2385.         add hl,bc
  2386.         ld de,0x8005
  2387.  
  2388.         ld b,148
  2389. decr_spr_lp1:
  2390.         push bc
  2391.  
  2392.         push hl
  2393.         push de
  2394.  
  2395.         ld bc,(dcrspr_len)
  2396.         call _iob
  2397.  
  2398.         pop hl ; (de)
  2399.         call DHL
  2400.         ex de,hl
  2401.         pop hl
  2402.         call DHL
  2403.  
  2404.         pop bc
  2405.         djnz decr_spr_lp1
  2406.  
  2407.  
  2408.         ld bc,(decrspr_offset)
  2409.         ld hl,0xe005
  2410.         add hl,bc
  2411.         ld de,0xa005
  2412.  
  2413.         ld b,148
  2414. decr_spr_lp2:
  2415.         push bc
  2416.  
  2417.         push hl
  2418.         push de
  2419.  
  2420.         ld bc,(dcrspr_len)
  2421.         call _iob
  2422.  
  2423.         pop hl ; (de)
  2424.         call DHL
  2425.         ex de,hl
  2426.         pop hl
  2427.         call DHL
  2428.  
  2429.         pop bc
  2430.         djnz decr_spr_lp2
  2431.  
  2432.  
  2433.         ld a,(scr_buf2)
  2434.         SETPG8000
  2435.         ld a,(load_buf2)
  2436.         SETPGC000
  2437.  
  2438.         ld bc,(decrspr_offset)
  2439.         ld hl,0xc005
  2440.         add hl,bc
  2441.         ld de,0x8005
  2442.  
  2443.         ld b,148
  2444. decr_spr_lp3:
  2445.         push bc
  2446.  
  2447.         push hl
  2448.         push de
  2449.  
  2450.         ld bc,(dcrspr_len)
  2451.         call _iob
  2452.  
  2453.         pop hl ; (de)
  2454.         call DHL
  2455.         ex de,hl
  2456.         pop hl
  2457.         call DHL
  2458.  
  2459.         pop bc
  2460.         djnz decr_spr_lp3
  2461.  
  2462.  
  2463.         ld bc,(decrspr_offset)
  2464.         ld hl,0xe005
  2465.         add hl,bc
  2466.         ld de,0xa005
  2467.  
  2468.         ld b,148
  2469. decr_spr_lp4:
  2470.         push bc
  2471.  
  2472.         push hl
  2473.         push de
  2474.  
  2475.         ld bc,(dcrspr_len)
  2476.         call _iob
  2477.  
  2478.         pop hl ; (de)
  2479.         call DHL
  2480.         ex de,hl
  2481.         pop hl
  2482.         call DHL
  2483.  
  2484.         pop bc
  2485.         djnz decr_spr_lp4
  2486.  
  2487.         jp restore8000c000
  2488. decrspr_offset dw 0 ;offset to draw sprite
  2489. dcrspr_len dw 0      ; cutted length
  2490. ;-----------------------
  2491. anim_wait:
  2492.         LD      A,0
  2493.         INC     A
  2494.         AND     3
  2495.         LD      (anim_wait+1),A
  2496.         RET     NZ
  2497.  
  2498.         call store8000c000
  2499.  
  2500.         ld a,(user_scr0_low) ;ok
  2501.         SETPG8000
  2502.  
  2503.         ld a,(user_scr0_high) ;ok
  2504.         SETPGC000
  2505.  
  2506.        
  2507.         ld hl,PUSH_DATA
  2508.         ld de,0x9e23-160
  2509.  
  2510.         ld a,0
  2511. FASE    equ $-1
  2512.  
  2513.         add a,a;x2
  2514.         add a,a;x4
  2515.         add a,a;x8
  2516.         add a,a;x16
  2517.         add a,a;x32
  2518.         ld c,a
  2519.         ld b,0
  2520.         add hl,bc        
  2521.        
  2522.         ex de,hl
  2523.      
  2524.  
  2525.         push hl
  2526.         ld b,8
  2527. export_push_iloop1:
  2528.         ld a,(de)
  2529.         ld (hl),a
  2530.         call DHL
  2531.         inc de
  2532.         djnz export_push_iloop1
  2533.         pop hl
  2534.  
  2535.         set 6,H
  2536.         push hl
  2537.         ld b,8
  2538. export_push_iloop2:
  2539.         ld a,(de)
  2540.         ld (hl),a
  2541.         call DHL
  2542.         inc de
  2543.         djnz export_push_iloop2
  2544.         pop hl
  2545.  
  2546.         res 6,H
  2547.         set 5,H
  2548.  
  2549.         push hl
  2550.         ld b,8
  2551. export_push_iloop3:
  2552.         ld a,(de)
  2553.         ld (hl),a
  2554.         call DHL
  2555.         inc de
  2556.         djnz export_push_iloop3
  2557.         pop hl
  2558.  
  2559.         set 6,H
  2560.  
  2561.         ld b,8
  2562. export_push_iloop4:
  2563.         ld a,(de)
  2564.         ld (hl),a
  2565.         call DHL
  2566.         inc de
  2567.         djnz export_push_iloop4
  2568.  
  2569.         ld a,(FASE)
  2570.         inc a
  2571.         and 7
  2572.         ld (FASE),a
  2573.  
  2574.         jp restore8000c000
  2575. ;-----------------------------
  2576. anim_eyes:
  2577.  
  2578.         LD      A,0
  2579.         INC     A
  2580.         AND     3
  2581.         LD      (anim_eyes+1),A
  2582.         RET     NZ
  2583.  
  2584.  
  2585.  
  2586.         OS_GETMAINPAGES
  2587.         ld a,e
  2588.         ld (im_stor_4000),a
  2589.         ld a,h
  2590.         ld (im_stor_8000),a
  2591.         ld a,l
  2592.         ld (im_stor_c000),a
  2593.  
  2594.         ld a,(font_page)
  2595.         SETPG4000
  2596.         ld a,(user_scr0_low) ;ok
  2597.         SETPG8000
  2598.         ld a,(user_scr0_high) ;ok
  2599.         SETPGC000
  2600.  
  2601.         ld a,(anim_stack_spr_num)
  2602.  
  2603.         ld ix,anim_stack
  2604.  
  2605. anim_eyes_loop:
  2606.         and a
  2607.         jp z,anim_eyes_exit
  2608.         push af        
  2609.  
  2610.         ld a,(ix+8)
  2611.         and a
  2612.         jr z,anim_eyes_mc
  2613.         dec a
  2614.         ld (ix+8),a
  2615.         jp anim_eyes_loop_cont
  2616.  
  2617.  
  2618.  
  2619. anim_eyes_mc:
  2620.             ;select sequence for anim
  2621.             ld hl,anim1_seq
  2622.             ld a,(ix+6); type . 2 or 3
  2623.             cp 2
  2624.             jr z,1f
  2625.             ld hl,anim2_seq
  2626. 1           ld (use_seq),hl
  2627.  
  2628.             ld a,(ix+7) ;current phase
  2629.  
  2630.             cp 0xfe ;need init?
  2631.             jr z,anim_mc_fe
  2632.  
  2633.  
  2634.             cp 0xff ;need init?
  2635.             jr nz,anim_mc_cont_print
  2636.  
  2637.             ld (ix+7),0
  2638.             call randr
  2639.             and 0x7f
  2640.             ;add a,a
  2641.             ld (ix+8),a              
  2642.             jp anim_eyes_loop_cont ;setup complete. skip to next anim
  2643.  
  2644.  
  2645.  
  2646. anim_mc_fe:
  2647.             ;initialize
  2648.  
  2649.             ;ld a,(hl)
  2650.             ;ld (ix+7),a
  2651.             ld (ix+7),0
  2652.             ld hl,(use_seq)
  2653.             inc hl
  2654.             ld a,(hl)
  2655.             ld (ix+8),a
  2656.             jp anim_eyes_loop_cont ;setup complete. skip to next anim
  2657.  
  2658. anim_mc_cont_print
  2659.             call anim_mc_print_sub
  2660.  
  2661.                     ;move cursor to next position
  2662.  
  2663. anim_mc_cont:
  2664.             ;move pointer to next
  2665.             ;a = ix+7 cursor position
  2666.             ld hl,(use_seq)
  2667.             ld a,(ix+7)
  2668.             inc a
  2669.             add a,a ; x2
  2670.             ld c,a
  2671.             ld b,0
  2672.             add hl,bc
  2673.             ld a,(hl)
  2674.  
  2675.             cp 0xfe
  2676.             jr c,anim_mc_cont_not_eof ;<254
  2677.  
  2678. anim_mc_cont_eof:
  2679.             ld (ix+7),a
  2680.             jr anim_eyes_loop_cont
  2681.  
  2682. anim_mc_cont_not_eof:
  2683.             inc (ix+7)
  2684.  
  2685. anim_eyes_loop_cont:
  2686.         ld bc,16
  2687.         add ix,bc   ;pointer to next anim
  2688.  
  2689.         pop af
  2690.         dec a
  2691.         jp anim_eyes_loop
  2692.  
  2693. anim_eyes_exit:
  2694.         ld a,0
  2695. im_stor_8000 equ $-1  
  2696.         SETPG8000
  2697.         ld a,0
  2698. im_stor_c000 equ $-1  
  2699.         SETPGC000
  2700.         ld a,0
  2701. im_stor_4000 equ $-1        
  2702.         SETPG4000
  2703.  
  2704.         ret
  2705. use_seq: dw 0
  2706.  
  2707. ;-----------------------------
  2708. anim_mc_print_sub:
  2709.                 ;calculate `skip` bytes
  2710.                 ld c,(ix+5);hgt
  2711.                 ld d,(ix+6)
  2712.                 dec d
  2713.                 call C_Time_D   ;c*d a=result
  2714.                 ld c,a
  2715.                 ld (anim_mc_skip_anim_frame),bc
  2716.  
  2717.  
  2718.  
  2719.                 ;calculate sprite start adress based on current frame
  2720.                 ld l,(ix+0);memory pos
  2721.                 ld h,(ix+1)
  2722.  
  2723.                 ld bc,0x4000;
  2724.                 and a;
  2725.                 sbc hl,bc;TODO - make refactor. store in stack 0x4000 based values
  2726.  
  2727.                 push hl
  2728.                
  2729.                 ld a,(ix+7)
  2730.                 add a,a ;!!!!x2
  2731.                 ld c,a
  2732.                 ld b,0
  2733.                 ld hl,(use_seq)
  2734.                 add hl,bc
  2735.                 ld d,(hl)  ;a = current fase sprite offset
  2736.  
  2737.                 ld c,(ix+5) ;hgt
  2738.                 call C_Time_D   ;c*d
  2739.                 ld c,a
  2740.                 pop hl
  2741.                 add hl,bc   ;hl sprite adress with vertical offset based on current frame
  2742.                 ld (anim_src),hl ;prepare sprite src adress
  2743.  
  2744.  
  2745.  
  2746.  
  2747.                 ld l,(ix+2);screen pos
  2748.                 ld h,(ix+3)
  2749.  
  2750.                 ld de,0
  2751. anim_src    equ $-2
  2752.                 ld b,(ix+4) ;len
  2753.                 srl b
  2754. anim_eyes_inner_loop:
  2755.                 push bc
  2756.  
  2757.                         ;hl ega scr addr
  2758.                         push hl
  2759.                         ld b,(ix+5) ;hgt
  2760. anim_eyes_inner_loop2:
  2761.                         push bc  
  2762.  
  2763.                         call _iob_byte
  2764.  
  2765.                         inc de
  2766.                         call DHL
  2767.  
  2768.                         pop bc
  2769.                         djnz anim_eyes_inner_loop2
  2770.  
  2771.                         pop hl
  2772.                         call p_nextcolumn
  2773.  
  2774.                         ;skip to next column of current frame
  2775.                         ex de,hl
  2776.                         ld bc,0
  2777. anim_mc_skip_anim_frame: equ $-2
  2778.                         add hl,bc
  2779.                         ex de,hl
  2780.  
  2781.  
  2782.                 pop bc
  2783.                 djnz anim_eyes_inner_loop
  2784.  
  2785.                 ret
  2786.  
  2787. ;---
  2788. ;in hl - x-coord 0-319
  2789. ;;out hl -adress in 8000 - ffff atm2 ega screen (x-offset)
  2790. p_calc_x:
  2791.         and a
  2792.         rr h
  2793.         rr l
  2794.         ld a,l
  2795.         rrca
  2796.         rrca
  2797.         ld h,0
  2798.         and a
  2799.         push af
  2800.         rla
  2801.         rr h
  2802.         rla
  2803.         rr h
  2804.         scf
  2805.         rr h
  2806.         pop af
  2807.         and 0x3f
  2808.         ld l,a
  2809.         ret
  2810. ;=============================================      
  2811. ;in hl - x-adress in atm2 ega screen
  2812. ;   a - y coord - 0-199
  2813. ;;out hl -adress in 8000 - ffff atm2 ega screen (xy offset)
  2814. p_calc_y:
  2815.         ld bc,40
  2816. p_calc_y_loop:
  2817.         and a
  2818.         ret z
  2819.         add hl,bc
  2820.         dec a
  2821.         jr p_calc_y_loop        
  2822. ;=============================================      
  2823. p_nextcolumn:
  2824.         bit 6,h
  2825.         set 6,h
  2826.         jr z,1f;shapes_linehorR_incxok
  2827.         ld a,h
  2828.         xor 0x60
  2829.         ld h,a
  2830.         and 0x20
  2831.         jr nz,1f;shapes_linehorR_incxok
  2832.         inc hl
  2833. 1 ;shapes_linehorR_incxok
  2834.     ret
  2835. ;---------------------------------------
  2836.