Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .include "m8535def.inc"
- .def Acc0 = r20
- .def ind_out1 = r21
- .def Acc1 = r22
- .def cursor = r23
- .def Acc2 = r24
- .def enemy = r25
- .def enemy_pos = r26
- .def Acc3 = r27
- .def step = r28
- .def level_start = r19
- .def level_numb = r18
- .org 0x00
- rjmp Reset
- .org 0x006
- rjmp Timer1Ovf
- .org 0x15
- Reset:
- ldi Acc0, high(RAMEND)
- out SPH, Acc0
- ldi Acc0, low(RAMEND)
- out SPL, Acc0
- ldi Acc0, 1
- com Acc0
- sbi DDRC, 0
- sbi DDRC, 1
- sbi DDRB, 4
- sbi DDRB, 5
- sbi DDRB, 6
- sbi DDRB, 7
- cbi DDRD, 5
- cbi DDRD, 6
- cbi DDRD, 7
- ldi Acc0, 0b00000000
- out TCCR1A, Acc0
- ldi Acc0, 0b00001000
- out TCCR1B, Acc0
- ldi Acc0, 200
- out OCR1AH, Acc0
- ldi Acc0, 255
- out OCR1AL, Acc0
- ldi Acc0, 0b00010000
- out TIMSK, Acc0
- ldi step, 3
- ldi level_start, 0
- ldi cursor, 0b10000000
- ldi level_numb, 1
- rcall LevelLabel
- sei
- Loop:
- sbi portB, 4
- cbi portB, 5
- sbi portB, 6
- sbi portB, 7
- nop
- nop
- nop
- sbis PIND, 5
- rjmp left
- sbi portB, 4
- cbi portB, 5
- sbi portB, 6
- sbi portB, 7
- nop
- nop
- nop
- sbis PIND, 6
- rjmp shoot
- sbi portB, 4
- cbi portB, 5
- sbi portB, 6
- sbi portB, 7
- nop
- nop
- nop
- sbis PIND, 7
- rjmp right
- rjmp end
- left:
- ldi Acc0, 1
- rcall Game
- rcall Wait1
- rcall indicator_out4
- rjmp end
- shoot:
- ldi Acc0, 2
- rcall Game
- rcall Wait2
- rcall indicator_out4
- rjmp end
- right:
- ldi Acc0, 3
- rcall Game
- rcall Wait3
- rcall indicator_out4
- rjmp end
- end:
- rjmp Loop
- Game:
- ;если уровень = 0 начать отсчёт и =1
- cpi level_start, 0
- brne shoott
- ldi level_start, 1
- ldi Acc0, 0b00001100
- out TCCR1B, Acc0
- ldi step, 1
- rjmp end_game
- shoott:
- cpi Acc0, 2
- brne move_right
- or enemy, cursor
- sub enemy, cursor
- rjmp end_game
- move_right:
- cpi Acc0, 3
- brne move_left
- cpi cursor, 16
- breq end_game
- lsr cursor
- move_left:
- cpi Acc0, 1
- brne end_game
- cpi cursor, 128
- breq end_game
- lsl cursor
- end_game:
- ; cpi enemy, 0
- ; brne end_game_1
- ; inc level_numb
- ;end_game_1:
- ret
- LevelLabel:
- ldi ind_out1, 0b11000111
- rcall indicator_out1
- ldi ind_out1, 0b11000001
- rcall indicator_out1
- ldi ind_out1, 0b11000111
- rcall indicator_out1
- lvl1:
- cpi level_numb, 1
- ldi enemy, 0b10000000
- brne lvl2
- ldi ind_out1, 0b11111001
- rcall indicator_out1
- rjmp endLabel
- lvl2:
- cpi level_numb, 2
- ldi enemy, 0b11000000
- brne lvl3
- ldi ind_out1, 0b10100100
- rcall indicator_out1
- rjmp endLabel
- lvl3:
- cpi level_numb, 3
- ldi enemy, 0b11010000
- brne lvl4
- ldi ind_out1, 0b10110000
- rcall indicator_out1
- rjmp endLabel
- lvl4:
- cpi level_numb, 4
- ldi enemy, 0b11110000
- brne lvl5
- ldi ind_out1, 0b10011001
- rcall indicator_out1
- rjmp endLabel
- lvl5:
- ldi level_numb, 1
- ldi ind_out1, 0b11111001
- rcall indicator_out1
- rjmp endLabel
- endLabel:
- ret
- indicator_out4:
- cpi step, 1
- brne step2
- ldi enemy_pos, 0b00000001
- rjmp output_start
- step2:
- cpi step, 2
- brne step3
- ldi enemy_pos, 0b01000000
- rjmp output_start
- step3:
- cpi enemy, 0
- brne loose
- inc level_numb
- rjmp label
- loose:
- ldi level_numb, 1
- label:
- rcall LevelLabel
- ldi step, 0
- ldi Acc0, 0b00001000
- out TCCR1B, Acc0
- ldi Acc0, 0b00000000
- out TCNT1H, Acc0
- out TCNT1L, Acc0
- ldi level_start, 0
- rjmp end_ind4_1
- output_start:
- clr ind_out1
- mov Acc0, cursor
- mov Acc3, enemy
- clr Acc2
- ind_loop4:
- inc Acc2
- lsl Acc0
- brcc non
- cusorr:
- ldi ind_out1, 0b00001000
- rjmp enemy_ind
- non:
- ldi ind_out1, 0b00000000
- enemy_ind:
- lsl Acc3
- brcc end_ind4
- add ind_out1, enemy_pos
- end_ind4:
- com ind_out1
- rcall indicator_out1
- cpi Acc2, 4
- brne ind_loop4
- end_ind4_1:
- ret
- indicator_out1:
- clr Acc1
- ind_loop1:
- inc Acc1
- lsl ind_out1
- brcc SetZero
- SetOne:
- sbi PortC, 1
- rjmp Clock
- SetZero:
- cbi PortC, 1
- Clock:
- sbi PortC, 0
- nop
- nop
- cbi PortC, 0
- cpi Acc1, 8
- brne ind_loop1
- ret
- Wait1:
- Wait1_Loop:
- rcall delay
- sbis PIND, 5
- rjmp Wait1_Loop
- ret
- Wait2:
- Wait2_Loop:
- rcall delay
- sbis PIND, 6
- rjmp Wait2_Loop
- ret
- Wait3:
- Wait3_Loop:
- rcall delay
- sbis PIND, 7
- rjmp Wait3_Loop
- ret
- delay:
- clr Acc0
- delay0:
- clr Acc1
- delay1:
- inc Acc1
- cpi Acc1, 45
- brne delay1
- inc Acc0
- cpi Acc0, 40
- brne delay0
- ret
- Timer1Ovf:
- inc step
- rcall indicator_out4
- reti
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement