-
Notifications
You must be signed in to change notification settings - Fork 0
/
sb_music.acm
82 lines (61 loc) · 1.67 KB
/
sb_music.acm
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
;;; ****************************************************************************
;;; Spaceballs - Music
;;;
;;; References
;;; http://codebase64.org/doku.php?id=base:demo_coding_introduction
;;; http://codebase64.org/doku.php?id=base:simple_irq_music_player
;;; ****************************************************************************
;;; Initialize music
lda #$00 ; Clear registers
tax
tay
jsr MUS_INIT
;;; Prepare rasterline interrupt
sei ; Turn off interrupts
lda #$7f
ldx #$01
sta CIA1_IRQ ; Turn off CIA interrupts
sta CIA2_IRQ
stx VIC_IMR ; Turn on raster interrupts
lda #$1b
ldx #$08
ldy #$14
sta VIC_REG1 ; Clear high bit of $d012, set text mode
stx VIC_REG2 ; Single-colour mode
sty VIC_MCTL ; screen at $0400, charset at $2000
lda #<irq ; LSB of interrupt handler code
ldx #>irq ; MSB
sta IRQPTR ; Store in interrupt pointer
stx IRQPTR + 1
ldy #$80 ; Raster line to trigger interrupt
sty VIC_RPOS
lda CIA1_IRQ ; ACK CIA interrupts
lda CIA2_IRQ
asl VIC_IRR ; ACK VIC interrupts
cli
;;; Enter infinite loop
hold
jmp hold
;;; ----------------------------------------------------------------------------
;;; Interrupt routine
;;; ----------------------------------------------------------------------------
irq
;; if PRFL flag set, then show color raster bar
!if PRFL = 1 {
lda VIC_BCOL ; Push current border color to stack
pha
lda #COL_RED ; Set new border color
sta VIC_BCOL
}
jsr MUS_PLAY ; Play music
!if PRFL = 1 {
pla ; Restore original border color
sta VIC_BCOL
}
asl VIC_IRR ; ACK interrupt
pla ; Restore registers from stack
tay
pla
tax
pla
rti ; Return from interrupt