-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpong.asm
101 lines (59 loc) · 1.45 KB
/
pong.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
BasicUpstart2(start)
*=$080f "Main Code"
#import "input_handling.asm"
#import "collision_detection.asm"
#import "ball_direction_2.asm"
#import "ball_move.asm"
#import "delay.asm"
#import "start_wait.asm"
start: jsr $e544 //clears screen, built in sub-routine at this location
// set colors of screen
lda #BLACK
sta $d021
lda #BLUE
sta $d020
//
lda collision_data
jsr set_sprt
jsr wait_for_key
pre_loop:
lda start_game
bne start_music
jmp pre_loop
start_music:
jsr init_music
jsr set_irq
loop:
jsr delay
jsr detect_collisions
jsr set_directions
jsr move_ball
rts
jmp loop
set_irq:
sei // turn off irq
ldy #$7f // $7f = %01111111
sty $dc0d // Turn off CIAs Timer interrupts
sty $dd0d // Turn off CIAs Timer interrupts
lda $dc0d // cancel all CIA-IRQs in queue/unprocessed
lda $dd0d // cancel all CIA-IRQs in queue/unprocessed
lda #$01
sta $d01a // request rasterbeam irq
lda #<irq
ldx #>irq
sta $314
stx $315 //store pointer to custom irq routine
lda #$85
sta $d012 // set first 7 bits of raster line to generate irq at
lda $d011
and #$7f
sta $d011 // turn off 9th bit of raster line to generate irq at
cli // turn irq on
rts
irq: dec $d019 // acknowledge IRQ
jsr play
jsr handle_input
jmp $ea81 // return to kernel IRQ routine
//must be imported last, as they create a memory block
#import "music_player.asm"
#import "sprite_config.asm"