Subversion Repositories NedoOS

Rev

Rev 2234 | Blame | Compare with Previous | Last modification | View Log | Download

  1.         DEVICE ZXSPECTRUM48
  2.         include "../_sdk/sys_h.asm"
  3.  
  4.  
  5.         macro BRIGHTBYTE x
  6. _=x
  7.         if _>15
  8. _=15
  9.         endif
  10. _g0=~_&1
  11. _g1=(~_>>1)&1
  12. _g2=(~_>>2)&1
  13. _g3=(~_>>3)&1
  14. ;0g20G3G3
  15.         ;db _
  16.         db (_g0<<6)+(_g2<<5)+(_g1<<3)+(_g3<<2)+(_g1<<1)+(_g3<<0)
  17.         endm
  18.  
  19.  
  20.  
  21.         org PROGSTART
  22. cmd_begin
  23.         ld sp,0x4000
  24.  
  25.  
  26.  
  27.  
  28.         ld e,6+0x80  //set TEXT mode  keep
  29.         OS_SETGFX
  30.        
  31.         ld e,0
  32.         OS_CLS
  33.  
  34.  
  35.  
  36.  
  37.         OS_GETMAINPAGES
  38.         ;dehl= o 0000,4000,8000,c000
  39.         ld a,d
  40.         ld (winpage0),a
  41.         ld a,e
  42.         ld (winpage1),a
  43.         ld a,h
  44.         ld (winpage2),a
  45.         ld a,l
  46.         ld (winpage3),a
  47.  
  48.         ;d=pgmain0000
  49.         call dropotherapps ;OS_HIDEFROMPARENT
  50.         call setpgsmain4000_C000
  51.  
  52.  
  53.  
  54.         ld de,res_path
  55.         OS_CHDIR
  56.         or a
  57.         jp nz,dirchangeerror
  58.  
  59.  
  60.         OS_NEWPAGE
  61.         or a
  62.         jp nz,memoryerror
  63.         ld a,e
  64.         ld (winpage11),a
  65.  
  66.  
  67.         OS_NEWPAGE
  68.         or a
  69.         jp nz,memoryerror
  70.         ld a,e
  71.         ld (winpage13),a
  72.  
  73.         OS_NEWPAGE
  74.         or a
  75.         jp nz,memoryerror
  76.         ld a,e
  77.         ld (winpage14),a
  78.  
  79.         OS_NEWPAGE
  80.         or a
  81.         jp nz,memoryerror
  82.         ld a,e
  83.         ld (winpage16),a
  84.  
  85.         OS_NEWPAGE
  86.         or a
  87.         jp nz,memoryerror
  88.         ld a,e
  89.         ld (winpage17),a
  90.  
  91.  
  92.         OS_NEWPAGE
  93.         or a
  94.         jp nz,memoryerror
  95.         ld a,e
  96.         ld (vidbuf),a
  97.  
  98.  
  99. ;-------------pre-setup. choose game version
  100.         ld hl,pre_setup
  101.         call print_hl
  102.  
  103. setup_lp:        
  104.         YIELDGETKEYLOOP
  105.         cp "1"
  106.         jr z,setup_is1
  107.         cp "2"
  108.         jr z,setup_is2
  109.         jr setup_lp
  110. setup_is1:
  111.           xor a
  112.           jr setup_set
  113. setup_is2:
  114.          ld a,1
  115.           jr setup_set
  116. setup_set:
  117.         ld (mode),a
  118.  
  119.         and a
  120.         jp z,skip_dfclt_setup
  121.  
  122. ;---------------------------------------------------
  123.         ld hl,difficulty_setup
  124.         call print_hl
  125. setup_df:        
  126.         YIELDGETKEYLOOP
  127.         cp "1"
  128.         jr z,setup_df1
  129.         cp "2"
  130.         jr z,setup_df2
  131.         cp "3"
  132.         jr z,setup_df3
  133.         cp "4"
  134.         jr z,setup_df4
  135.         jr setup_lp
  136. setup_df1:
  137.           xor a
  138.           jr setup_df_set
  139. setup_df2:
  140.          ld a,1
  141.           jr setup_df_set
  142. setup_df3:
  143.          ld a,2
  144.           jr setup_df_set
  145. setup_df4:
  146.          ld a,3
  147.           jr setup_df_set
  148. setup_df_set:
  149.         ld (difficulty),a
  150. ;---------------------------------------------------
  151.  
  152. skip_dfclt_setup:
  153.         ld a,(mode)
  154.         and a
  155.         jp z,scr_unmodded
  156. ; modded - load ega screen        
  157.  
  158.                         ld e,0+0x80  //set EGA mode  keep
  159.                         OS_SETGFX
  160.                        
  161.                         ld e,0
  162.                         OS_CLS
  163.                        
  164.                         ld de,blackpal
  165.                         OS_SETPAL
  166.                        
  167.                        
  168.                         ld a,(user_scr1_low)
  169.                         SETPG8000
  170.                         ld a,(user_scr1_high)
  171.                         SETPGC000
  172.  
  173.                         ld e,1
  174.                         OS_SETSCREEN
  175.  
  176.                          ld de,scr16c
  177.                          call openstream_file
  178.                          ld hl,0x8000 ;len
  179.                          ld de,0x8000 ;where
  180.                          call readstream_file
  181.                          ld hl,32
  182.                          ld de,pal
  183.                          call readstream_file
  184.                          call closestream_file
  185.                
  186.                           call palette_precalc
  187.                           call fade_fromblack
  188.  
  189.  
  190.  
  191.                         ld e,0+8+0x80  //set EGA no turbo mode  keep
  192.                         OS_SETGFX
  193.                        
  194.                         jp cont_load1
  195.  
  196. scr_unmodded:
  197.                                 ;set mode
  198.                                 ld e,3+0x80  //set 6912 mode keep
  199.                                 OS_SETGFX
  200.                        
  201.                        
  202.                                 ld a,(user_scr0_high)
  203.                                 SETPG4000
  204.                                 ld a,(winpage2)
  205.                                 SETPG8000
  206.                        
  207.                                  ld e,0
  208.                                  OS_CLS
  209.                                  ld e,0
  210.                                  OS_SETSCREEN
  211.                                  ld de,stdpal
  212.                                  OS_SETPAL  
  213.  
  214.  
  215.                                 ld hl,0x4000
  216.                                 ld de,0x4001
  217.                                 ld (hl),l
  218.                                 ld bc,6143
  219.                                 ldir        
  220.  
  221.  
  222.                                 ld hl,0x5800
  223.                                 ld de,0x5801
  224.                                 ld (hl),l
  225.                                 ld bc,767
  226.                                 ldir
  227.  
  228.  
  229.                                  ld de,scr6912
  230.                                  call openstream_file
  231.                                          ld hl,6144 ;len
  232.                                          ld de,0x4000 ;where
  233.                                          call readstream_file
  234.                        
  235.                                          ld hl,768
  236.                                          ld de,0x8000 ;where
  237.                                          call readstream_file
  238.                                  call closestream_file
  239.  
  240.  
  241.                                 ld e,3+8+0x80  //set 6912 mode keep
  242.                                 OS_SETGFX
  243.                                 call fade_fromblack6912
  244. cont_load1:
  245.          ld a,(winpage11)
  246.          SETPGC000
  247.          ld de,f_name11
  248.          call openstream_file
  249.          ld hl,0x4000 ;len
  250.          ld de,0xc000 ;where
  251.          call readstream_file
  252.          call closestream_file
  253.  
  254. ;-------------ram11 patch
  255.                ld a,(mode)
  256.                 and a
  257.                 jr z,skip_ram11_patch
  258.                                 ;org 0xc35c
  259.                                 ;call inert
  260.                         ld de,inert
  261.                         ld hl,0xc35c
  262.                         ld (hl),0xcd
  263.                         inc hl:ld (hl),e
  264.                         inc hl:ld (hl),d
  265.  
  266.  
  267.                   ld de,set_next_difficulty
  268.                   ld hl,0xc347
  269.                   ld (hl),0x00 : inc hl
  270.                   ld (hl),0x00 : inc hl
  271.                   ld (hl),0x00 : inc hl
  272.                   ld (hl),0xcd : inc hl
  273.                   ld (hl),e    : inc hl
  274.                   ld (hl),d    : inc hl
  275. ;------------------------------------------
  276. skip_ram11_patch:
  277.  
  278.          ld a,(winpage13)
  279.          SETPGC000
  280.          ld de,f_name13
  281.          call openstream_file
  282.          ld hl,0x4000 ;len
  283.          ld de,0xc000 ;where
  284.          call readstream_file
  285.          call closestream_file
  286. ;-------------ram 13 patch
  287.                             ;org 0xe060
  288.                             ;ld b,6   ;menu lines count+1
  289.                             ;ld hl,controls_menu
  290.                
  291.                             ;org 0xe075
  292.                             ;jp menu_keyscan_mod
  293.  
  294.                 ld de,controls_menu
  295.                 ld hl,0xe060
  296.                 ld (hl),6
  297.                 inc hl
  298.                 ld (hl),6
  299.                 inc hl:ld (hl),0x21
  300.                 inc hl:ld (hl),e
  301.                 inc hl:ld (hl),d
  302.  
  303.                 ld de,menu_keyscan_mod
  304.                 ld hl,0xe075
  305.                 ld (hl),0xc3
  306.                 inc hl:ld (hl),e
  307.                 inc hl:ld (hl),d
  308.  
  309.  
  310.                   ld de,set_difficulty
  311.                   ld hl,0xe251
  312.                   ld (hl),0x00 : inc hl
  313.                   ld (hl),0x00 : inc hl
  314.                   ld (hl),0x00 : inc hl
  315.                   ld (hl),0xcd : inc hl
  316.                   ld (hl),e    : inc hl
  317.                   ld (hl),d    : inc hl
  318. ;------------------------------------------
  319.          ld a,(winpage14)
  320.          SETPGC000
  321.          ld de,f_name14
  322.          call openstream_file
  323.          ld hl,0x4000 ;len
  324.          ld de,0xc000 ;where
  325.          call readstream_file
  326.          call closestream_file
  327.  
  328.  
  329.          ld a,(winpage16)
  330.          SETPGC000
  331.          ld de,f_name16
  332.          call openstream_file
  333.          ld hl,0x4000 ;len
  334.          ld de,0xc000 ;where
  335.          call readstream_file
  336.          call closestream_file
  337.  
  338. ;-------------ram16 patch
  339.                ld a,(mode)
  340.                 and a
  341.                 jr z,skip_ram16_patch
  342.                         ld de,fix_stun_ram16_1
  343.                         ld hl,0xe6fa
  344.                         ld (hl),0xcd : inc hl
  345.                         ld (hl),e    : inc hl
  346.                         ld (hl),d
  347.  
  348.                         ld de,fix_stun_ram16_2
  349.                         ld hl,0xe70a
  350.                         ld (hl),0xcd : inc hl
  351.                         ld (hl),e    : inc hl
  352.                         ld (hl),d
  353. ;------------------------------------------
  354. skip_ram16_patch:
  355.          ld a,(winpage17)
  356.          SETPGC000
  357.          ld de,f_name17
  358.          call openstream_file
  359.          ld hl,0x4000 ;len
  360.          ld de,0xc000 ;where
  361.          call readstream_file
  362.          call closestream_file
  363.  
  364.  
  365.         ld a,(mode)
  366.         and a
  367.         jp z,skip_mid_scr
  368.              
  369.  
  370.                         ld e,0+0x80  //set EGA mode  keep
  371.                         OS_SETGFX
  372.  
  373.                          call fade_toblack      
  374.  
  375.  
  376.  
  377.                         ;set mode
  378.                         ld e,3+0x80  //set 6912 mode keep
  379.                         OS_SETGFX
  380.                
  381.                
  382.                         ld a,(user_scr0_high)
  383.                         SETPG4000
  384.                         ld a,(winpage2)
  385.                         SETPG8000
  386.                
  387.                          ld e,0
  388.                          OS_CLS
  389.                          ld e,0
  390.                          OS_SETSCREEN
  391.                          ld de,stdpal
  392.                          OS_SETPAL  
  393.  
  394.  
  395.  
  396.                                 ld hl,0x4000
  397.                                 ld de,0x4001
  398.                                 ld (hl),l
  399.                                 ld bc,6143
  400.                                 ldir        
  401.  
  402.  
  403.                                 ld hl,0x5800
  404.                                 ld de,0x5801
  405.                                 ld (hl),0x47
  406.                                 ld bc,767
  407.                                 ldir
  408.  
  409.  
  410.  
  411.         ld hl,0x4000
  412.         ld (VP_ADR1),hl
  413.         ld (VP_ADR2),hl
  414.         ld (VP_ADR3),hl
  415.  
  416.  
  417.         ld de,intro
  418.         call vid_load_play
  419.  
  420.  
  421.         ld hl,0x4021
  422.         ld (VP_ADR1),hl
  423.         ld (VP_ADR2),hl
  424.         ld (VP_ADR3),hl
  425.  
  426.  
  427.  
  428.                                 ld hl,0x4000
  429.                                 ld de,0x4001
  430.                                 ld (hl),l
  431.                                 ld bc,6143
  432.                                 ldir        
  433.  
  434.  
  435.                                 ld hl,0x5800
  436.                                 ld de,0x5801
  437.                                 ld (hl),l
  438.                                 ld bc,767
  439.                                 ldir
  440.  
  441.          ld de,scr6912
  442.          call openstream_file
  443.                  ld hl,6144 ;len
  444.                  ld de,0x4000 ;where
  445.                  call readstream_file
  446.  
  447.                  ld hl,768
  448.                  ld de,0x8000 ;where
  449.                  call readstream_file
  450.          call closestream_file
  451.  
  452.  
  453.  
  454.                 ld e,3+8+0x80  //set 6912 mode keep
  455.                 OS_SETGFX
  456.  
  457.                 call fade_fromblack6912
  458.  
  459. skip_mid_scr:
  460.          ld a,(winpage3)
  461.          SETPGC000
  462.          ld de,f_name_main
  463.          call openstream_file
  464.          ld hl,0x8000 ;len
  465.          ld de,0x7404 ;where
  466.          call readstream_file
  467.          call closestream_file
  468.  
  469.  
  470.         call fade_toblack6912
  471. ;------------------ main patch
  472.                         ;org 0x7a62         ;  (615e)
  473.                         ;ld a,3
  474.                         ;call select_page
  475.                         ;nop:nop        
  476.  
  477.                         ;org #7a70         ;    (616d)
  478.                         ;xor a
  479.                         ;jp select_page
  480.                   ld de,select_page
  481.                   ld hl,0x7a62
  482.                   ld (hl),0x3e: inc hl
  483.                   ld (hl),0x03: inc hl
  484.                   ld (hl),0xcd: inc hl
  485.                   ld (hl),e   : inc hl
  486.                   ld (hl),d   : inc hl
  487.                   ld (hl),0: inc hl
  488.                   ld (hl),0
  489.  
  490.                   ld hl,0x7a70
  491.                   ld (hl),0xaf:inc hl
  492.                   ld (hl),0xc3:inc hl
  493.                   ld (hl),e   : inc hl
  494.                   ld (hl),d   : inc hl
  495.  
  496.                           ;      ORG #9BEE
  497.                           ;      CALL select_page
  498.                                
  499.                           ;      ORG #9C2A
  500.                           ;      CALL select_page
  501.  
  502.                   ld de,select_page
  503.                   ld hl,0x9bee
  504.                   ld (hl),0xcd: inc hl
  505.                   ld (hl),e   : inc hl
  506.                   ld (hl),d   : inc hl
  507.  
  508.                   ld hl,0x9c2a
  509.                   ld (hl),0xcd: inc hl
  510.                   ld (hl),e   : inc hl
  511.                   ld (hl),d   : inc hl
  512.  
  513.  
  514.                                 ;org 0x9c4c        
  515.                                 ;di
  516.                                 ;ds 3,0
  517.                                 ;call pg_transfer
  518.                                 ;ds 7,0
  519.                                
  520.                                 ;org 0x9c7f
  521.                                 ;jp setpg0
  522.  
  523.                   ld de,pg_transfer
  524.                   ld hl,0x9c4c
  525.                   ld (hl),0xf3:inc hl
  526.                   ld (hl),0x00:inc hl
  527.                   ld (hl),0x00:inc hl
  528.                   ld (hl),0x00:inc hl
  529.                   ld (hl),0xcd:inc hl
  530.                   ld (hl),e   : inc hl
  531.                   ld (hl),d   : inc hl
  532.                   ld (hl),0x00:inc hl
  533.                   ld (hl),0x00:inc hl
  534.                   ld (hl),0x00:inc hl
  535.                   ld (hl),0x00:inc hl
  536.                   ld (hl),0x00:inc hl
  537.                   ld (hl),0x00:inc hl
  538.                   ld (hl),0x00:inc hl
  539.  
  540.                   ld de,setpg0
  541.                   ld hl,0x9c7f
  542.                   ld (hl),0xc3:inc hl
  543.                   ld (hl),e   : inc hl
  544.                   ld (hl),d   : inc hl
  545.  
  546.                               ;  org 0xaa78
  547.                               ;  ld b,6   ;menu lines count+1
  548.                               ;  ld hl,controls_menu
  549.                                
  550.                               ;  org 0xaa8d
  551.                               ;  jp menu_keyscan_mod
  552.                 ld de,controls_menu
  553.                 ld hl,0xaa78
  554.                 ld (hl),6:inc hl
  555.                 ld (hl),6:inc hl
  556.                 ld (hl),0x21:inc hl
  557.                 ld (hl),e:inc hl
  558.                 ld (hl),d
  559.  
  560.                 ld de,menu_keyscan_mod
  561.                 ld hl,0xaa8d
  562.                 ld (hl),0xc3 : inc hl
  563.                 ld (hl),e    : inc hl
  564.                 ld (hl),d
  565. ;-------------------------------------
  566.                                                             ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  567.                 ;;  first level hack
  568.                                                                        ; org 0xac32   ;ram3 conatains level 0 and restores after death
  569.                 ;      ld hl,0xac32
  570.                 ;      ld (hl),8
  571.  
  572.                                                            
  573.                ;immunity cheat
  574.                ;      ld hl,0x9a74
  575.                ;      ld (hl),0xc9
  576.  
  577.                                                             ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  578.                ;restore sound effect 1
  579.                ;      ld hl,0x7bec        ;;after init - 62e8  
  580.                ;      ld (hl),0x18
  581.  
  582.                 ld a,(mode)
  583.                 and a
  584.                 jp z,0x8134
  585. ;--modded patch
  586.  
  587.                                 ;  ORG #798A                ;(0x6086)
  588.                                 ;  CALL p_manager
  589.  
  590.                   ld de,p_manager
  591.                   ld hl,0x798a
  592.                   ld (hl),0xcd:inc hl
  593.                   ld (hl),e   : inc hl
  594.                   ld (hl),d   : inc hl
  595.  
  596.                                 ; ORG 0x7E37 ;(6533)  ;╬┴╨└┴╬╥╫╚╩ ╙╨╬┬═▀ 9 (JP Z,#7F55)
  597.                                 ; JP Z,level9_video
  598.  
  599.                   ld de,level9_video
  600.                   ld hl,0x7e37
  601.                   ld (hl),0xca : inc hl
  602.                   ld (hl),e    : inc hl
  603.                   ld (hl),d    : inc hl        
  604.  
  605.                                ; org 0x7dcf  ;0x64cb 0    
  606.                                ; nop:nop
  607.                                ; call fix_stun
  608.  
  609.                   ld de,fix_stun
  610.                   ld hl,0x7dcf
  611.                   ld (hl),0x00 : inc hl
  612.                   ld (hl),0x00 : inc hl
  613.                   ld (hl),0xcd : inc hl
  614.                   ld (hl),e    : inc hl
  615.                   ld (hl),d    : inc hl        
  616.  
  617.  
  618.  
  619.                   ld de,set_difficulty
  620.                   ld hl,0xac69
  621.                   ld (hl),0x00 : inc hl
  622.                   ld (hl),0x00 : inc hl
  623.                   ld (hl),0x00 : inc hl
  624.                   ld (hl),0xcd : inc hl
  625.                   ld (hl),e    : inc hl
  626.                   ld (hl),d    : inc hl            
  627.  
  628.         jp 0x8134
  629.  
  630.  
  631.  
  632. cmd_quit:
  633.         ;unload resered page
  634.  
  635.         im 1
  636.         di
  637.  
  638.         call nomus
  639.  
  640. ;        ld hl,t_vid_file00_pages_list+$FF
  641. ;        call free_vid_file
  642.  
  643.         ld a,(winpage17)
  644.         ld e,a
  645.         OS_DELPAGE
  646.  
  647.         ld a,(winpage16)
  648.         ld e,a
  649.         OS_DELPAGE
  650.  
  651.         ld a,(winpage14)
  652.         ld e,a
  653.         OS_DELPAGE
  654.  
  655.         ld a,(winpage13)
  656.         ld e,a
  657.         OS_DELPAGE
  658.  
  659.         ld a,(winpage11)
  660.         ld e,a
  661.         OS_DELPAGE
  662.  
  663.         ld a,(winpage3)
  664.         ld e,a
  665.         OS_DELPAGE
  666.  
  667.         ld a,(winpage2)
  668.         ld e,a
  669.         OS_DELPAGE
  670.  
  671.         ld a,(winpage1)
  672.         ld e,a
  673.         OS_DELPAGE
  674.  
  675.         ld a,(winpage0)
  676.         ld e,a
  677.         OS_DELPAGE
  678.  
  679.         ld a,(vidbuf)
  680.         ld e,a
  681.         OS_DELPAGE
  682.  
  683.  
  684.         ;set mode
  685.         ld e,6+0x80  //set 6912 mode keep
  686.         OS_SETGFX
  687.  
  688.         ;fix. robocop modify byte at 0000
  689.         ld a,0x3e
  690.         ld (0),a        
  691.         QUIT
  692.  
  693. ;---------------------------------------
  694. fade_toblack6912:
  695.         ld b,8
  696. .loop_6c1b:
  697.         push bc
  698.         ld hl,0x5800
  699. .loop_6c1f:
  700.         ld a,(hl)
  701.         ld b,a
  702.         and 7
  703.         jr z,.loop_6c26
  704.         dec a
  705. .loop_6c26:
  706.         ld c,a
  707.         ld a,b
  708.         and 0x38
  709.         jr z,.loop_6c2e
  710.         sub 8
  711. .loop_6c2e:
  712.         or c
  713.         ld (hl),a
  714.         inc hl
  715.         ld a,h
  716.         cp 0x5b
  717.         jr nz,.loop_6c1f
  718.        
  719. .loop_l6c39        
  720.         halt
  721.         halt
  722.         pop bc
  723.         djnz .loop_6c1b        
  724.         ld hl,0x4000
  725.         ld de,0x4001
  726.         ld bc,0x1aff
  727.         ld (hl),l
  728.         ldir
  729.         ret
  730.  
  731.  
  732.  
  733.  
  734. fade_fromblack6912:
  735.         ld b,7
  736. .loop1:
  737.         push bc
  738.         ld hl,0x5800
  739.         ld de,0x8000
  740.         ld bc,768
  741. .loop2:
  742.         push bc
  743.         ld a,(de)
  744.         and 7
  745.         ld c,a
  746.         ld a,(hl)
  747.         ld b,a
  748.         and 7
  749.         cp c
  750.         jr z,.skip_s1
  751.         inc b
  752.         ld (hl),b
  753. .skip_s1:
  754.         ld a,(de)
  755.         and 0x38
  756.         ld c,a
  757.         ld a,(hl)
  758.         ld b,a
  759.         and 0x38
  760.         cp c
  761.         jr z,.skip_s2
  762.         ld a,b
  763.         add a,8
  764.         ld (hl),a
  765. .skip_s2:
  766.         inc hl
  767.         inc de
  768.         pop bc
  769.         dec bc
  770.         ld a,b
  771.         or c
  772.         jr nz,.loop2
  773.         halt
  774.         halt
  775.         pop bc
  776.         djnz .loop1
  777.         ld hl,0x8000
  778.         ld de,0x5800
  779.         ld bc,768
  780.         ldir
  781.         ret        
  782.  
  783.  
  784. ;<----------------------
  785. fade_toblack:
  786.         ;dec lx
  787.         ld hl,0x2ddd
  788.         xor a
  789.         jp fade_to_sub
  790. fade_fromblack:
  791.         ;inc lx
  792.         ld hl,0x2cdd
  793.         xor a
  794.         jp fade_from_sub
  795.  
  796.  
  797.  
  798.  
  799. fade_to_sub:
  800.         ld (fade_tocolor),a
  801.         ld (fade_to_op),hl
  802.  
  803.         ld hl,pal
  804.         ld de,temppal
  805.         ld bc,32
  806.         ldir        ;;
  807.  
  808.         call palette_precalc_sub
  809.  
  810.         ld lx,8
  811. fade0
  812.         dec lx
  813. fade_to_op: equ $-2        
  814.         ld hl,pal_rgb
  815.         ld de,pal
  816.         call recolour
  817.         push ix
  818.  
  819. ;       ld a,1
  820. ;       ld (setpalflag),a
  821.         ld de,pal
  822.         OS_SETPAL
  823.  
  824.  
  825.         halt
  826.         halt
  827.         halt
  828.         pop ix
  829.         ld a,lx
  830.         cp 0
  831. fade_tocolor: equ $-1
  832.         jr nz,fade0
  833.         halt
  834.         halt
  835.         halt
  836.         ret
  837.  
  838. ;<--------
  839. fade_from_sub:
  840.         ld (fade_fromcolor),a
  841.         ld (fade_from_op),hl
  842.  
  843.  
  844.         ld hl,pal
  845.         ld de,temppal
  846.         ld bc,32
  847.         ldir        ;;
  848.  
  849.  
  850.         call palette_precalc_sub
  851.  
  852.         ld lx,15
  853. fade_fromcolor: equ $-1
  854.  
  855.  
  856. fadew1:
  857.         dec lx
  858. fade_from_op: equ $-2
  859.         ld hl,pal_rgb
  860.         ld de,pal
  861.         call recolour
  862.         push ix
  863.  
  864. ;       ld a,1
  865. ;       ld (setpalflag),a
  866.         ld de,pal
  867.         OS_SETPAL
  868.  
  869.  
  870.         halt
  871.         halt
  872.         halt
  873.         pop ix
  874.         ld a,lx
  875.         cp 8
  876.         jr nz,fadew1
  877.         halt
  878.         halt
  879.         halt
  880.  
  881.         ld hl,temppal
  882.         ld bc,32
  883.         ld de,pal
  884.         ldir
  885. ;       ld a,1
  886. ;       ld (setpalflag),a
  887.         ld de,pal
  888.         OS_SETPAL
  889.  
  890.         halt
  891.         ret
  892. ;<--------
  893.  
  894.  
  895.  
  896.  
  897.  
  898.  
  899.  
  900.  
  901.  
  902.  
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909. palette_precalc_sub:
  910. palette_precalc:
  911.                 ld hl,pal
  912.                 ld de,pal_rgb
  913.  
  914.                 ld b,16
  915. mkpalATM3RGB
  916.                 push bc
  917.                 ld a,(hl)
  918.                 inc hl
  919.                 push hl
  920.                 ld h,(hl)
  921.                 ld l,a
  922.                 push de
  923.                
  924.                 call calchexcolor ;hl=color (DDp palette) ;out: ;b=B, d=R, e=G
  925.        
  926.                 ld a,e ;G
  927.                 add a,a
  928.                 add a,a
  929.                 add a,a
  930.                 add a,a
  931.                 or d ;R
  932.                 pop de
  933.                 ld c,a ;GR
  934.                 ld a,b
  935.                 add a,a
  936.                 add a,a
  937.                 add a,a
  938.                 add a,a
  939.                 ld (de),a ;B0
  940.                 inc de
  941.                 ld a,c
  942.                 ld (de),a ;GR
  943.                 inc de
  944.                 pop hl
  945.                 inc hl
  946.                 pop bc
  947.                 djnz mkpalATM3RGB
  948.                 ret
  949.  
  950.  
  951. calchexcolor ;hl=color (DDp palette) ;out: ;b=B, d=R, e=G
  952. ;keep c!!!
  953. ;DDp palette: %grbG11RB(low),%grbG11RB(high)
  954. ;high B, high b, low B, low b
  955.                 ld b,0;0xff
  956.                 ld de,0;0xffff
  957.                 ld a,h
  958.                cpl
  959.                 rra
  960.                 rl b ;B high
  961.                 rra
  962.                 rl d ;R high
  963.                 rra
  964.                 rra
  965.                 rra
  966.                 rl e ;G high
  967.                 rra
  968.                 rl b ;b high
  969.                 rra
  970.                 rl d ;r high
  971.                 rra
  972.                 rl e ;g high
  973.                 ld a,l
  974.                cpl
  975.                 rra
  976.                 rl b ;B low
  977.                 rra
  978.                 rl d ;R low
  979.                 rra
  980.                 rra
  981.                 rra
  982.                 rl e ;G low
  983.                 rra
  984.                 rl b ;b low
  985.                 rra
  986.                 rl d ;r low
  987.                 rra
  988.                 rl e ;g low
  989. ;b=B
  990. ;d=R
  991. ;e=G
  992.         ret
  993.  
  994.  
  995. recolour
  996. ;hl=palfrom (RGB)
  997. ;de=palto (DDp)
  998. ;lx=brightness=0..15
  999.         di
  1000.         ld (recoloursp),sp
  1001.         ld sp,hl
  1002.        ld h,tbright/256 ;once
  1003.         ld hx,16
  1004. bripalATM3
  1005.          ;ld a,(hl) ;B0
  1006.          ;inc hl
  1007.          ;push hl
  1008.          ;ld b,(hl) ;GR
  1009.        pop bc
  1010.        ld a,c
  1011.          ;ld h,tbright/256
  1012. ;de=palto
  1013. ;h=tbright/256
  1014. ;lx=brightness
  1015. ;a,b = B0,GR
  1016.          add a,lx
  1017.         ld l,a
  1018.         ld c,(hl) ;B colour component with brightness
  1019.         ld a,b
  1020.         and 0xf0
  1021.          add a,lx
  1022.         ld l,a
  1023.         ld a,b
  1024.         ld b,(hl) ;G colour component with brightness
  1025.         add a,a
  1026.         add a,a
  1027.         add a,a
  1028.         add a,a
  1029.          add a,lx
  1030.         ld l,a
  1031.         ld l,(hl) ;R colour component with brightness
  1032.  
  1033.        ld a,b ;G
  1034.        rlca ;g??G???? ;G10
  1035.        xor l ;R
  1036.        and 0b10010000;0b01000010 ;R10
  1037.        xor l;gr?G??R?
  1038.        rlca ;r?G??R?g
  1039.        xor c ;B
  1040.        and 0b10100101;0b01000010 ;B10
  1041.        xor c;rbG??RBg
  1042.        rrca ;grbG??RB
  1043.         or 0b00001100 ;unused bits
  1044.         ld (de),a ;low %grbG11RB
  1045.         inc de ;TODO ld (),a
  1046.  
  1047.        ld a,b ;G
  1048.        rlca ;?g??G??? ;G32
  1049.        xor l ;R
  1050.        and 0b01001000;0b00100001 ;R32
  1051.        xor l;?gr?G??R
  1052.        rlca ;gr?G??R?
  1053.        xor c ;B
  1054.        and 0b11010010;0b00100001 ;B32
  1055.        xor c;grbG??RB
  1056.         or 0b00001100 ;unused bits
  1057.         ld (de),a ;high %grbG11RB
  1058.         inc de ;TODO ld (),a
  1059.  
  1060.          ;pop hl
  1061.          ;inc hl
  1062.          dec hx
  1063.          jp nz,bripalATM3 ;TODO dup..edup
  1064. recoloursp=$+1
  1065.         ld sp,0
  1066.         ei
  1067.         ret
  1068.  
  1069.  
  1070.         align 256
  1071. tbright
  1072. ;brightness levels (black 0..7 less than original, 8 equal, 9..15 to white)
  1073. ;0, 1/12, 1/8, 3/16, 2/8, 3/8, 4/8, 6/8, 1
  1074. _lev=0
  1075.         dup 16 ;colour component level
  1076. _antilev=15-_lev
  1077.         BRIGHTBYTE _lev*0
  1078.         BRIGHTBYTE _lev/12
  1079.         BRIGHTBYTE _lev*1/8
  1080.         BRIGHTBYTE _lev*3/16
  1081.         BRIGHTBYTE _lev*2/8
  1082.         BRIGHTBYTE _lev*3/8
  1083.         BRIGHTBYTE _lev*4/8
  1084.         BRIGHTBYTE _lev*6/8
  1085.  
  1086.         BRIGHTBYTE _lev
  1087.  
  1088.         BRIGHTBYTE 15-(_antilev*6/8)
  1089.         BRIGHTBYTE 15-(_antilev*4/8)
  1090.         BRIGHTBYTE 15-(_antilev*3/8)
  1091.         BRIGHTBYTE 15-(_antilev*2/8)
  1092.         BRIGHTBYTE 15-(_antilev*3/16)
  1093.         BRIGHTBYTE 15-(_antilev*1/8)
  1094.         BRIGHTBYTE 15
  1095.  
  1096. _lev=_lev+1
  1097.         edup
  1098. ;===================
  1099.   ;#DD #2C      INC  IXL           #FD #2C       INC  IYL
  1100.  ; #DD #2D      DEC  IXL
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106. ;---------------------------------------
  1107.  
  1108. nomus:
  1109. NOMUS   XOR A
  1110.         LD D,14
  1111. MU_1    LD BC,#FFFD
  1112.         DEC D
  1113.         OUT (C),D
  1114.         LD B,#BF
  1115.         OUT (C),A
  1116.         JR NZ,MU_1
  1117.         LD B,#FF
  1118.         LD D,7
  1119.         OUT (C),D
  1120.         LD B,#BF
  1121.         DEC A
  1122.         OUT (C),A
  1123.         RET
  1124.  
  1125. dirchangeerror
  1126.         ld hl,txt_dircherror
  1127.         jr openerror
  1128.  
  1129.  
  1130.  
  1131. memoryerror
  1132.         OS_CLOSEHANDLE
  1133.         ld e,6+0x80
  1134.         OS_SETGFX
  1135.         ld e,0
  1136.         OS_CLS
  1137.         ld hl,txt_memoryerror
  1138.         call print_hl
  1139.         YIELDGETKEYLOOP
  1140.         jp cmd_quit
  1141.  
  1142.  
  1143. openerror:
  1144.         push hl
  1145.         ld e,6+0x80
  1146.         OS_SETGFX
  1147.         ld e,0
  1148.         OS_CLS
  1149.         pop  hl
  1150.         call print_hl
  1151.         ld hl,txt_nl
  1152.         call print_hl
  1153.         YIELDGETKEYLOOP
  1154.         jp cmd_quit
  1155.  
  1156. print_hl
  1157.         ld a,(hl)
  1158.         or a
  1159.         ret z
  1160.         push hl
  1161.         PRCHAR
  1162.         pop hl
  1163.         inc hl
  1164.         jp print_hl
  1165.         ret
  1166.  
  1167. setpage0
  1168.         ld a,(winpage3)
  1169.         jr setpage_m
  1170. setpage1
  1171.         ld a,(winpage11)
  1172.         jr setpage_m
  1173. setpage2
  1174.         ld a,(winpage2)
  1175.         jr setpage_m
  1176. setpage3
  1177.         ld a,(winpage13)
  1178.         jr setpage_m
  1179. setpage4
  1180.         ld a,(winpage14)
  1181.         jr setpage_m
  1182. setpage5
  1183.         ld a,(user_scr0_high)
  1184.         jr setpage_m
  1185. setpage6
  1186.         ld a,(winpage16)
  1187.         jr setpage_m
  1188. setpage7
  1189.         ld a,(winpage17)
  1190. setpage_m
  1191.         SETPGC000
  1192.         pop hl
  1193.         ret
  1194.  
  1195. set_next_difficulty:
  1196.        push af,hl,de,bc
  1197.        ld a,(difficulty_c)
  1198.         cp 3
  1199.         jr z,set_difc1
  1200.         inc a
  1201.         ld (difficulty_c),a
  1202.         jr set_difc1
  1203.  
  1204. set_max_difficulty:
  1205.        push af,hl,de,bc
  1206.                 ld a,3
  1207.                 jr set_difc1
  1208. set_difficulty:
  1209.        push af,hl,de,bc
  1210.                 ld a,(difficulty_c)
  1211. set_difc1:
  1212.                 add a,a
  1213.                 ld e,a
  1214.                 ld d,0
  1215.                 ld hl,dfc_table
  1216.                 add hl,de
  1217.                 ld a,(hl)
  1218.                 inc hl
  1219.                 ld h,(hl)
  1220.                 ld l,a
  1221.                 ld de,0x9a7d
  1222.                 ld bc,4
  1223.                 ldir
  1224.                
  1225.                 pop bc,de,hl,af
  1226.                 ret
  1227.  
  1228. mode            db 0
  1229. difficulty      db 0
  1230. difficulty_c    db 0
  1231. dfc_table:      dw easy_tbl
  1232.                 dw normal_tbl
  1233.                 dw hard_tbl
  1234.                 dw hell_tbl
  1235.  
  1236. easy_tbl          db 0x87,0x00,0x00,0x00
  1237. normal_tbl        db 0x87,0x87,0x00,0x00
  1238. hard_tbl          db 0x87,0x87,0x87,0x00
  1239. hell_tbl          db 0x87,0x87,0x87,0x87
  1240.  
  1241. pre_setup:          db 0x0A,"RoboCop by Ocean Software Ltd [1988]",0x0D,0x0A
  1242.                     db "Adapted for NedoOS an modded by Zorba (Transman/Triumf) [2025]",0x0D,0x0A
  1243.                     db "----------------------------------------",0x0D,0x0A
  1244.                     db 0x0D,0x0A,"Choose game version:",0x0D,0x0A
  1245.                     db 0x0D,0x0A
  1246.                     db "1. Original",0x0D,0x0A
  1247.                     db "2. Slightly modded",0x0D,0x0A,0
  1248. difficulty_setup:
  1249.                     db 0x0D,0x0A,"Select difficulty:",0x0D,0x0A
  1250.                     db 0x0D,0x0A
  1251.                     db "1. Easy",0x0D,0x0A
  1252.                     db "2. Normal",0x0D,0x0A
  1253.                     db "3. Hard",0x0D,0x0A
  1254.                     db "4. Hell",0x0D,0x0A,0
  1255.                    
  1256.  
  1257. video_name    db "video"
  1258. vidloadnum db "0.bin",0
  1259.  
  1260. res_path db "robocop",0
  1261.  
  1262.  
  1263. pal_rgb   ds 32,0xff
  1264. temppal   ds 32,0
  1265. pal       ds 32,0xff
  1266. blackpal  ds 32,0xff
  1267. stdpal:  STANDARDPAL
  1268.  
  1269. winpage0    db 0
  1270. winpage1    db 0
  1271. winpage2    db 0
  1272. winpage3    db 0
  1273.  
  1274. winpage11   db 0
  1275. winpage13   db 0
  1276. winpage14   db 0
  1277. winpage16   db 0
  1278. winpage17   db 0
  1279.  
  1280. vidbuf      db 0
  1281.  
  1282. f_name_main db "main.bin",0
  1283.  
  1284. f_name11   db "ram11.bin",0
  1285. f_name13   db "ram13.bin",0
  1286. f_name14   db "ram14.bin",0
  1287. f_name16   db "ram16.bin",0
  1288. f_name17   db "ram17.bin",0
  1289.  
  1290. scr16c     db "robo.16c",0
  1291. scr6912    db "robo.scr",0
  1292. intro      db "intro.bin",0
  1293.  
  1294. txt_memoryerror:    db 0x0A,"Memory allocation error!",0x0D,0x0A,0
  1295. txt_dircherror:     db 0x0A,"Cannot change directory: ",0
  1296. txt_nl:             db 0x0D,0x0A,0
  1297.         include "../_sdk/file.asm"
  1298.  
  1299. page_switch_table
  1300.         dw setpage0
  1301.         dw setpage1
  1302.         dw setpage2
  1303.         dw setpage3
  1304.         dw setpage4
  1305.         dw setpage5
  1306.         dw setpage6
  1307.         dw setpage7
  1308.  
  1309.  
  1310.  
  1311. select_page:
  1312. ;        push hl,bc
  1313.         and 7
  1314.         push hl
  1315.         ld hl,page_switch_table
  1316.         add a,a
  1317.         ld b,0
  1318.         ld c,a
  1319.         add hl,bc
  1320.         ld a,(hl)
  1321.         inc hl
  1322.         ld h,(hl)
  1323.         ld l,a
  1324.         jp (hl)
  1325.  
  1326.  
  1327.  
  1328. pg_transfer:
  1329. ;hl - pages
  1330.         ld a,l
  1331.         and 7
  1332.         call select_page
  1333.         ld a,(iy)
  1334.  
  1335.         push af
  1336.  
  1337.         ld a,h
  1338.         and 7
  1339.         call select_page
  1340.         pop af
  1341.         ld (ix),a
  1342.         ret
  1343.  
  1344.  
  1345. setpg0
  1346.         call select_page
  1347.         jp 0x66ef
  1348.  
  1349.  
  1350.  
  1351.  
  1352.  
  1353. menu_keyscan_mod:
  1354.         rra
  1355.         ld hl,0xaa58
  1356.         jr c,.key1
  1357.         ld hl,0xae4f
  1358.         rra
  1359.         jr nc,.key3plus
  1360. .key1:
  1361.         ;keyboard /sinclair
  1362.         ld bc,0x00a
  1363.         ld de,0x9b7d
  1364.         ldir
  1365.         ld a,0xc9
  1366.         jp .togam
  1367. .key3plus:
  1368.         rra
  1369.         jr nc,.key4plus
  1370. ;kempston
  1371.         xor a
  1372.         jp .togam
  1373. .key4plus:
  1374.         rra
  1375.         jp c,0xaaae ;redefine keys
  1376.         rra
  1377.         jp nc,0xaa62  ;no valid key pressed
  1378.         jp cmd_quit
  1379.  
  1380. .togam
  1381.          push af
  1382.             call clr_v_t
  1383.  
  1384.              ld a,(difficulty)
  1385.              ld (difficulty_c),a
  1386.          pop af
  1387.          jp 0xac22
  1388.  
  1389.  
  1390. inert:
  1391.            call clr_v_t
  1392.            ld hl,0x604e
  1393.            ret          
  1394.  
  1395.  
  1396. clr_v_t:
  1397.         LD HL,VIDEO_S
  1398.         LD B,10
  1399. .init_loop
  1400.         LD (HL),0
  1401.         INC HL
  1402.         DJNZ .init_loop
  1403.         ret
  1404.  
  1405.  
  1406.  
  1407.  
  1408.  
  1409.  
  1410.  
  1411. level9_video:
  1412.                 CALL p_manager
  1413.                 JP 0x7F55
  1414.  
  1415. p_manager:
  1416.                 ld (store_sp),sp
  1417.                 ld sp,0x4000
  1418.                 push hl
  1419.  
  1420.  
  1421.                 call area_cls
  1422.  
  1423.                 call p_manager_controller_text
  1424.                 call p_manager_controller_video
  1425.  
  1426.                 ;disable stun
  1427.                 xor a
  1428.                 ld (0x9acb),a
  1429.  
  1430.  
  1431.                 pop hl
  1432.  
  1433.                         LD A,(0x9CCD)
  1434.                 ld sp,0
  1435. store_sp     equ $-2
  1436.                 RET
  1437.  
  1438.  
  1439. p_manager_controller_video
  1440.                 LD A,(0x9CCD)
  1441.                 LD E,A
  1442.                 LD D,0
  1443.                 LD HL,VIDEO_S
  1444.                 ADD HL,DE
  1445.                 LD A,(HL)
  1446.                 AND A
  1447.                 RET NZ
  1448.             inc a
  1449.             ld (hl),a
  1450.  
  1451.             ld a,"0"
  1452.             add a,e
  1453.             ld (vidloadnum),a
  1454. ;play video
  1455. ;e - video number
  1456.  
  1457.                 di
  1458.                 im 1
  1459.                 ei
  1460.        
  1461.  
  1462.  
  1463.  
  1464. ;load selected video
  1465.                 ld de,video_name
  1466.                 call vid_load_play
  1467.  
  1468.  
  1469.  
  1470.                 di
  1471.                 im 2
  1472.                 ei
  1473.                 ret
  1474.  
  1475.  
  1476.  
  1477.  
  1478.  
  1479.  
  1480. vid_load_play:
  1481.                 call openstream_file
  1482.                 or a
  1483.                 jp nz,$
  1484.  
  1485.  
  1486.                 ld e,3+0x80  //set 6912 mode keep
  1487.                 OS_SETGFX
  1488.  
  1489.  
  1490.                 ld hl,t_vid_file00_pages_list
  1491.                 ld (load_vid_file_number),hl
  1492. ;-----------------------------
  1493. load_vid_file_number = $+1 :
  1494.                 ld bc,t_vid_file00_pages_list
  1495.                 push bc
  1496.                                
  1497. .read_file_loop:
  1498.                 OS_NEWPAGE              ;out: a=0 (OK)/!=0 (fail), e=page
  1499.                
  1500.                 pop bc ;file tab
  1501.                 or a
  1502.                 jp nz,memoryerror
  1503.                 ld a,e
  1504. 1               ld (bc),a
  1505.                 inc c  
  1506.                 push bc ;file tab
  1507.                 SETPGC000
  1508.        
  1509.                 ld de,0xC000
  1510.                 ld hl,0x4000
  1511.                 call readstream_file    ;DE = Buffer address, HL = Number of bytes to read
  1512.                                 ;hl=actual size
  1513.                 ld a,h
  1514.                 cp $40
  1515.                 jr nc,.read_file_loop    ;>= $40
  1516.  
  1517.                 pop bc ;file tab
  1518.                 ;ЄєЄ ьюцэю фюёЄрЄ№ ъюышўхёЄтю ёЄЁрэшЎ
  1519.                 ld a,c
  1520.                 ld c,$FF
  1521.                 ld (bc),a
  1522.                 call closestream_file
  1523. ;-----------------------------------------
  1524.  
  1525.                 CALL VIDEOPLAY
  1526.  
  1527.                 ld hl,t_vid_file00_pages_list+$FF
  1528.                 call free_vid_file
  1529.  
  1530.                 ld a,(winpage3)
  1531.                 SETPGC000
  1532.  
  1533.                                 ld e,3+8+0x80  //set 6912 mode keep
  1534.                                 OS_SETGFX
  1535.  
  1536.                 halt
  1537.                 ret
  1538.  
  1539.  
  1540.                 align 256
  1541. t_vid_file00_pages_list:  ds 256,0
  1542.                 nop
  1543.  
  1544.  
  1545.  
  1546. p_manager_controller_text
  1547.                 LD A,(0x9CCD)
  1548.         LD E,A
  1549.         LD D,0
  1550.         LD HL,VIDEO_S
  1551.         ADD HL,DE
  1552.         LD A,(HL)
  1553.         AND A
  1554.         RET NZ
  1555.  
  1556.         ld a,e
  1557.         add a,a
  1558.         ld e,a
  1559.         ld d,0
  1560.         ld hl,text_table
  1561.          add hl,de
  1562.         ld a,(hl)
  1563.         inc hl
  1564.         ld h,(hl)
  1565.         ld l,a
  1566. ;0x61ab
  1567.         ld b,(hl)
  1568.         ld a,b
  1569.         and a
  1570.         ret z
  1571.  
  1572.  
  1573.         push de,bc,hl
  1574.  
  1575.             ld hl,mess_diff
  1576.             call _clone_0xac80 ;print string
  1577.             ld a,0x40
  1578.             call 0x9b90 ;erase cursor
  1579.            
  1580.             ld a,(difficulty_c)
  1581.             add a,a
  1582.             ld e,a
  1583.             ld d,0
  1584.             ld hl,mes_d_tabl
  1585.              add hl,de
  1586.             ld a,(hl)
  1587.             inc hl
  1588.             ld h,(hl)
  1589.             ld l,a
  1590.             call _clone_0xac80 ;print string
  1591.             ld a,0x40
  1592.             call 0x9b90 ;erase cursor
  1593.  
  1594.        pop hl,bc,de
  1595.  
  1596.  
  1597.  
  1598.  
  1599.         inc hl
  1600. .prt_loop
  1601.         call _clone_0xac80 ;print string
  1602.  
  1603.         ld a,0x40
  1604.         call 0x9b90 ;erase cursor
  1605.  
  1606.        djnz .prt_loop
  1607.  
  1608.  
  1609.  
  1610. ;------------------------------------------------------------------
  1611. ;debug
  1612. /*
  1613.                
  1614.                 di
  1615.                 im 1
  1616.                 ei
  1617.  
  1618.                 call mem_check
  1619.                 ;a - free pages count
  1620.                 ld de,mes_free_pg_num_c
  1621.                 call ConvertNumberA
  1622.  
  1623.                 di
  1624.                 im 2
  1625.                 ei
  1626.        
  1627.                
  1628.                 ld hl,mes_free_mem
  1629.                 call _clone_0xac80
  1630.                 ld a,0x40
  1631.                 call 0x9b90 ;erase cursor
  1632.  
  1633.  
  1634.                 ld hl,mes_free_pg_num
  1635.                 call _clone_0xac80
  1636.                 ld a,0x40
  1637.                 call 0x9b90 ;erase cursor
  1638.  
  1639. */
  1640. ;------------------------------------------------------------------
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647.  
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.        call 0x61ab
  1654.        ret
  1655.  
  1656. mes_free_mem:
  1657.            dw 0x5001
  1658.            db "FREE@PAGES:@@",0
  1659. mes_free_pg_num:
  1660.            dw 0x500d
  1661. mes_free_pg_num_c:
  1662.            db "00000" ,0    
  1663.  
  1664.  
  1665. _clone_0xac80:
  1666.             ld e,(hl)
  1667.             inc hl
  1668.             ld d,(hl)
  1669.             inc hl
  1670.             ld (0x9ba1),de
  1671. ._0xac88
  1672.             ld a,(hl)
  1673.             inc hl
  1674.             or a
  1675.             ret z
  1676.             call 0x9b90
  1677.             ld a,0x3d
  1678.             call 0x9b90
  1679.             ld a,(0x9ba1)
  1680.             dec a
  1681.             ld (0x9ba1),a
  1682.             push bc
  1683.             ld b,3
  1684.             call _clone_0xac75
  1685.             pop bc
  1686.             jr ._0xac88
  1687.  
  1688. _clone_0xac75:
  1689.             ld a,0x7f
  1690.             in a,(0xfe)
  1691.             rra
  1692.             ret nc
  1693.             ei
  1694.             halt
  1695.             djnz _clone_0xac75
  1696.             ret
  1697.  
  1698.  
  1699. free_vid_file:
  1700.                ld a,(hl)
  1701.                 and a
  1702.                 ret z
  1703.                 ld l,a
  1704. free_vid_loop
  1705.                 dec l
  1706.                 ld e,(hl)
  1707.  
  1708.                 push af
  1709.                 push hl
  1710.                 OS_DELPAGE
  1711.                 pop hl
  1712.                 pop af                
  1713.                 jr nz,free_vid_loop          
  1714.         ret
  1715.  
  1716. ;216*128 pixels (27*16)
  1717. area_cls:
  1718.         ld hl,0x5821
  1719.         ld c,16
  1720. .lllp:
  1721.         push hl
  1722.         ld b,0x1b
  1723. .eer2
  1724.         ld (hl),0x47
  1725.         inc hl
  1726.         djnz .eer2
  1727.         pop hl
  1728.  
  1729.         ld de,32
  1730.         add hl,de
  1731.         dec c
  1732.         jr nz,.lllp            
  1733.  
  1734.  
  1735.  
  1736.  
  1737.         ld hl,0x4021
  1738.         ld c,128
  1739. ._62f2:
  1740.         push hl
  1741.         ld b,0x1b
  1742. .eer
  1743.         ld (hl),0
  1744.         inc hl
  1745.         djnz .eer
  1746.         pop hl
  1747.         call DownHL
  1748. ._6321:
  1749.         dec c
  1750.         jr nz,._62f2
  1751.         ret
  1752.  
  1753.  
  1754. DownHL:
  1755.                 inc     h
  1756.                 ld      a, h
  1757.                 and     7
  1758.                 ret     nz
  1759.                 ld      a, l
  1760.                 add     a, 20h
  1761.                 ld      l, a
  1762.                 ret     c
  1763.                 ld      a, h
  1764.                 sub     8
  1765.                 ld      h, a
  1766.                 ret
  1767.  
  1768. VIDEO_S       DB         0,0,0,0,0,0,0,0,0,0
  1769. text_table
  1770.          dw txt_mission0
  1771.          dw txt_mission1
  1772.          dw txt_mission2
  1773.          dw txt_mission3
  1774.          dw txt_mission4
  1775.          dw txt_mission5
  1776.          dw txt_mission6
  1777.          dw txt_mission7
  1778.          dw txt_mission8
  1779.          dw txt_mission9
  1780.  
  1781. txt_mission0
  1782.              db 2  
  1783.              dw 0x480a
  1784.              db  "ON@PATROL",0
  1785.              dw 0x4849
  1786.              db  "IN@DETROIT",0  
  1787. txt_mission1:
  1788.              db 2  
  1789.              dw 0x4806
  1790.              db  "ATTACK@IN@PROGRESS",0
  1791.              dw 0x4847
  1792.              db  "RESCUE@THE@WOMAN",0  
  1793. txt_mission2:
  1794.              db 2  
  1795.              dw 0x4809
  1796.              db  "ON@PATROL",0
  1797.              dw 0x4842
  1798.              db  "ARMED@CRIMINALS@AT@LARGE",0  
  1799. txt_mission3:
  1800.              db 2  
  1801.              dw 0x4802
  1802.              db  "IDENTIFY@DISCEASED@USING",0
  1803.              dw 0x4841
  1804.              db  "POLICE@DEPARTMENT@COMPUTER",0    
  1805.  
  1806. txt_mission4:
  1807.              db 3  
  1808.              dw 0x4807
  1809.              db  "CONGRATULATIONS",0  
  1810.              dw 0x4846
  1811.              db  "NOW@RAID@THE@GANG",0
  1812.              dw 0x4889
  1813.              db  "DRUG@FACTORY",0    
  1814. txt_mission5:
  1815.              db 2  
  1816.              dw 0x4806
  1817.              db  "ARREST@DICK@JONES",0
  1818.              dw 0x4848
  1819.              DB  "AT@O.C.P.@HQ",0    
  1820. txt_mission6:
  1821.              db 1
  1822.              dw 0x4806
  1823.              db  "ESCAPE@FROM@O.C.P.",0    
  1824.  
  1825. txt_mission7:
  1826.              db 1  
  1827.              dw 0x4806
  1828.              db  "REST@IN@JUNKYARD",0    
  1829.  
  1830. txt_mission8:
  1831.              db 3  
  1832.              dw 0x4802
  1833.              db  "PRESIDENT@O.C.P.@BOARD@OF",0  
  1834.              dw 0x4843
  1835.              db  "DIRECTORS@WITH@EVIDENCE",0
  1836.              dw 0x4885
  1837.              db  "AGAINST@DICK@JONES",0    
  1838.  
  1839. txt_mission9 db 0
  1840.              dw 0x4801
  1841.              db 0
  1842.  
  1843.  
  1844. controls_menu
  1845.         dw 0x480a
  1846.         db "1@@KEYBOARD",0
  1847.         dw 0x484a
  1848.         db "2@@SINCLAIR",0
  1849.         dw 0x488a
  1850.         db "3@@KEMPSTON",0
  1851.         dw 0x48ca
  1852.         db "4@@DEFINE@KEYS",0
  1853.         dw 0x500a
  1854.         db "5@@EXIT@@@",0,0,0,0,0,0,0,0
  1855.  
  1856. mess_diff dw 0x4046
  1857.           db "DIFFICULTY:@",0
  1858. mes_d_easy dw 0x4052
  1859.            db "EASY@@",0
  1860. mes_d_norm dw 0x4052
  1861.            db "NORMAL",0
  1862. mes_d_hard dw 0x4052
  1863.            db "HARD@@",0
  1864. mes_d_hell dw 0x4052
  1865.            db "HELL@@",0        
  1866.  
  1867.  
  1868. mes_d_tabl
  1869.             dw mes_d_easy
  1870.             dw mes_d_norm
  1871.             dw mes_d_hard
  1872.             dw mes_d_hell    
  1873. /*
  1874. sounds_table
  1875.         db 0,3,7,8,3,8,5,3,2,4,6,3,3,4,6
  1876.         db 4,5,4,4,3,5,3,2,5,4,3,4,6,1,9
  1877.         db 255,10,6,8,12,9,0x14,0x20,255
  1878.         db 0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14
  1879.         db 0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14
  1880.         db 0x14,0x14,0x14,0x14,255,0,0,0
  1881. */
  1882.  
  1883. fix_stun:
  1884.             ld a,0x77
  1885.             ld (0x9acb),a
  1886.             call 0x9ab0
  1887.  
  1888.             ld a,8
  1889.             ld (0x9cb8),a
  1890.             ret
  1891.  
  1892.  
  1893. fix_stun_ram16_1:
  1894.             ;C = 1
  1895.             ld a,0x77
  1896.             ld (0x9acb),a
  1897.             jp 0x9ab0
  1898.  
  1899.  
  1900. fix_stun_ram16_2:
  1901.             ld (0x9acb),a
  1902.             ld (0x9cbc),a
  1903.             ret    
  1904.  
  1905. CONT    EQU 254         ;ёыєцхсэ√х ъюэёЄрэЄ√
  1906. COMAND  EQU 255
  1907.  
  1908. BMODE   EQU 0           ;сшЄ√ Ёхцшьют
  1909. DMODE   EQU 1
  1910. EXTPCK  EQU 2
  1911. EXCMODE EQU 3
  1912. EXCFIN  EQU 4
  1913.  
  1914. EX_ENDSTR  EQU -1               ;"ъюЁюЄъшх" ъюьрэф√
  1915. EX_NEWFRM  EQU %00011111
  1916. EX_KEYFRM  EQU %00111111
  1917.  
  1918.  
  1919. VIDEO   EQU 49152       ;рфЁхё Ёрёяыюцхэш  тшфхю
  1920.  
  1921.  
  1922. FIRST1  EQU 0x4201  ;0x4000 ;       ;рфЁхё ¤ъЁрэр
  1923. FSTATR  EQU 0x5800  ; ;x`22528+32+1
  1924.  
  1925.  
  1926. MAXSCR  EQU 0x58 ;HIGH FIRST1 + #18
  1927.  
  1928. SPEDE   EQU 4           ;чрфхЁцър ьхцфє ърфЁрьш
  1929.  
  1930.         MACRO   IDE
  1931.         INC E
  1932.         CALL Z,R_DE
  1933.         ENDM
  1934.  
  1935.  
  1936.  
  1937.  
  1938.  
  1939. VIDEOPLAY:
  1940.         LD (STAKP+1),SP
  1941.         LD IX,PLFLG
  1942.         XOR A
  1943.         ld (current_ram_page),a
  1944.         LD (IX),A
  1945.  
  1946.  
  1947.        
  1948.         push hl
  1949.                 LD l,0
  1950. current_ram_page EQU $-1
  1951.                 ld h,HIGH t_vid_file00_pages_list
  1952.                
  1953.                 ld a,(hl)
  1954.                 SETPGC000
  1955.         pop hl
  1956.        
  1957.  
  1958.  
  1959.  
  1960.  
  1961.         LD DE,VIDEO
  1962. NEWKAD  EXX
  1963.  
  1964.         LD HL,FSTATR
  1965.         SET EXCFIN,(IX)
  1966.         EXX
  1967.         LD HL,FIRST1
  1968. VP_ADR1 equ $-2
  1969.         LD C,0
  1970. PLCYC
  1971.         BIT EXTPCK,(IX)
  1972.         JP NZ,EXTP_STRM
  1973.  
  1974.         LD A,(DE)
  1975.         IDE
  1976.         CP COMAND
  1977.         JR NZ,NOCOM
  1978.  
  1979. EX_COMM
  1980.         LD A,(DE)
  1981.         IDE
  1982.  
  1983.         DEC A
  1984.         JP Z,WAIT
  1985.         DEC A
  1986.         RET Z
  1987.         DEC A
  1988.         JR NZ,NCHS
  1989.         LD A,(DE)
  1990.         LD (WAIT+1),A
  1991.         IDE
  1992.         JR PLCYC
  1993.  
  1994. NCHS    DEC A
  1995.         JP Z,SCRENE
  1996.  
  1997.         DEC A
  1998.         JR NZ,LGRP
  1999.  
  2000.         LD A,(DE)
  2001.         IDE
  2002.         LD C,A
  2003. C_GROUP LD B,8
  2004. PTS1    LD A,(DE)
  2005.         LD (HL),A
  2006.         IDE
  2007.         INC H
  2008.         DJNZ PTS1
  2009.         INC L
  2010.         JR Z,M7
  2011.         LD A,H
  2012.         SUB 8
  2013.         LD H,A
  2014. M7      DEC C
  2015.         JR NZ,C_GROUP
  2016.         JR PLCYC
  2017.  
  2018. LGRP    DEC A
  2019.         JP NZ,LNOGR
  2020.         LD A,(DE)
  2021.         IDE
  2022.         LD C,A          ;QUANTITY
  2023.         CALL DEP_ZN_
  2024.         JR PLCYC
  2025. LNOGR   DEC A
  2026.         JP Z,LSCRENE
  2027.         DEC A
  2028.         JR NZ,NOBMOD
  2029.         SET BMODE,(IX)
  2030.         JR PLCYC
  2031. NOBMOD
  2032.         LD A,(DE)
  2033.         IDE
  2034.         RRA
  2035.         JR NC,NODPK
  2036.         SET DMODE,(IX)
  2037.  
  2038. NODPK   RRA
  2039.         JR NC,PLCYC
  2040.         SET EXTPCK,(IX)
  2041.         RRA
  2042.         JP NC,PLCYC
  2043.         SET EXCMODE,(IX)
  2044.         JP PLCYC
  2045.  
  2046. NOCOM   CP CONT
  2047.         JR NZ,NOCNT
  2048.         ADD A,L
  2049.         LD L,A
  2050.         JP NC,PLCYC
  2051.         LD A,H
  2052.         ADD A,8
  2053.         LD H,A
  2054.         JP PLCYC
  2055. NOCNT
  2056.         ADD A,L
  2057.         LD L,A
  2058.         JR NC,M8
  2059.         LD A,H
  2060.         ADD A,8
  2061.         LD H,A
  2062. M8
  2063.         BIT BMODE,(IX)
  2064.         JR Z,OLDZZ
  2065.         LD C,1
  2066.         CALL DEP_ZN_
  2067.         JP PLCYC
  2068. OLDZZ   LD B,#08
  2069. PUTES   LD A,(DE)
  2070.         LD (HL),A
  2071.         IDE
  2072.         INC H
  2073.         DJNZ PUTES
  2074.         INC L
  2075.         JP Z,PLCYC
  2076.         LD A,H
  2077.         SUB 8
  2078.         LD H,A
  2079.         JP PLCYC
  2080. WAIT    LD A,SPEDE
  2081. W_LOOP  HALT
  2082.         DEC A
  2083.         JR NZ,W_LOOP
  2084. ESCR    
  2085.  
  2086.  
  2087.         LD A,127
  2088.         IN A,(254)
  2089.         RRA
  2090.         JP C,NEWKAD
  2091.  
  2092. STAKP   LD SP,0
  2093.         SCF
  2094.         RET
  2095.  
  2096. ;-------EXTPACK STREAM PROCESSING -------
  2097. EXTP_STRM
  2098.         LD A,(DE)
  2099.         IDE
  2100.         CP -1
  2101.         RET Z
  2102.         CP EX_NEWFRM
  2103.         JR Z,WAIT
  2104.         CP EX_KEYFRM
  2105.         JR Z,EX_KEYF
  2106.  
  2107.         JR NZ,EX_CDEPC
  2108.  
  2109. EX_KEYF
  2110.         ;...
  2111.         JP LSCRENE
  2112.  
  2113. ;------------------
  2114. EX_CDEPC
  2115.         LD C,A          ;MASK1
  2116.         LD B,8
  2117.  
  2118. EX_DPCK RR C
  2119.         JR C,EX_OFFS
  2120.         PUSH BC
  2121.         LD A,(DE)
  2122.         IDE
  2123.         LD C,A
  2124.         XOR A
  2125.         LD B,A          ;OLDB
  2126.         EX AF,AF'
  2127.  
  2128. EX_DBPC RR C
  2129.        JR NC,EX_NOB1
  2130.        LD A,(DE)
  2131.        IDE
  2132.        LD B,A
  2133. EX_NOB1 EX AF,AF'
  2134.         XOR B
  2135.         LD (HL),A
  2136.         EX AF,AF'
  2137.        INC H
  2138.        LD A,H
  2139.        AND 7
  2140.        JR NZ,EX_DBPC
  2141.        INC L
  2142.        JR Z,EX_NOSH
  2143.        LD A,H
  2144.        SUB 8
  2145.        LD H,A
  2146. EX_NOSH POP BC
  2147. EX_CONC DJNZ EX_DPCK
  2148.        CALL EX_CMODE
  2149.        JP EXTP_STRM
  2150.  
  2151. EX_OFFS LD A,(DE)
  2152.        IDE
  2153.        AND A
  2154.        JR Z,EX_FCOLR
  2155.        ADD A,L
  2156.        LD L,A
  2157.        JR NC,EX_CONC
  2158.        LD A,H
  2159.        ADD A,8
  2160.        LD H,A
  2161.        JR EX_CONC
  2162.  
  2163. EX_FCOLR
  2164.        CALL EX_CMODE
  2165.        JR NZ,EX_FCOLR
  2166.        JP EXTP_STRM
  2167.  
  2168. EX_CMODE
  2169.        BIT EXCMODE,(IX)
  2170.        RET Z
  2171.        BIT EXCFIN,(IX)
  2172.        RET Z
  2173.        LD A,(DE)
  2174.        IDE
  2175.        LD C,A          ;MASK
  2176.        LD B,8          ;DATA
  2177.  
  2178. EX_CDPC RR C
  2179.        JR C,EX_COFS
  2180.        LD A,(DE)
  2181.        AND 63
  2182.        EXX
  2183.        LD (HL),A
  2184.        INC HL
  2185.        EXX
  2186.        LD A,(DE)
  2187.        IDE
  2188.        RLA
  2189.        JR NC,EX_CNS
  2190.        RES EXCFIN,(IX)
  2191.        AND 128
  2192.        RET
  2193.  
  2194. EX_CNS  DJNZ EX_CDPC
  2195.        LD A,-1
  2196.        AND A
  2197.        RET
  2198.  
  2199. EX_COFS LD A,(DE)
  2200.        IDE
  2201.        EXX
  2202.        ADD A,L
  2203.        LD L,A
  2204.        ADC A,H
  2205.        SUB L
  2206.        LD H,A
  2207.        EXX
  2208.        JR EX_CNS
  2209.  
  2210.  
  2211. SCRENE  
  2212.  
  2213.        LD HL,FIRST1
  2214. VP_ADR2 equ $-2
  2215.        LD A,(DE)
  2216.        LD C,A
  2217.        IDE
  2218. PCK_CYC LD A,(DE)
  2219.        CP C
  2220.        JR Z,REPT
  2221.        LD B,8
  2222. PGR     LD A,(DE)
  2223.        LD (HL),A
  2224.        INC H
  2225.        IDE
  2226.        DJNZ PGR
  2227.        INC L
  2228.        JR Z,M5
  2229.        LD A,H
  2230.        SUB 8
  2231.        LD H,A
  2232. M5
  2233.        LD A,H
  2234.        CP MAXSCR
  2235.        JR C,PCK_CYC
  2236.        JR NEWK
  2237.  
  2238. REPT    IDE
  2239.        LD A,C
  2240.        EX AF,AF'
  2241.         LD A,(DE)
  2242.         LD C,A
  2243.         IDE
  2244.         LD B,8
  2245.         PUSH HL
  2246. COZN    LD A,(DE)
  2247.         LD (HL),A
  2248.         IDE
  2249.         INC H
  2250.         DJNZ COZN
  2251.         INC L
  2252.         JR Z,NDP1
  2253.         LD A,H
  2254.         SUB 8
  2255.         LD H,A
  2256. NDP1
  2257.         DEC C
  2258.         JR NZ,CONDP
  2259.         POP BC
  2260.         JR ISEND
  2261. CONDP   EX DE,HL ;HL-ADRESS DE-SCREEN+1
  2262.         EX (SP),HL      ;HL-SCREEN DE-SCREEN+1
  2263.         EX DE,HL        ;DE-SCREEN HL-SCREEN+1
  2264. DEPCYC  LD B,8
  2265.         PUSH DE
  2266. COZN1   LD A,(DE)
  2267.         LD (HL),A
  2268.         INC H
  2269.         INC D
  2270.         DJNZ COZN1
  2271.         INC L
  2272.         JR Z,NDP2
  2273.         LD A,H
  2274.         SUB 8
  2275.         LD H,A
  2276. NDP2    POP DE
  2277.         LD A,H
  2278.         CP MAXSCR
  2279.         JR C,CONPKC
  2280.         POP DE
  2281.         JR NEWK
  2282. CONPKC  DEC C
  2283.         JR NZ,DEPCYC
  2284.         POP DE
  2285. ISEND   EX AF,AF'
  2286.        LD C,A
  2287.        LD A,H
  2288.        CP MAXSCR
  2289.        JR C,PCK_CYC
  2290. NEWK
  2291.  
  2292.  
  2293.  
  2294.  
  2295.        LD A,(WAIT+1)
  2296.        SUB 2
  2297.        JP C,ESCR
  2298.        JP Z,ESCR
  2299.        JP W_LOOP
  2300.  
  2301. LSCRENE
  2302.  
  2303.        LD HL,FIRST1
  2304. VP_ADR3 equ $-2
  2305.        EXX
  2306.        LD HL,FSTATR    ;ADR
  2307.        EXX
  2308.  
  2309. LPCK_CYC
  2310.        LD A,(DE)
  2311.        IDE
  2312.        INC A
  2313.        JR Z,NEWK
  2314.        DEC A
  2315.        JR NZ,LREPT
  2316.        LD A,(DE)
  2317.        IDE
  2318.        LD C,A
  2319.        BIT EXCMODE,(IX)
  2320.        JR Z,NOCO1
  2321. DEPSCC  PUSH BC
  2322.        LD C,1
  2323.        CALL DEP_ZN
  2324.        CALL DEPCOL
  2325.        POP BC
  2326.        DEC C
  2327.        JR NZ,DEPSCC
  2328.        JP LPCK_CYC
  2329.  
  2330. NOCO1   CALL DEP_ZN
  2331.        JR LPCK_CYC
  2332. LREPT
  2333.        LD A,(DE)
  2334.        LD C,A
  2335.        IDE
  2336.        PUSH HL
  2337.        PUSH BC
  2338.        LD C,1
  2339.        CALL DEP_ZN
  2340.        CALL DEP_COL_
  2341.        POP BC
  2342.        DEC C
  2343.        JR NZ,CONPA
  2344.        POP AF
  2345.        JR LPCK_CYC
  2346.  
  2347.  
  2348. ;fill empty area with repeat blocks
  2349. CONPA   EX DE,HL        ;HL-ADRESS DE-SCREEN+1
  2350.        EX (SP),HL      ;HL-SCREEN DE-SCREEN+1
  2351.        EX DE,HL        ;DE-SCREEN HL-SCREEN+1
  2352. LDEPCYC LD B,8
  2353.        PUSH DE
  2354. LCOZN1                  LD A,(DE)
  2355.                        LD (HL),A
  2356.        INC H
  2357.        INC D
  2358.        DJNZ LCOZN1
  2359.        INC L
  2360.        JR Z,LNDP2
  2361.        LD A,H
  2362.        SUB 8
  2363.        LD H,A
  2364. LNDP2   POP DE
  2365.        BIT EXCMODE,(IX)
  2366.        JR Z,LCONPKC
  2367.        LD A,L
  2368.        and 31   ;AND 31
  2369.        JR NZ,LCONPKC   ;
  2370.  
  2371.        EX DE,HL   ;ZZZZ
  2372.        EX (SP),HL
  2373.        EX DE,HL
  2374.        CALL DEPCLA
  2375.        EX DE,HL
  2376.        EX (SP),HL
  2377.        EX DE,HL
  2378.  
  2379. LCONPKC DEC C
  2380.        JR NZ,LDEPCYC
  2381. LISEND  POP DE
  2382.        JR LPCK_CYC
  2383.  
  2384. DEP_COL_
  2385.        BIT EXCMODE,(IX)
  2386.        RET Z
  2387. DEPCOL  LD A,L
  2388.        AND 31
  2389.        RET NZ
  2390.  
  2391. DEPCLA  EXX
  2392.        LD E,0
  2393.        EXX
  2394.  
  2395. DPCC1   LD A,(DE)
  2396.        IDE
  2397.        EXX
  2398.        LD C,A
  2399.        LD B,8
  2400.  
  2401. DPCC    RR C
  2402.        JR NC,OLDCOL
  2403.        EXX
  2404.        LD A,(DE)
  2405.        IDE
  2406.        EXX
  2407.        LD E,A
  2408. OLDCOL  LD (HL),E
  2409.        INC HL
  2410.        DJNZ DPCC
  2411.        LD A,L
  2412.        EXX
  2413.        AND 31
  2414.        JR NZ,DPCC1
  2415.        RET
  2416.  
  2417. INCHL   INC H
  2418.        LD A,H
  2419.        AND 7
  2420.        RET NZ
  2421.        INC L
  2422.        RET Z
  2423.        LD A,H
  2424.        SUB 8
  2425.        LD H,A
  2426.        RET
  2427.  
  2428. INCDE1  INC D
  2429.        LD A,D
  2430.        AND 7
  2431.        RET NZ
  2432.        INC E
  2433.        RET Z
  2434.        LD A,D
  2435.        SUB 8
  2436.        LD D,A
  2437.        RET
  2438.  
  2439. R_DE    INC D
  2440.        RET NZ
  2441. SWPAG   LD D,192
  2442.        PUSH AF
  2443.  
  2444.                push de
  2445.                push hl
  2446.                push bc
  2447.  
  2448.                 LD A,(current_ram_page)
  2449.                inc a
  2450.                ld (current_ram_page),a
  2451.                ld l,a
  2452.                ld h,HIGH t_vid_file00_pages_list
  2453.                ld a,(hl)
  2454.                SETPGC000
  2455.  
  2456.                pop bc
  2457.                pop hl
  2458.                pop de        
  2459.  
  2460.        POP AF
  2461.        RET
  2462.  
  2463.  
  2464.  
  2465. ;single row
  2466. DEP_ZN_
  2467. DPMODE  LD A,0
  2468.        AND #AE         ;XOR (HL)
  2469.        LD (XORHL),A
  2470. DEP_ZN
  2471. MAKALL  PUSH BC
  2472.        LD A,(DE)
  2473.        IDE
  2474.        LD B,A  ;MASK
  2475.        XOR A
  2476.        LD C,A  ;PREWDAT
  2477.        LD (OLBYT+1),A
  2478. MAKGR
  2479.        RR B
  2480.        JR NC,OLBYT
  2481.        LD A,(DE)
  2482.        IDE
  2483.        LD (OLBYT+1),A
  2484. OLBYT
  2485.        LD A,0
  2486.        XOR C
  2487.        LD C,A
  2488. XORHL   NOP
  2489.        LD (HL),A
  2490.        INC H
  2491.        LD A,H
  2492.        AND 7
  2493.        JR NZ,MAKGR
  2494.        INC L
  2495.        JR Z,M7_
  2496.        LD A,H
  2497.        SUB 8
  2498.        LD H,A
  2499. M7_     POP BC
  2500.        DEC C
  2501.        JR NZ,MAKALL
  2502.        XOR A
  2503.        LD (XORHL),A
  2504.  
  2505.        RET
  2506.  
  2507.  
  2508. PLFLG   DB 0
  2509.  
  2510.  
  2511.  
  2512.  
  2513.  
  2514.  
  2515.  
  2516. mem_check:
  2517.        ld d,0
  2518.        ld e,0
  2519. .loop
  2520.        push de
  2521.        dec e
  2522.        OS_GETPAGEOWNER
  2523.        ld a,e
  2524.        pop de
  2525.  
  2526.        and a
  2527.        jr nz,.ll
  2528.        inc d
  2529. .ll:
  2530.        dec e
  2531.        jr nz,.loop
  2532.        ;ld h,0
  2533.        ;ld l,d
  2534.        ld a,d
  2535.        ret
  2536.  
  2537.  
  2538. ConvertNumberA:
  2539.    ld h, 0
  2540.    ld l, a
  2541. ConvertNumberHL:
  2542.    ; Get the number in hl as text in de
  2543.    ld bc, -10000
  2544.    call .one
  2545.    ld bc, -1000
  2546.    call .one
  2547.    ld bc, -100
  2548.    call .one
  2549.    ld bc, -10
  2550.    call .one
  2551.    ld c, -1
  2552. .one
  2553.    ld a, "0"-1
  2554. .two
  2555.    inc a
  2556.    add hl, bc
  2557.    jr c, .two
  2558.    push bc;
  2559.    push af;
  2560.    ld a, b;
  2561.    cpl;
  2562.    ld b, a;
  2563.    ld a, c;
  2564.    cpl;
  2565.    ld c, a;
  2566.    inc bc;
  2567.    call c, .carry;
  2568.    pop af;
  2569.    add hl, bc;
  2570.    pop bc;
  2571.    ld (de), a
  2572.    inc de
  2573.    ret
  2574.  
  2575. .carry;
  2576.    dec bc;
  2577.    ret;
  2578.  
  2579. dropotherapps
  2580. ;d=pgmain0000
  2581. ;юЄ яюёыхфэшї id (фхЄхщ) ъ яхЁт√ь (ЁюфшЄхы ь), Є.ъ. яЁш dropapp сєфшЄё  ЁюфшЄхы№
  2582.        ld e,0xfe ;no id 0xff
  2583. dropotherapps0
  2584.        push de
  2585.        OS_GETAPPMAINPAGES ;d,e,h,l=pages in 0000,4000,8000,c000, c=flags ;a!=0: no app
  2586.        or a
  2587.        ld a,d
  2588.        pop de
  2589.        jr nz,dropotherapps_skip ;no app
  2590.       cp d
  2591.       jr z,dropotherapps_skip ;my app
  2592.        push de
  2593.        ;e=id
  2594.        OS_DROPAPP
  2595.        pop de
  2596. dropotherapps_skip
  2597.        dec e
  2598.        ld a,e
  2599.        dec a ;no id 0 ;id 1 = idle
  2600.        cp 3
  2601.        jr nz,dropotherapps0
  2602.        ret
  2603.  
  2604. setpgsmain4000_C000
  2605.        ld a,(winpage1)
  2606.        SETPG4000
  2607.        ld a,(winpage2)
  2608.        SETPG8000
  2609.        ld a,(winpage3)
  2610.        SETPGC000
  2611.        ret
  2612.  
  2613.  
  2614. ;scr_buffer ds 6912,0
  2615.  
  2616. cmd_end:
  2617.  
  2618.  
  2619.        savebin "robocop.com",cmd_begin,cmd_end-cmd_begin
  2620.        LABELSLIST "..\..\us_ns2\user.l",1
  2621.