;
; datavariables.h: variables in data memory
;
; author: Marko Kanala, raato ]a t[ mulletronic.com

; CURRENT PATTERN DATA BEGINS AT 0x0100
;  (start of file register bank 1)
;
; Pattern data stored in pattern memory consists of
; - 12 bytes of pattern name
; - 2 full patterns (pattern + fill pattern)
;
; One pattern takes 76 bytes.
;
; So 12 + (2 * 76) = 164 (0xa4) bytes of data memory is needed
; for the current pattern data.
;
; LICENSE
; Creative Commons Attribution-NonCommercial-ShareALike 2.5
;
; You are free:
;
; * to copy, distribute, display, and perform the work
; * to make derivative works
;
; Under the following conditions:
;	
; 1. Attribution. You must attribute the work in the manner specified by the 
;    author or licensor.
; 2. Noncommercial. You may not use this work for commercial purposes.
; 3. Share Alike. If you alter, transform, or build upon this work, you may 
;    distribute the resulting work only under a license identical to this one.
;
; * For any reuse or distribution, you must make clear to others the license 
;   terms of this work.
; * Any of these conditions can be waived if you get permission from the 
;   copyright holder.
;
; Your fair use and other rights are in no way affected by the above.
;
; This is a human-readable summary of the Legal Code.
; See full license at http://creativecommons.org/licenses/by-nc-sa/2.5/legalcode
;
; Copyright: Marko Kanala (raato@mulletronic.com).
;

;
; NOTE: PATTERN/MEASURE DATA IN BANK 1
;
pattern_data		equ		0x0100
; 12 characters of pattern name
pat_name			equ		pattern_data		; 0x100
; the actual pattern data (see constants.h)
pattern				equ		pat_name + 12		; 0x10c
; fill pattern data
fillpattern			equ		pattern + 76		; 0x158

measure_data		equ		fillpattern + 76	; 0x1a4
; 12 characters of track name
track_name			equ		measure_data

;
; /NOTE: PATTERN/MEASURE DATA IN BANK 1
;




;
; NOTE: SYSEX DATA BUFFER IN BANK 2
;
; when doing an inbound or outbound sysex transfer 
; (full memory dump) the data is read 256 bytes at the time to 
;  the FSR bank 2.
;
sysexdata			equ		0x0200






;
; NOTE: BANK 0 starts here (general app vars)
;

; for storing the state in the event of
;  low priority irq
lp_irq_wtmp			equ		0x00
lp_irq_statustmp	equ		0x01
lp_irq_bsrtmp		equ		0x02

; counter and temp regs for led routines in
;  low priority interrupt
led_counter			equ		0x03
led_counter_tmp		equ		0x04
; runs from 0 to 15 for pattern display row select
led_scaler			equ		0x05

; for storing the state in the event of
;  high priority irq
hp_irq_wtmp			equ		0x06
hp_irq_statustmp	equ		0x07
hp_irq_bsrtmp		equ		0x08

; general temp reg for low priority interrupts
lp_irq_temp			equ		0x09

; temp regs for the actual program
temp				equ		0x0a
temp2				equ		0x0b

player_temp			equ		0x0c

ad_delay			equ		0x0d

; 0 == 30 bpm
; 255 = 285 bpm
tempo				equ		0x0e

; 16x2 led display vars
lcd_delay_l			equ		0x0f		
lcd_delay_h			equ		0x10
lcd_delay_z			equ		0x11
lcd_temp			equ		0x12
; set if player trigger routine collides
;  with lcd bus
lcd_player_coll		equ		0x13
bcd_temp			equ		0x14
bcd_result_0		equ		0x15
bcd_result_1		equ		0x16

hp_irq_tblptrh		equ		0x17
hp_irq_tblptrl		equ		0x18

; lcd screens
currentdisplay		equ		0x19
lastdisplay			equ		0x1a

; downkey temp
irq_downkey			equ		0x1b

; current pattern bank
currentbank			equ		0x1c
; 0 - 15
currentpattern		equ		0x1d

; blink flag and counter
blink				equ		0x1e
blink_counter		equ		0x1f

; led storage
leds_busa_1			equ		0x20
leds_busb_1			equ		0x21
leds_busa_2			equ		0x22
leds_busb_2			equ		0x23

; keys storage
irq_key				equ		0x24
last_key			equ		0x25
; holds the current unhandled keypress
keypress			equ		0x26

; contains bits (see constants.inc) of
;  the keys that can be held down
downkeys			equ		0x27
; events
event				equ		0x28
; modes
mode				equ		0x29
; selected instrument
; the order is the same as the memory organisation
;  of the pattern (see pat_<instr>)
selectedinst		equ		0x2a

bpmtick				equ		0x2b	; 0 - 23
bpmscaler			equ		0x2c	; 1 or 0
currentstep			equ		0x2d	; current player step

; blinks with tempo (step advance)
blink_tempo			equ		0x2e

; i2c counter
i2c_counter			equ		0x2f
FADDRH				equ		0x30
FADDRL				equ		0x31

; generic argument store for lcd display
;  routines
display_arg			equ		0x32

; triggers 0 to 5
; xxtttttt
triggers_a			equ		0x33
; triggers 6 to 11
; xxtttttt
triggers_b			equ		0x34
; temp reg for trigger routines
temptrig			equ		0x35
; temp reg for trigger volumes
temptrigvol			equ		0x36

currentstep_instr	equ		0x37
currentstep_bdrum	equ		currentstep_instr		; 0x37
currentstep_sdrum	equ		currentstep_instr+1		; 0x38
currentstep_ltom	equ		currentstep_instr+2		; 0x39
currentstep_mtom	equ		currentstep_instr+3		; 0x3a
currentstep_htom	equ		currentstep_instr+4		; 0x3b
currentstep_rshot	equ		currentstep_instr+5		; 0x3c
currentstep_hclap	equ		currentstep_instr+6		; 0x3d
currentstep_chihat	equ		currentstep_instr+7		; 0x3e
currentstep_ohihat	equ		currentstep_instr+8		; 0x3f
currentstep_crash	equ		currentstep_instr+9		; 0x40
currentstep_ride	equ		currentstep_instr+10	; 0x41
currentstep_accent	equ		currentstep_instr+11	; 0x42

trigdelay			equ		0x43

; blink counter msb
blink_counter2		equ		0x44

; temporary regs for led bus refreshing
leds_temp_1			equ		0x45
leds_temp_2			equ		0x46

; 0 if total accent is off, used in 9090.inc
totalaccent			equ		0x47

; 0 - 15
nextpattern			equ		0x48
nextbank			equ		0x49
; temp regs to hold pattern length and shuffle value
;  to allow flash loading to the pattern_data address
;  while the player is running
currentlength		equ		0x4a
currentshuffle		equ		0x4b

; name entering buffer reg
keyboardbuf			equ		0x4c

; 16 position pattern chain buffer
chainbuffer			equ		0x4d	; 16 positions -> 0x5c
chainposition		equ		0x5d
chainshowpos		equ		0x5e
chainshowblink		equ		0x5f

flamcounter			equ		0x60
flam_a				equ		0x61
flam_b				equ		0x62

midibuffer			equ		0x63

; counter in sysexdata
sysexbytes			equ		0x64
; sysex init counter (F0 + ID)
sysexcounter		equ		0x65
; incoming sysex type (0, 1)
sysextype			equ		0x66
; sysex status reg
sysexstatus			equ		0x67
; sysex temp reg
sysexbuf			equ		0x68
; temp for FSR1 in full mem dump
sysexfsr1l			equ		0x69
sysexfsr1h			equ		0x6a

; how many timer 2 irq:s are waited before
;  DISPLAYCHANGED is true again
lcdwait				equ		0x6b
lcdwaitcounter		equ		0x6c

;
; track play / write variables
;
currenttrack		equ		0x70    ; 0 - 15
currentmeasure		equ		0x71	; 2 bytes, actual measure position
currenttracklen		equ		0x73	; 2 bytes, actual number of measures
currentrepeat       equ     0x75    ; 0 - 3
; note: pattern set in current measure is held in memory buffer
nextmeasure			equ		0x76	; 2 bytes

currentmeasuredata	equ		0x78
editedmeasuredata	equ		0x79
nextmeasuredata		equ		0x7a

; holds the downkey bits that should be
;  waited to be lifted up. Used to generate
;  a pseudo key event from laststep-key in
;  track play/write mode :/
downkeypresses		equ		0x7b
; keyboard.inc cursor position
cursorpos			equ		0x7c

i2c_temp			equ		0x7d
i2c_temp2			equ		0x7e
tw_temp				equ		0x7f

hp_irq_tablat		equ		0x80

repeatcounter		equ		0x81

; settings -->
mode_before_settings equ	0x82
selected_setting	equ		0x83
select_pressed		equ		0x84


settings			equ		0x90	; current sequencer settings
settings_midi_channel equ	0x91	; midi channel

;midi_in_buffer		equ		0x92
;midi_in_buffer_note	equ		0x93
;midi_in_buffer_vel	equ		0x94

;
; copy buffers
;
pattcopybuffer:		equ		0xa0	; 76 bytes of pattern data
instrcopybuffer:	equ		0xec	; triggers, accentes, flams and length
									; = 2 + 2 + 2 + 1 = 7 bytes

; midi velocities for different sounds if 
;  notes should be played to midi out
midi_velocities:	equ		0xf3
midi_bdrum:			equ		0xf3
midi_sdrum:			equ		0xf4
midi_ltom:			equ		0xf5
midi_mtom:			equ		0xf6
midi_htom:			equ		0xf7
midi_rshot:			equ		0xf8
midi_hclap:			equ		0xf9
midi_chihat:		equ		0xfa
midi_ohihat:		equ		0xfb
midi_crash:			equ		0xfc
midi_ride:			equ		0xfd

free:				equ		0xfe

; DATA EEPROM addresses used -->

eeprom_settings		equ		0x00
eeprom_midi_channel equ		0x01

External Labels :

	None.