I'm working with a HCS12 Motorola chip trying to make a MIDI player. Got stuck on the function of play/pause/forward/back. These are controlled by external switches set to high and low.
Below is my attempted switch settings:
switches
LDD $0000
CPD #$0001;"pause" button
BNE AFTER_1
PAUSED
LDD $0000
CPD #$0002; "play" button
BNE PAUSED
AFTER_1
LDD $0000
CPD #$0004;"next" button
BNE AFTER_4
bra NEXT_SONG; the location for next song
AFTER_4
LDD $0000
CPD #$0008;"back" button
BNE AFTER_8
bra LAST_SONG; the location of last song
AFTER_8
Don't really know how to simultaneously run the switch program and the main music program. Ideally should use a port P Interrupt, then altering the stack before RTI? But I have no idea how to program this.
Also am not sure how to set up
NEXT_SONG
and
LAST_SONG
.
A segment from my melody part looks like this:
alice JSR alicemainmelo
MOVW #568, $B6
JSR sixteenth
MOVW #455, $B6
JSR sixteenth
MOVW #380, $B6
JSR sixteenth
MOVW #361, $B6
JSR short
MOVW #1720, $B4
JSR sixteenth
MOVW #1136, $B4
JSR sixteenth
MOVW #860, $B4
JSR sixteenth
MOVW #568, $B6
JSR sixteenth
JSR alicemainmelo
MOVW #568, $B6
JSR sixteenth
MOVW #361, $B6
JSR sixteenth
MOVW #380, $B6
JSR sixteenth
MOVW #430, $B6
JSR short
MOVW #1720, $B4
JSR sixteenth
MOVW #1136, $B4
JSR sixteenth
MOVW #860, $B4
JSR sixteenth