?login_element?

Subversion Repositories NedoOS

Rev

Rev 844 | Rev 1908 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. tkeyangle=$-5
  2.               ;LRDU
  3.        ;DB -1 ;0000
  4.        ;DB 128;0001
  5.        ;DB 0  ;0010
  6.        ;DB -1 ;0011
  7.        ;DB 64 ;0100
  8.         DB 96 ;0101
  9.         DB 32 ;0110
  10.         DB 64 ;0111
  11.         DB 192;1000
  12.         DB 160;1001
  13.         DB 224;1010
  14.         DB 192;1011
  15.         DB -1 ;1100
  16.         DB 128;1101
  17.         DB 0  ;1110
  18.         DB -1 ;1111
  19. tkeyangleend
  20.  
  21. ;в 0x4000 включена pgmap
  22. CONTROL
  23. ;режимы двери:
  24. ;0: дверь закрыта
  25. ;1: дверь открывается, doortimer увеличивается
  26. ;2: дверь открыта, dooropentimer уменьшается
  27. ;3: дверь закрывается, doortimer уменьшается
  28. doortimer=$+1
  29.         ld a,0
  30. doortimermode=$+1
  31.         ld b,0
  32.         djnz control_door_noopening
  33.         add a,2
  34.         ld (doortimer),a
  35.         jr nz,control_doorq
  36.         dec a ;-1
  37.         ld (doortimer),a ;stay opened
  38.         ld a,50 ;a=door open time
  39.         ld (dooropentimer),a
  40.         ld a,2
  41.         ld (doortimermode),a
  42.         jr control_doorq
  43. control_door_noopening
  44.         djnz control_door_noopened
  45. dooropentimer=$+1
  46.         ld a,0
  47.         dec a
  48.         ld (dooropentimer),a
  49.         jr nz,control_doorq
  50.         ;call closecurrentdoor ;keeps hl
  51.         ld a,-2
  52.         ld (doortimer),a ;stay opened
  53.         ld a,3
  54.         ld (doortimermode),a
  55.         jr control_doorq
  56. control_door_noopened
  57.         djnz control_door_noclosing
  58. ;если игрок стоит в дверях, то не закрываем, а открываем
  59.         LD HL,(IMcurXx+1)
  60.         LD a,(IMcurYy+1)
  61.         ld h,a
  62.         ld a,ID_DOOR
  63.         cp (hl)
  64.         jr z,control_door_setopened
  65.         inc h
  66.         cp (hl)
  67.         jr z,control_door_setopened
  68.         dec h
  69.         set mapdifbit,l
  70.         cp (hl)
  71.         jr z,control_door_setopened
  72.         inc l
  73.         cp (hl)
  74.         jr z,control_door_setopened
  75.         ld a,(doortimer)
  76.         sub 2
  77.         ld (doortimer),a
  78.         jr nz,control_doorq
  79.         ;xor a
  80.         ld (doortimermode),a
  81.         call closecurrentdoor ;keeps hl
  82.         jr control_doorq
  83. control_door_setopened
  84.         ld a,1
  85.         ld (doortimermode),a
  86. control_door_noclosing
  87. control_doorq
  88.  
  89.        IF kempston
  90.         LD C,#FF
  91.         IN A,(#1F)
  92.         LD B,A
  93.         AND #E0
  94.         jr NZ,nKEMPSTON
  95.         LD A,B
  96.         RRA
  97.         jr NC,$+4
  98.         RES 1,C
  99.         RRA
  100.         jr NC,$+4
  101.         RES 0,C
  102.         RRA
  103.         jr NC,$+4
  104.         RES 3,C
  105.         RRA
  106.         jr NC,$+4
  107.         RES 2,C
  108.         RRA
  109.         jr NC,$+4
  110.         RES 6,C
  111. nKEMPSTON
  112. ;C=%1f11durl
  113.        ENDIF
  114.        IF autostrafe
  115.         BIT 3,C ;down
  116.         jr NZ,nAUTOSTRAFE
  117.         LD A,C
  118.         BIT 1,A
  119.         jr NZ,$+6
  120.         AND %01101111 ;strafe + rotate flag
  121.         OR %00001011 ;block down & rotate
  122.         BIT 0,A
  123.         jr NZ,$+6
  124.         AND %01011111 ;strafe + rotate flag
  125.         OR %00001011 ;block down & rotate
  126.         LD C,A
  127. nAUTOSTRAFE
  128.        ENDIF
  129.         LD B,#FF
  130.         ld a,#fe
  131.         in a,(#fe)
  132.         rra
  133.         rl b ;cs (open)
  134.         LD A,#7F
  135.         IN A,(#FE)
  136.         RRA
  137.         RL B ;space (fire)
  138.         LD A,#FD
  139.         IN A,(#FE)
  140.         RRA
  141.         RL B ;A
  142.         RRA
  143.         RRA
  144.         RL B ;D
  145.         RLA
  146.         RL B ;S (down)
  147.         LD A,#FB
  148.         IN A,(#FE)
  149.         RRA
  150.         RRA
  151.         RL B ;W (up)
  152.         LD A,#DF
  153.         IN A,(#FE)
  154.         RRA
  155.         RL B ;P (right)
  156.         RRA
  157.         LD A,B
  158.         RLA ;O (left)
  159.        IF kempston
  160.         AND C
  161.        ENDIF
  162.  
  163. ;A=%ofADdurl
  164.  
  165.        IF demoplay
  166. demoplayoff=$
  167.         OR A
  168.         jr C,demoplayQ
  169.        BIT 4,A ;"D"
  170.        jr NZ,demoplaynOFF
  171.         LD A,#37 ;scf
  172.         LD (demoplayoff),A
  173.         LD A,#91 ;sub c
  174.         LD (mouseon),A
  175.         LD A,#FF
  176. demoplaynOFF
  177. democursor=$+1
  178.         LD HL,demobegin
  179. demokey=$+1
  180.         LD A,%00111111
  181. demokeytime=$+1
  182.         LD C,1
  183.         DEC C
  184.         jr NZ,CnNEWKEY
  185.         LD A,(HL)
  186.         LD (demokey),A
  187.         INC HL
  188.         LD C,(HL)
  189.         INC HL
  190.         LD (democursor),HL
  191. CnNEWKEY
  192.         LD HL,demokeytime
  193.         LD (HL),C
  194. demoplayQ
  195.        ELSE
  196.        IF demorec
  197. democursor=$+1
  198.         LD HL,demobegin
  199. demokeytime=$+1
  200.         LD C,0
  201.         INC C
  202.         jr Z,CNEWKEY
  203.         CP (HL)
  204.         jr Z,CnNEWKEY
  205. CNEWKEY
  206.         INC HL
  207.         LD (HL),C
  208.         LD C,0
  209.         INC HL
  210. CnNEWKEY
  211.         LD (HL),A
  212.         LD (democursor),HL
  213.         LD HL,demokeytime
  214.         LD (HL),C
  215.        ENDIF
  216.        ENDIF
  217.  
  218. ;a=%ofADdurl
  219.        PUSH AF
  220.         bit 7,a
  221.         jr nz,noopendoor
  222.         ;call closecurrentdoor ;keeps hl
  223.  
  224.         LD HL,(IMcurXx+1)
  225.         LD a,(IMcurYy+1)
  226.         ld h,a
  227.         ld c,ID_DOOR*2
  228.         ld a,(hl)
  229.         add a,a
  230.         cp c
  231.         jr z,opendoor_h_dec
  232.         inc h ;dec h
  233.         ld a,(hl)
  234.         add a,a
  235.         cp c
  236.         jr z,opendoor_h_inc
  237.         dec h ;inc h
  238.         set mapdifbit,l
  239.         ld a,(hl)
  240.         add a,a
  241.         cp c
  242.         jr z,opendoor_l_dec
  243.         inc l
  244.         ld a,(hl)
  245.         add a,a
  246.         cp c
  247.         ;jr z,opendoor
  248.         jr nz,noopendoor
  249. opendoor_l_inc
  250.         push hl
  251.         res 7,(hl)
  252.         inc l
  253.         res 7,(hl)
  254.         jr opendoorok
  255. opendoor_l_dec
  256.         push hl
  257.         res 7,(hl)
  258.         dec l
  259.         res 7,(hl)
  260.         jr opendoorok
  261. opendoor_h_dec
  262.         push hl
  263.         res 7,(hl)
  264.         dec h
  265.         res 7,(hl)
  266.         jr opendoorok
  267. opendoor_h_inc
  268.         push hl
  269.         res 7,(hl)
  270.         inc h
  271.         res 7,(hl)
  272. opendoorok
  273. ;ничего не делать, если hl==(oldopendooraddr2)
  274.        ld de,(oldopendooraddr2)
  275.        or a
  276.        sbc hl,de
  277.        add hl,de
  278.         pop de
  279.        jr z,noopendoor
  280.         call closecurrentdoor ;keeps hl,de
  281.         ld (oldopendooraddr2),hl
  282.         ld (oldopendooraddr),de
  283.         xor a
  284.         ld (doortimer),a
  285.         inc a
  286.         ld (doortimermode),a
  287.         ld a,5
  288.         call sfxplay
  289. noopendoor
  290.        pop af
  291. ;a=%ofADdurl
  292.        bit 6,a
  293.        jp nz,nofire
  294.        push af
  295.        
  296.         call RAYPREPXY
  297.         LD A,SCRWIDPIX/2;0x40;TODO связано с scrwid/2
  298.         ld l,a
  299.         LD (cura),A
  300.         CALL RAYCAST
  301. ;C=dist(scale#)
  302. ;B=texx
  303.         ld a,c
  304.         ld (fire_walldist),a
  305.        if 1==0
  306.        call getuser_scr_high_cur
  307.        SETPG8000
  308.        ld a,(fire_walldist)
  309.        ld hl,0x8000
  310.        ld bc,40
  311.        dup 8
  312.        ld (hl),7
  313.        rla
  314.        rr (hl)
  315.        add hl,bc
  316.        edup
  317.        endif
  318.        
  319.         call SCANMONS      
  320. ;в cursprites лежат данные о видимых спрайтах (от задних к передним)
  321. ;ID 8 (0=end)
  322. ;dist 16
  323. ;xscr 8
  324. ;monster index
  325.         ld hl,cursprites
  326. fire_scan0
  327.         ld a,(hl)
  328.         or a
  329.         jp z,fire_scan0q
  330.         inc l
  331.         ld c,(hl)
  332.         inc l
  333.         ld b,(hl) ;bc=dist
  334.         ld d,b
  335.         ld e,c
  336.         inc l
  337.         dup 3;4
  338.         srl d
  339.         rr e
  340.         edup
  341.         ld a,d
  342.         or a
  343.         jr z,$+4
  344.          ld e,255
  345.         or e
  346.         jr nz,$+3
  347.          inc e
  348.         ld d,t1x/256
  349.         ld a,(de) ;width*k (for typical sprite width)
  350.         ld e,a
  351.         ld a,(hl) ;xscr (центр = 0x40)
  352.         sub e
  353.         jr nc,$+3
  354.          xor a ;a=sprite left margin
  355.         cp SCRWIDPIX/2;0x40;TODO связано с scrwid/2
  356.         jr nc,fire_miss
  357.         ld a,(hl) ;xscr
  358.         add a,e
  359.         jr nc,$+3
  360.          sbc a,a ;a=sprite right margin
  361.         cp SCRWIDPIX/2;0x40;TODO связано с scrwid/2
  362.         jr c,fire_miss
  363.         push hl
  364. ;не убивать, если стена впереди закрывает монстра (т.е. стена ближе)
  365. ;bc=dist
  366. ;приводим к 128..255
  367.         LD DE,#000
  368.         INC B
  369.         DEC B
  370.         LD A,C
  371.         jr Z,fire_MOTOLOGRLQ
  372.        DUP 5;6
  373.         INC D
  374.         SRL B
  375.         RRA
  376.         jr Z,fire_MOTOLOGRLE
  377.        EDUP
  378. fire_MOTOLOGRLQ ;
  379. fire_MOTOLOGRLE ;
  380.         LD C,A ;128..255 ;D=0..5
  381.         LD B,tlogd/256
  382.         LD A,(BC) ;log(dist) = 128..255 for arg>=128
  383.        if atm==0
  384.        SUB 16;64                 ;0..127 for arg=64..127 ;???
  385.        endif
  386.         LD C,A                ;0 for arg<64
  387.         LD B,tlogd2sca/256
  388.          SRA D
  389.          RR E ;DE=+0,+#80,..+#300
  390.         EXD
  391.         ADD HL,BC
  392.         LD a,(HL) ;scale#
  393.         pop hl
  394. fire_walldist=$+1
  395.         cp 0
  396.         jr c,fire_miss
  397.         push hl
  398.        
  399. ;найти этого монстра в таблице монстров
  400.         inc l
  401.         ld l,(hl) ;monster index
  402.         ld h,0
  403.         add hl,hl
  404.         add hl,hl
  405.         add hl,hl ;*8
  406.         ld bc,MONSTRS+1 ;Xx,Yy,TYPEphase,TIMEenergy
  407.         add hl,bc
  408.         ld (hl),0xc0 ;impossible X
  409.         ld a,0;5
  410.         call sfxplay
  411.         pop hl
  412. fire_miss
  413.        if CURSPRITES_RECSZ == 5
  414.        inc l
  415.        endif
  416.         inc l
  417.         jp fire_scan0
  418. fire_scan0q
  419.        
  420.        pop af
  421. nofire
  422.        push af
  423.  
  424. IMavision=$+1
  425.         LD HL,32*256
  426. IMdavision=$+1
  427.         LD DE,100
  428.         AND %10110011
  429.         CP 0
  430.         LD ($-1),A
  431.         jr Z,$+4
  432.         LD E,50 ;key just pressed/released
  433.        IF kempston&autostrafe
  434.         BIT 7,A
  435.         jr NZ,nAUTOROTATE
  436.         BIT 4,A
  437.         jr NZ,$+3
  438.         ADD HL,DE
  439.         BIT 5,A
  440.         jr NZ,$+4
  441.         SBC HL,DE
  442. nAUTOROTATE
  443.        ENDIF
  444.        IF doublerotate
  445.         RRA
  446.         jr C,$+4
  447.         ADD HL,DE
  448.         ADD HL,DE
  449.         RRA
  450.         jr C,$+6
  451.         SBC HL,DE
  452.         SBC HL,DE
  453.        ELSE
  454.         RRA
  455.         jr C,$+3
  456.         ADD HL,DE
  457.         RRA
  458.         jr C,$+4
  459.         SBC HL,DE
  460.        ENDIF
  461.  
  462.         LD A,E
  463.         ADD A,12;10
  464.         jr C,$+3
  465.          LD E,A ;key held: increase rotspd
  466.         LD (IMdavision),DE
  467.        IF mouse
  468.         LD BC,#FBDF
  469.         IN A,(C)
  470. mouseoldx=$+1
  471.         LD C,0
  472.         LD ($-1),A
  473. mouseon=$
  474.        IF demoplay
  475.         XOR A
  476.        ELSE
  477.         SUB C
  478.        ENDIF
  479.         NEG
  480.         LD E,A
  481.         RLA
  482.         SBC A,A
  483.         LD D,A
  484.         EXD
  485.         DUP 6
  486.         ADD HL,HL
  487.         EDUP
  488.         ADD HL,DE
  489.        ENDIF
  490.         LD (IMavision),HL
  491.  
  492. ;делим вектор на коэфф замедления
  493. IMcurDX=$+1
  494.         LD HL,0
  495.         LD B,H
  496.         ld A,L
  497.         SRA B
  498.         RRA
  499.        IF doublespeed
  500.         SRA B
  501.         RRA
  502.        ENDIF
  503.         LD C,A
  504.         CP B
  505.        jr NZ,$+3
  506.        LD C,L
  507.         SBC HL,BC
  508.         LD B,H
  509.         ld C,L
  510. CSLOWXQ
  511. IMcurDY=$+1
  512.         LD HL,0
  513.         LD D,H
  514.         ld A,L
  515.         SRA D
  516.         RRA
  517.        IF doublespeed
  518.         SRA D
  519.         RRA
  520.        ENDIF
  521.         LD E,A
  522.         CP D
  523.        jr NZ,$+3
  524.        LD E,L
  525.         SBC HL,DE
  526.         LD D,H
  527.         ld E,L
  528. CSLOWYQ
  529.        POP AF ;%00ADSWPO
  530.        RRCA
  531.        RRCA
  532.        AND 15
  533.         LD HL,tkeyangle
  534.         ADD A,L
  535.         LD L,A
  536.        IF (tkeyangle^tkeyangleend)&256
  537.         ADC A,H
  538.         SUB L
  539.         LD H,A
  540.        ENDIF
  541.         LD A,(HL)
  542. ;прибавляем вектор направления
  543. ;sin и cos (IMavision+32*N), где N=0..7 в зав. от клавиш
  544. ;0=forth
  545. ;64=left
  546.        CP -1
  547.        JP Z,CTRLnspeed
  548.         LD HL,IMavision+1
  549.         ADD A,(HL)
  550.         LD L,A
  551.         LD H,tcos/256 ;-pi/4..+pi/4
  552.         LD A,(HL)
  553.        ADD A,C
  554.        LD C,A
  555.        BIT 7,(HL)
  556.        jr NZ,$+3
  557.        INC B
  558.        jr C,$+3
  559.        DEC B
  560.         LD A,64
  561.         SUB L
  562.         LD L,A
  563.         LD A,(HL)
  564.        ADD A,E
  565.        LD E,A
  566.        BIT 7,(HL)
  567.        jr NZ,$+3
  568.        INC D
  569.        jr C,$+3
  570.        DEC D
  571. CTRLnspeed
  572.         LD (IMcurDX),BC
  573.         LD (IMcurDY),DE
  574.        DUP 2
  575.         SRA D
  576.         RR E
  577.         SRA B
  578.         RR C
  579.        EDUP
  580.  
  581.         LD HL,(IMcurXx)
  582.         ADD HL,BC
  583.         BIT 7,B
  584.        PUSH DE,HL
  585.         LD HL,(IMcurXx)
  586.         LD DE,256-mindist ;dx>0
  587.         jr Z,$+4
  588.         LD  E,mindist ;dx<0
  589.         ADD HL,DE
  590.         LD A,H
  591.         LD HL,(IMcurYy)
  592.         LD  E,mindist
  593.         SBC HL,DE
  594.         LD B,H
  595.         ADD HL,DE
  596.         ADD HL,DE
  597.         LD L,A
  598.         SET mapdifbit,L
  599.         LD A,(HL)
  600.         LD H,B
  601.         OR (HL)
  602.        POP HL,DE
  603.         RLA ;проходимо?
  604.         jr C,CTRLnX
  605.         LD (IMcurXx),HL
  606.         ;jr CTRLnXq
  607. CTRLnX
  608. ;непроходимо
  609. ;CTRLnXq
  610.         LD HL,(IMcurYy)
  611.         ADD HL,DE
  612.         BIT 7,D
  613.        PUSH HL
  614.         LD HL,(IMcurYy)
  615.         LD DE,256-mindist ;dx>0
  616.         jr Z,$+4
  617.         LD  E,mindist ;dx<0
  618.         ADD HL,DE
  619.         LD A,H
  620.         LD HL,(IMcurXx)
  621.         LD  E,mindist
  622.         SBC HL,DE
  623.         LD B,H
  624.         ADD HL,DE
  625.         ADD HL,DE
  626.         LD L,H
  627.         LD H,A
  628.         LD A,(HL)
  629.         LD L,B
  630.         OR (HL)
  631.        POP HL
  632.         RLA ;проходимо?
  633.        RET C
  634.         LD (IMcurYy),HL ;H!=0
  635.         RET
  636.  
  637. closecurrentdoor
  638. ;keeps hl,de
  639.         ld a,128+ID_DOOR;(hl)
  640. oldopendooraddr=$+1
  641.         ld (killablebyte),a
  642. oldopendooraddr2=$+1
  643.         ld (killablebyte),a
  644.        ld bc,killablebyte
  645.        ld (oldopendooraddr),bc
  646.        ld (oldopendooraddr2),bc
  647.         ret
  648. killablebyte
  649.         db 0
  650.