0

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

Edited by Mme: n/a

2
Contributors
1
Reply
3
Views
7 Years
Discussion Span
Last Post by Salem
0

Create some kind of structured array for your songs (not in-line code)

So

song1_notes dw #568, #455, #380, #361
song1_times dw 1, 1, 1, 2 ; 1 is sixteenth, 2 is short

Your song playing loop steps through the table

PlayOneSong
- input parameters would be pointers to a given song table (above)
- initialise loop and song length values
loop:
- load song1_notes[index]
- move to $B6
- load song1_times[index]
- call appropriate function
- call switches
- if result is non-zero, then act accordingly
-- pause would wait in a tight loop, calling switches until another key is pressed
-- play would do nothing (here)
-- next/prev would return a status to the caller, to set up another song
- endif
- increment index
- goto loop if index < length
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.