;----------------------------------------------------------------: ; | ; N A K A M U R A S P E C I A L M O D U L E | ; | ; Sound Toy [Prelude-1] Board | ; | ;----------------------------------------------------------------: ;========== Data Area ===================================== dseg abs d_area(04000h) tone_data_bank: ds 128*10 ; Tone Data Parameter dseg abs b_area(08000h) tx_fifo: ds 256*16 ; MIDI TX FIFO (8000-8FFF) fnum_1_l: ds 256*16 ; F-Number (L) #1 (9000-9FFF) fnum_1_m: ds 256*16 ; F-Number (M) #1 (A000-AFFF) fnum_1_h: ds 256*16 ; F-Number (H) #1 (B000-BFFF) dseg abs r_area(0fdc0h) bank_buff: ds 16 ; offset = DSP-01 dsp_vib_ctr: ds 16 ; offset = DSP-01 dsp_vib_spd: ds 16 ; offset = DSP-01 dsp_vib_add: ds 16 ; offset = DSP-01 dsp_vib_dat: ds 16 ; offset = DSP-01 dsp_vib_flg: ds 16 ; offset = DSP-01 bender: ds 16 ; offset = MIDI : Default = [40] volume: ds 16 ; offset = MIDI : Volume Buffer work: ds 10 ; Universal Work Area calc: ds 12 ; Calculator Area loop_counter: ds 1 ; Job [E] Buffer play_data_1: ds 4 ; Play Data Buffer (1) play_data_2: ds 4 ; Play Data Buffer (2) play_data_3: ds 4 ; Play Data Buffer (3) play_buffer: ds 4 ; Play Mode Status Buffer play_trk: ds 1 ; Play Check Track NO. play_bit: ds 1 ; Play Check Track Bit Map pedals: ds 16 ; Danper=[0] Soft=[1] iseg abs i_area(0ff00h) assign_ctr: ds 16 ; offset = DSP-01 : [0]=Newest ,[10h]=Empty assign_note: ds 16 ; offset = DSP-01 assign_ch: ds 16 ; offset = DSP-01 : Output = MIDI CH assign_pc: ds 16 ; offset = MIDI tempo: ds 1 ; ** Tempo : 8-254 relative_tempo: ds 1 ; ** Relative Tempo , 40h = [1:1] time_base_para: ds 1 ; 2=TB:48,3=TB:72,...,8=TB:192 temp: ds 4 ; Tempo Caluclate Buffer mode_flags: ds 1 ; 0 = [Default Status] int_flg: ds 1 ; Interrupt Check Flags run_mode: ds 1 ; Record/Play/ME Status Mode Flag time_number: ds 3 ; Time Base Count Number Data time_counter: ds 3 ; Current Count Data play_counter: ds 4 ; Play Counter active_status: ds 1 ; Active Track Status Buffer tx_top: ds 2 ; dsp_tx_end: ds 2 ; DSP-01 Tone Generator TX FIFO End dsp_channel: ds 1 ; MIDI Channel Buffer dsp_rsb: ds 1 ; Running Status Buffer dsp_dcb: ds 1 ; Data Count Buffer dsp_data_1st: ds 1 ; DSP-01 Received 1 Byte Data Buffer dsp_data_2nd: ds 1 ; DSP-01 Received 1 Byte Data Buffer on_pointer: ds 1 ; Assign ON Pointer ch_buff: ds 1 ; Bend Channel Buffer vib_timer: ds 1 ; Vibrate Speed Timer stack_hl: ds 2 ; HL Buffer led_timer: ds 4 ; LED Display Timer pointer_1: ds 2 ; pointer_2: ds 2 ; pointer_3: ds 2 ; pointer_4: ds 2 ; ad_sum: ds 2 ; ad_flg: ds 1 ; ;========== Port Defines Area ============================= dsp-01 equ 0fa00h ; Tone Generator [DSP-01] : FA00-FBFF internal_ram equ 0fdc0h ; Internal RAM Top Address port_p01cr equ 0ffc2h ; Port 0/1 Control port_p2cr equ 0ffc5h ; Port-2 Control port_iop3 equ 0ffc6h ; Port-3 port_p3cr equ 0ffc7h ; Port-3 Control port_p4cr equ 0ffc9h ; Port-4 Control port_iop5 equ 0ffcah ; Port-5 port_smmod equ 0ffcbh ; Stepping Motor Mode port_iop6 equ 0ffcch ; Port-6 port_iop7 equ 0ffcdh ; Port-7 port_p67cr equ 0ffceh ; Port-6/7 Control port_iop8 equ 0ffd0h ; Port-8 port_p8cr equ 0ffd1h ; Port-8 Control port_wdmod equ 0ffd2h ; Watch Dog Timer Mode port_wdcr equ 0ffd3h ; Watch Dog Timer Control port_treg0 equ 0ffd4h ; 16bit Timer <0/1> port_treg2 equ 0ffd6h ; 8bit Timer <2> port_treg3 equ 0ffd7h ; 8bit Timer <3> port_tclk equ 0ffd8h ; Timer Source Control port_tmod equ 0ffdah ; Timer Mode port_trun equ 0ffdbh ; Timer/Serial Baud Rate port_treg5 equ 0ffe2h ; 16bit Timer <5> [low] port_t4mod equ 0ffe4h ; 16bit Timer Mode port_t4ffcr equ 0ffe5h ; 16bit Timer Control port_intel equ 0ffe6h ; Interrupt Enable Mask [low] port_inteh equ 0ffe7h ; Interrupt Enable Mask [high] port_dmaeh equ 0ffe8h ; Micro DMA Enable Mask [high] port_scmod equ 0ffe9h ; Serial Channel Mode port_sccr equ 0ffeah ; Serial Channel Control port_scbuf equ 0ffebh ; Serial Channel Buffer port_bx equ 0ffech ; Bank Register x port_by equ 0ffedh ; Bank Register y port_adreg equ 0ffeeh ; A/D Converter Data Buffer port_admod equ 0ffefh ; A/D Converter Control ;========== Bit Map Defines Area ========================== int_bit_timer equ 1 ; Time Base int_bit_tim_1 equ 2 ; 1msec tempo_bit equ 1 ; Port_TRUN ; Tempo Count ON/OFF real_play equ 4 ; 0 = NOP , 1 = Play pedal_damper equ 0 ; pedals ; 0 = Off , 1 = On pedal_soft equ 1 ; 0 = Off , 1 = On ;========== MACRO Defines ================================= %define(dsp-01_system(offset,data))( ld (dsp-01+%offset),%data nop ld (dsp-01+0f3h),%data ) %define(dsp-01_16ch(offset,data)) local loop( ldw (work+1),dsp-01+%offset ld (work+0),%data call @_setting_16 ) %define(move_3byte(dst,src))( ld a,(%src+0) ld (%dst+0),a ld a,(%src+1) ld (%dst+1),a ld a,(%src+2) ld (%dst+2),a ) %define(shift(d1,d2,d3))( ldw (work+0),%d1 ldw (work+2),%d2 ldw (work+4),%d3 call _shift_sub ) %define(range(d1,d2))( ld hl,%d1 ld de,%d2 ld bc,00e80h lddr ) %define(data_set_16(address,data)) local loop( ldw (work+1),%address ld (work+0),%data call @_setting_16 ) ;========== Head Program Area ============================= cseg abs c_area(0) di ld sp,0ffc0h call system_setup ; System Initialize --> Main Loop jp main_start ;========== Interrupt Vector/Sequence ===================== org 10h ; Software Interrupt : SWI reti org 18h ; Non Mascable Interrupt : NMI reti org 20h ; Watch Dog Timer : INTWD reti org 28h ; External Interrupt #0 : INT0 reti org 30h ; Timer Interrupt #0 : INTT0 reti org 38h ; Timer Interrupt #1 : INTT1 push hl ld hl,(time_counter) add hl,(time_number) jr _int_time_base org 40h ; Timer Interrupt #2 : INTT2 reti org 48h ; Timer Interrupt #3 : INTT3 set int_bit_tim_1,(int_flg) reti org 50h ; Timer Interrupt #4 : INTT4 reti org 58h ; External Interrupt #1 : INT1 reti org 60h ; Timer Interrupt #5 : INTT5 reti org 68h ; External Interrupt #2 : INT2 reti org 70h ; UART Receive Interrupt : INTRX reti org 78h ; UART Transmit Interrupt : INTTX reti _int_time_base: ld (time_counter),hl ld a,(time_counter+2) adc a,(time_number+2) ld (time_counter+2),a jr nc,_int_tb_ret set int_bit_timer,(int_flg) ; Time Counter Event ! _int_tb_ret: pop hl reti ;========== System Initialize Routine ===================== system_setup: ;<< DSP-01 Initialize >> ld (port_iop3),11111011b ; DSP-01 Reset ! call @_wait_timer ; (wait) ld (port_iop3),11111111b ; DSP-01 Start ! call @_wait_timer ; (wait) %dsp-01_system(0f5h,0) ; Memory Bus Close ;<< CPU : TMP91C640 Initialize >> ld (port_wdmod),01110000b ; Watch Dog OFF ld (port_wdcr),0b1h ; Watch Dog OFF ld (port_intel),01000000b ; Interrupt Enable ld (port_inteh),00000001b ; Interrupt Enable ld (port_dmaeh),00000000b ; Micro DMA Disable ld (port_p01cr),00000110b ; Port 0/1 = Data/Address Bus ld (port_p2cr),11111111b ; Port 2 = Address Bus ld (port_p3cr),10101001b ; Port 3 = UART ld (port_sccr),00000000b ; Port 3 = Constant ld (port_p4cr),00001111b ; Port 4 = Bank Address ld (port_smmod),00000000b ; Port 6/7 = Port ld (port_p67cr),11111111b ; Port 6/7 = Output ld (port_p8cr),00001000b ; Port 8 = Output/Buzzer ld (port_scmod),00101000b ; UART Control ld (port_trun),10101111b ; Baud Rate ld (port_tmod),00000100b ; 8bit Timer Mode ld (port_tclk),10010001b ; Timer Assign ld (port_t4mod),00000110b ; 16bit Timer Mode ld (port_t4ffcr),00001011b ; 16bit Timer Control ldw (port_treg0),0ffffh ; (dummy) Tempo ld (port_treg2),3 ; MIDI Divide Rate : 12MHz ld (port_treg3),187 ; 1msec Interval Constant(1) ld (port_admod),0f0h ; A/D Wait ld (port_bx),00h ; ROM/RAM Area ld (port_by),00h ; ld (port_iop6),0ffh ; LED Off ld (port_iop7),0ffh ; ;<< DSP-01 Initialize >> %dsp-01_system(0f0h,0) ; Random Bit Pattern %dsp-01_16ch(000h,0) ; F-NO.(L) %dsp-01_16ch(010h,0) ; F-NO.(M) %dsp-01_16ch(020h,0) ; F-NO.(H) %dsp-01_16ch(030h,0) ; Start Point %dsp-01_16ch(040h,0) ; Loop Top %dsp-01_16ch(050h,0) ; Loop End %dsp-01_16ch(060h,0) ; Bank %dsp-01_16ch(070h,0) ; Panpot %dsp-01_16ch(0a0h,0f0h) ; Attack Level %dsp-01_16ch(0b0h,00fh) ; Attack Speed call @_dsp-01_all_off ; All Note Off %dsp-01_system(0f2h,00101111b) ; Output Parameter %dsp-01_system(0f5h,1) ; Memory Bus Open ;<< RAM Area Initialize >> ld hl,internal_ram ; Internal RAM Area ld bc,512-16 _int_ram_clear: ld (hl),0 inc hl djnz bc,_int_ram_clear call init_tone_set ; TONE Module call @_dsp-01_all_off ; Tone Generator All Note Off ld (time_base_para),2 ; Time Base = 48 ld (relative_tempo),40h ; Relative Tempo = 1:1 ld a,(sequence_tempo) ld (tempo),a call @_tempo_setting ; BIOS call @_rel_tempo_set ; BIOS %data_set_16(volume,190) ; MIDI Volume %data_set_16(bender,40h) ; MIDI Bender %data_set_16(dsp_vib_dat,8) ; Vibrate Default Offset ld (port_admod),11111000b ; A/D Start ! ei ret ;========== Main Loop ===================================== main_start: nop main_loop: call @_dsp-01_rx_chk ; TGEN call @_dsp-01_vibrate ; TGEN call @_int_1msec_seq ; BIOS bit int_bit_timer,(int_flg) call nz,@_play_check ; BIOS jr main_loop @_play_check: res int_bit_timer,(int_flg) bit real_play,(run_mode) ; Playing ? ret z cp (active_status),0 ret z ld (play_trk),3 ; Track NO. ld (play_bit),00001000b ; Track Bit _play_chk_loop: ld a,(active_status) and a,(play_bit) ; Active Track ? jr z,_play_chk_next ld hl,play_counter ld a,(play_trk) cp (hl+a),2 ; Play_Counter End ? jr c,_play_chk_hit dec (hl+a) ; NO --> Decrement Only jr _play_chk_next _play_chk_hit: ld hl,play_data_1 ld b,(hl+a) bit 7,b ; 1st Event ? jr z,_play_chk_pass ld a,b and a,11110000b cp a,11110000b jr nz,_play_chk_midi cp b,0fch ; Track End ? jr z,_play_chk_end jr _play_chk_recov ; F8 or F9 _play_chk_midi: ld c,b ; Status ld a,(play_trk) slaa slaa or a,b ld b,a call @_tx_midi_set ; MIDI Status Tx. Set ld hl,play_data_2 ld a,(play_trk) ld b,(hl+a) call @_tx_midi_set ; MIDI Key-Num. Tx. Set and c,11100000b cp c,11000000b ; Status = [Cn]/[Dn] ? jr z,_play_chk_pass ld hl,play_data_3 ld a,(play_trk) ld b,(hl+a) call @_tx_midi_set ; MIDI Velocity Tx. Set _play_chk_pass: call @_play_request ; MPU Next Data Request Sequence ld hl,play_counter ld a,(play_trk) cp (hl+a),0 ; Soon Get Next Data ? jr z,_play_chk_hit _play_chk_next: dec (play_trk) srl (play_bit) jr nc,_play_chk_loop ret _play_chk_recov: ld hl,play_buffer ld a,(play_trk) ld b,(hl+a) ld hl,play_data_1 ld (hl+a),b jr _play_chk_pass _play_chk_end: ld a,(play_bit) cpl a and a,(active_status) ld (active_status),a jr nz,_play_chk_next res real_play,(run_mode) ret ;<< NO.[ 11 ] Play Data Request >> @_play_request: ld b,(play_trk) call @_receive_wait ; Wait Check ld hl,play_counter ld a,(play_trk) ld (hl+a),b cp b,0f8h ; Timing Overflow ? jr nc,_play_hit_f8 call @_receive_wait ; Wait Check ld c,b and c,0f0h cp c,0f0h jr nz,_play_wait_cont ld hl,play_data_1 ld a,(play_trk) ld c,(hl+a) ld (hl+a),b ld hl,play_buffer ld (hl+a),c ret _play_hit_f8: ld (hl+a),240 ld hl,play_data_1 ld c,(hl+a) ld (hl+a),0f8h ld hl,play_buffer ld (hl+a),c ret _play_wait_cont: bit 7,b jr z,_play_running ld hl,play_data_1 ld a,(play_trk) ld (hl+a),b call @_receive_wait ; Wait Check _play_running: ld hl,play_data_2 ld a,(play_trk) ld (hl+a),b ld hl,play_data_1 ld c,(hl+a) and c,11100000b cp c,11000000b ; Status = [Cn]/[Dn] ? ret z call @_receive_wait ; Wait Check ld hl,play_data_3 ld a,(play_trk) ld (hl+a),b ret ;<< NO.[ 16 ] Play Sequence Data Get Waiting Check : Return = [B] >> @_receive_wait: cp (play_trk),0 jr z,_wait_0 cp (play_trk),1 jr z,_wait_1 cp (play_trk),2 jr z,_wait_2 cp (play_trk),3 jr z,_wait_3 _wait_0: ld hl,(pointer_1) ld b,(hl) inc hl ld (pointer_1),hl ret _wait_1: ld hl,(pointer_2) ld b,(hl) inc hl ld (pointer_2),hl ret _wait_2: ld hl,(pointer_3) ld b,(hl) inc hl ld (pointer_3),hl ret _wait_3: ld hl,(pointer_4) ld b,(hl) inc hl ld (pointer_4),hl ret ;<< NO.[ 17 ] Relative Tempo Setting >> @_rel_tempo_set: ld hl,0100h div hl,(relative_tempo) mul hl,40h res tempo_bit,(port_trun) ld (port_treg0),hl ; Timer [A] = Time Base set tempo_bit,(port_trun) ret ;<< NO.[ 19 ] 16 Byte Data Setting : [work+0] --> [work+1/2] >> @_setting_16: ld a,(work) ld hl,(work+1) ld b,16 _set_16: ld (hl),a inc hl djnz _set_16 ret ;<< NO.[ 20 ] Tempo Setting : Input Data = (tempo) >> @_tempo_setting: ld l,(time_base_para) mul hl,07dh ld (temp+0),hl ld a,(time_base_para) slaa slaa add a,(temp+1) ld (temp+2),a ld l,(tempo) mul hl,(temp+0) ld (temp+1),h ld (time_number+0),l ld l,(tempo) mul hl,(temp+2) ld (temp+2),hl ld a,(temp+1) add a,(temp+2) ld (time_number+1),a ld a,(temp+3) adc a,0 ld (time_number+2),a ret ;<< NO.[ 24 ] MIDI Transmit Data Set : Input = [ B ] >> @_tx_midi_set: push de ld hl,(tx_top) ld de,tx_fifo add hl,de ld (hl),b incw (tx_top) bit 4,(tx_top+1) jr z,_tx_midi_ex ldw (tx_top),0 _tx_midi_ex: pop de ret ;<< NO.[ 25 ] Waiting Timer >> @_wait_timer: ld bc,07fffh _wait_loop: nop djnz bc,_wait_loop ret ;<< NO.[ 29 ] 24*24-->48 Multiply : [calc+0/2]*[calc+3/5] --> [calc+6/11] >> @_24_24_to_48: ld l,(calc+0) mul hl,(calc+3) ld (calc+6),l ; LSB 8bit ld c,h ld b,0 ld l,(calc+1) mul hl,(calc+3) ld e,l ld d,0 ld (calc+8),h ld l,(calc+0) mul hl,(calc+4) ld (calc+9),h ld h,0 add hl,bc add hl,de ld (calc+7),l ; 2nd LSB 8bit ld c,(calc+8) ld b,0 ld e,(calc+9) ld d,0 ld l,h ld h,0 add hl,bc add hl,de ld ix,hl ld l,(calc+2) mul hl,(calc+3) ld c,l ld b,0 ld (calc+9),h ld l,(calc+1) mul hl,(calc+4) ld e,l ld d,0 ld (calc+10),h ld l,(calc+0) mul hl,(calc+5) ld (calc+11),h ld h,0 add hl,ix add hl,bc add hl,de ld (calc+8),l ; 3rd LSB 8bit ld c,(calc+9) ld b,0 ld ix,bc ld c,(calc+10) ld b,0 ld e,(calc+11) ld d,0 ld l,h ld h,0 add hl,ix add hl,bc add hl,de ld bc,hl ld l,(calc+2) mul hl,(calc+4) ld e,l ld d,0 ld (calc+10),h ld l,(calc+1) mul hl,(calc+5) ld (calc+11),h ld h,0 add hl,bc add hl,de ld (calc+9),l ; 3rd MSB 8bit ld c,(calc+10) ld b,0 ld e,(calc+11) ld d,0 ld l,h ld h,0 add hl,bc add hl,de ld bc,hl ld l,(calc+2) mul hl,(calc+5) add hl,bc ld (calc+10),l ; 2nd MSB 8bit ld (calc+11),h ; MSB 8bit ret ;<< NO.[ 30 ] 48Bit --> 24Bit Cutting : [calc+6/11] --> [calc+0/2] >> @_48_cut_to_24: sla (calc+8) ld a,0 adc a,(calc+9) ld (calc+0),a ld a,0 adc a,(calc+10) ld (calc+1),a ld a,0 adc a,(calc+11) ld (calc+2),a ret ;<< NO.[ 31 ] 48Bit-->24Bit Cut + 1Bit Shift : [calc+6/11] --> [calc+0/2] >> @_48_shift_24: rl (calc+8) ld a,(calc+9) rla ld (calc+0),a ld a,(calc+10) rla ld (calc+1),a ld a,(calc+11) rla ld (calc+2),a ret ;========== Tone ON Event Routine ======== @_dsp_on_send: ld b,0fah ; DSP-01 = [FA**] ld c,e or c,0c0h ld (bc),0f0h ld c,e or c,0d0h ld (bc),00fh ld c,e or c,090h ld (bc),0 ; OFF ld a,(dsp_channel) ld (ch_buff),a ld hl,assign_note ld a,e ld b,(dsp_data_1st) ld (hl+a),b call @_dsp_on_pitch ; ### Common Subroutine ### ld hl,(stack_hl) inc hl inc hl ; 2 ld a,(hl) ld c,e or c,040h ld (bc),a inc hl ; 3 ld a,(hl) ld c,e or c,050h ld (bc),a inc hl ; 4 ld d,(hl) push hl ld hl,bank_buff ld a,e ld (hl+a),d ld c,e or c,060h ld (bc),d ld c,e or c,070h ld (bc),127 pop hl inc hl ; 5 ld c,(hl) push hl ld hl,volume ld a,(dsp_channel) ld l,(hl+a) mul hl,c ld a,h ld l,(dsp_data_2nd) mul hl,a ld a,h ld hl,_speed_table ld d,(hl+a) ld c,e or c,0a0h ld (bc),d pop hl inc hl ; 6 ld a,(hl) ld c,e or c,0b0h ld (bc),a inc hl ; 7 ld c,(hl) cp c,0 jr z,_on_decay_0 push hl ld hl,volume ld a,(dsp_channel) ld l,(hl+a) mul hl,c ld a,h ld l,(dsp_data_2nd) mul hl,a ld a,h ld hl,_speed_table ld a,(hl+a) pop hl jr _on_decay_set _on_decay_0: ld a,0f0h _on_decay_set: ld c,e or c,0c0h ld (bc),a inc hl ; 8 ld a,(hl) ld c,e or c,0d0h ld (bc),a ld c,e or c,090h ld (bc),3 ; ON ! ret _speed_table: db 0f0h,08fh,07fh,06ch,06fh,05ch,05fh,04ch db 04fh,038h,039h,03ah,03bh,03ch,03dh,03eh db 03fh,028h,029h,02ah,02bh,02ch,02dh,02eh db 02fh,02fh,018h,018h,019h,019h,01ah,01ah db 01bh,01bh,01ch,01ch,01dh,01dh,01eh,01eh db 01fh,01fh,008h,008h,009h,009h,009h,00ah db 00ah,00ah,00bh,00bh,00bh,00ch,00ch,00ch db 00eh,00eh,00eh,00eh,00fh,00fh,00fh,00fh ;========== OFF Event Routine ======== @_dsp_off_send: ld a,(dsp_channel) ld hl,assign_pc ld l,(hl+a) mul hl,10 ; Parameter Counts add hl,tone_data_bank+9 ; Release ld b,0fah ; DSP-01 = [FA**] ld c,e or c,0c0h ld (bc),0f0h ld a,(hl) ld c,e or c,0d0h ld (bc),a ld c,e or c,090h ld (bc),0 ; OFF ! ret @_dsp_off_rhythm: ld b,0fah ; DSP-01 = [FA**] ld c,e or c,090h ld (bc),0 ; OFF ret ;========== Common Pitch Write Routine ======== @_dsp_on_pitch: ld hl,assign_pc ld a,(ch_buff) ld l,(hl+a) mul hl,10 ; Parameter Counts add hl,tone_data_bank ; Top ld (stack_hl),hl bit 0,(hl) jr z,_on_shift_next sub b,12 _on_shift_next: bit 1,(hl) jr z,_on_shift_end sub b,24 _on_shift_end: and b,7fh ld a,(ch_buff) ld hl,bender ld c,(hl+a) ld hl,dsp_vib_dat ld a,(hl+a) add a,c ld c,a sub b,2 ld l,32 mul hl,b ld b,0 add hl,bc ld c,08h add hl,bc or h,10010000b ld b,0fah ; DSP-01 = [FA**] ld a,(hl) ld c,e ld (bc),a and h,00001111b or h,10100000b ld a,(hl) or c,010h ld (bc),a or h,00010000b ld a,(hl) ld c,e or c,020h ld (bc),a ld hl,(stack_hl) inc hl ; 1 ld a,(hl) ld c,e or c,030h ld (bc),a ret ;========== < MIDI Receive > Check ======== @_dsp-01_rx_chk: ld hl,(dsp_tx_end) cp hl,(tx_top) ; FIFO Event ? ret z ld de,tx_fifo add hl,de ld b,(hl) incw (dsp_tx_end) bit 4,(dsp_tx_end+1) jr z,_tx_dsp_nx ldw (dsp_tx_end),0 _tx_dsp_nx: bit 7,b jr z,dsp_running cp b,0f8h ret nc ; Realtime = Pass ! cp b,0f0h jr c,dsp_status ld (dsp_rsb),0 ; [F0]-[F7] = Pass ! ret dsp_status: ld a,b and b,11110000b ld (dsp_rsb),b and a,00001111b ld (dsp_channel),a ld (dsp_dcb),0 ret dsp_running: ld a,(dsp_rsb) cp a,0 ret z cp (dsp_dcb),0 jr nz,_dsp_run_2nd ld (dsp_data_1st),b cp a,0c0h jp z,dsp_prog_change cp a,0d0h ret z ld (dsp_dcb),1 ret _dsp_run_2nd: ld (dsp_data_2nd),b ld (dsp_dcb),0 ld a,(dsp_rsb) cp a,080h jp z,dsp_note_off cp a,090h jp z,dsp_note_on cp a,0b0h jp z,dsp_cont_change cp a,0e0h jp z,dsp_pitch_bend ret dsp_note_off: ld e,0 ; Assign Channel _assign_off_1: ld hl,assign_ctr ld a,e cp (hl+a),10h jr z,_assign_off_2 ld hl,assign_ch ld a,(hl+a) cp a,(dsp_channel) jr nz,_assign_off_2 ld hl,assign_note ld a,e ld a,(hl+a) cp a,(dsp_data_1st) jr z,_assign_off_3 _assign_off_2: inc e cp e,10h jr nz,_assign_off_1 ret _assign_off_3: ld hl,assign_ctr ld a,e ld b,(hl+a) ld d,0 _assign_off_4: ld a,d cp (hl+a),10h jr z,_assign_off_6 ld a,(hl+a) cp a,b jr z,_assign_off_5 jr c,_assign_off_6 ld a,d dec (hl+a) jr _assign_off_6 _assign_off_5: ld a,e ld (hl+a),10h _assign_off_6: inc d cp d,10h jr nz,_assign_off_4 ld hl,pedals ld a,(dsp_channel) bit pedal_damper,(hl+a) ret nz jp @_dsp_off_send ; DSP-01 Trigger dsp_note_on: cp (dsp_data_2nd),0 jp z,dsp_note_off ld hl,pedals ld a,(dsp_channel) bit pedal_soft,(hl+a) jr z,_not_soft_on srl (dsp_data_2nd) _not_soft_on: ld e,0 ; Assign Channel _assign_on_1: ld hl,assign_ctr ld a,e cp (hl+a),10h jr z,_assign_on_2 ld hl,assign_ch ld a,(hl+a) cp a,(dsp_channel) jr nz,_assign_on_2 ld hl,assign_note ld a,e ld a,(hl+a) cp a,(dsp_data_1st) jr z,_assign_on_3 _assign_on_2: inc e cp e,10h jr z,_assign_on_next jr _assign_on_1 _assign_on_3: call @_dsp_off_rhythm ; DSP-01 Trigger ld hl,assign_ctr ld a,e ld b,(hl+a) ld d,0 _assign_on_4: ld a,d ld a,(hl+a) cp a,b jr z,_assign_on_5 jr nc,_assign_on_6 ld a,d inc (hl+a) jr _assign_on_6 _assign_on_5: ld a,e ld (hl+a),0 _assign_on_6: inc d cp d,10h jr nz,_assign_on_4 jp @_dsp_on_send ; DSP-01 Trigger _assign_on_next: ld e,(on_pointer) ; Assign Channel ld b,e inc (on_pointer) and (on_pointer),00001111b ld hl,assign_ctr _assign_on_7: ld a,e cp (hl+a),10h jr z,_assign_on_8 inc e and e,00001111b ld a,e cp a,b jr nz,_assign_on_7 jr _assign_on_kill _assign_on_8: ld a,0 _assign_on_9: cp (hl+a),10h jr z,_assign_on_10 inc (hl+a) _assign_on_10: inc a cp a,10h jr nz,_assign_on_9 _assign_set_ok: ld a,e ld (hl+a),0 ld hl,assign_ch ld b,(dsp_channel) ld (hl+a),b ld hl,assign_note ld b,(dsp_data_1st) ld (hl+a),b jp @_dsp_on_send ; DSP-01 Trigger _assign_on_kill: ld e,0 ; Assign Channel ld hl,assign_ctr _assign_on_11: ld a,e cp (hl+a),0fh jr z,_assign_on_12 inc e cp e,10h jr nz,_assign_on_11 ret _assign_on_12: call @_dsp_off_rhythm ; DSP-01 Trigger ld hl,assign_ctr ld a,0 _assign_on_13: inc (hl+a) inc a cp a,10h jr nz,_assign_on_13 jr _assign_set_ok dsp_cont_change: cp (dsp_data_1st),7 jr z,_dsp_cont_vol cp (dsp_data_1st),64 jr z,_dsp_cont_damp cp (dsp_data_1st),67 jr z,_dsp_cont_soft ret _dsp_cont_soft: ld hl,pedals ld a,(dsp_channel) bit 6,(dsp_data_2nd) jr z,_soft_off set pedal_soft,(hl+a) ret _soft_off: res pedal_soft,(hl+a) ret _dsp_cont_vol: ld hl,volume ld a,(dsp_channel) ld b,(dsp_data_2nd) scf rl b ld (hl+a),b ret _dsp_cont_damp: ld hl,pedals ld a,(dsp_channel) bit 6,(dsp_data_2nd) jr z,_damper_off set pedal_damper,(hl+a) ret _damper_off: res pedal_damper,(hl+a) ld e,0 ; Assign Channel _damper_off_1: ld hl,assign_ctr ld a,e cp (hl+a),10h jr nz,_damper_off_2 ld hl,assign_ch ld a,(hl+a) cp a,(dsp_channel) jr nz,_damper_off_2 ld hl,assign_note ld a,e ld a,(hl+a) ld (dsp_data_1st),a ld (dsp_data_2nd),0 call @_dsp_off_send ; DSP-01 Trigger _damper_off_2: inc e cp e,10h jr nz,_damper_off_1 ret dsp_prog_change: ld hl,assign_pc ld a,(dsp_channel) ld (hl+a),b ld l,b mul hl,10 ; Parameter Counts add hl,tone_data_bank ld a,(hl) ld b,a and a,00001100b srla srla add a,2 ld c,a ld a,b and a,00110000b slla slla or a,c ld c,a ld hl,dsp_vib_spd ld a,(dsp_channel) ld (hl+a),c ret dsp_pitch_bend: ld hl,bender ld a,(dsp_channel) ld (hl+a),b ld e,0 _bend_chk: ld hl,assign_ch ld a,e ld a,(hl+a) cp a,(dsp_channel) jr nz,_bend_next ld (ch_buff),a ld hl,assign_note ld a,e ld b,(hl+a) call @_dsp_on_pitch ; ### Common Subroutine ### _bend_next: inc e cp e,10h jr nz,_bend_chk ret ;========== All Note Off ======== @_dsp-01_all_off: %dsp-01_16ch(0c0h,0f0h) ; Decay Level %dsp-01_16ch(0d0h,007h) ; Decay Speed %dsp-01_16ch(090h,0) ; Control Word ld a,0 ld hl,assign_ctr _all_off_loop: ld (hl+a),10h inc a cp a,10h jr nz,_all_off_loop ret ;========== Vibrate Routine ======== @_dsp-01_vibrate: inc (vib_timer) cp (vib_timer),3 ; Speed Parameter ret nz ld (vib_timer),0 ld (loop_counter),0 _dsp_vib_loop: ld e,(loop_counter) ; [E] = MIDI Channel ld a,e ld hl,dsp_vib_flg ld (hl+a),0 ld hl,dsp_vib_spd ld c,(hl+a) ld b,c and b,00111111b ld hl,dsp_vib_ctr inc (hl+a) ld a,(hl+a) cp a,b jr c,_dsp_vib_next ld a,e ld (hl+a),0 ld hl,dsp_vib_add inc (hl+a) ld a,(hl+a) and a,00011111b ld hl,_dsp_vib_table and c,11000000b srl c ld b,0 add hl,bc ld c,(hl+a) ld a,e ld hl,dsp_vib_dat ld (hl+a),c ld hl,dsp_vib_flg inc (hl+a) _dsp_vib_next: inc (loop_counter) cp (loop_counter),10h jr nz,_dsp_vib_loop ld (loop_counter),0 _vib_chk: ld e,(loop_counter) ; [E] = DSP-01 Channel ld hl,assign_ch ld a,e ld a,(hl+a) ld hl,dsp_vib_flg cp (hl+a),0 jr z,_vib_next ld (ch_buff),a ld hl,assign_note ld a,e ld b,(hl+a) call @_dsp_on_pitch ; ### Common Subroutine ### _vib_next: inc (loop_counter) cp (loop_counter),10h jr nz,_vib_chk ret _dsp_vib_table: db 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 db 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 ; Depth = [00] db 8,8,8,9,9,9,9,9,10,9,9,9,9,9,8,8 db 8,8,8,7,7,7,7,7,6,7,7,7,7,7,8,8 ; Depth = [01] db 8,9,10,10,11,11,11,12,12,12,11,11,11,10,10,9 db 8,7,6,6,5,5,5,4,4,4,5,5,5,6,6,7 ; Depth = [10] db 8,9,10,11,12,13,13,14,14,14,13,13,12,11,10,9 db 8,7,6,5,4,3,3,2,2,2,3,3,4,5,6,7 ; Depth = [11] ;========== Pitch Setting Subroutines ====================== shift_set: ldw (work+6),0b000h %shift(0be80h,0ae80h,09e80h) %shift(0bd00h,0ad00h,09d00h) %shift(0bb80h,0ab80h,09b80h) %shift(0ba00h,0aa00h,09a00h) %shift(0b880h,0a880h,09880h) %shift(0b700h,0a700h,09700h) %shift(0b580h,0a580h,09580h) %shift(0b400h,0a400h,09400h) %shift(0b280h,0a280h,09280h) %shift(0b100h,0a100h,09100h) ret _shift_sub: ld hl,(work+0) ld de,(work+2) ld bc,(work+4) _shift_loop: dec hl dec de dec bc srl (hl) rr (de) rr (bc) cp hl,(work+6) jr nz,_shift_loop ret all_range: %range(0bfffh,0be7fh) %range(0afffh,0ae7fh) %range(09fffh,09e7fh) ret bend_compute: ld (work+0),0 _bend_set_loop: ld (work+1),090h ld (work+2),0a0h ld (work+3),0b0h call _bend_sub ; Each Bend Set inc (work+0) cp (work+0),12 jr nz,_bend_set_loop ret _bend_sub: ld a,(work+0) ld hl,_low_offset_2 ld c,(hl+a) ld hl,_high_offset_1 ld b,(hl+a) ld a,(work+1) or a,b ld b,a ld a,(bc) ld (work+5),a ld a,(work+0) ld hl,_low_offset_2 ld c,(hl+a) ld hl,_high_offset_1 ld b,(hl+a) ld a,(work+2) or a,b ld b,a ld a,(bc) ld (work+6),a ld a,(work+0) ld hl,_low_offset_2 ld c,(hl+a) ld hl,_high_offset_1 ld b,(hl+a) ld a,(work+3) or a,b ld b,a ld a,(bc) ld (work+7),a ; Normal Pitch Data Get ! ld (work+4),0 ; Bend Depth : 0-31 _bend_sub_loop: call _bend_sub_sub inc (work+4) cp (work+4),32 jr nz,_bend_sub_loop ret _bend_sub_sub: %move_3byte(calc+0,work+5) ld l,(work+4) ; Bend Depth mul hl,3 ld bc,_bend_table add hl,bc ld a,(hl) ld (calc+5),a inc hl ld a,(hl) ld (calc+4),a inc hl ld a,(hl) ld (calc+3),a ; Bend Multi. Data Set ! call @_24_24_to_48 ; BIOS call @_48_shift_24 ; BIOS ld a,(work+0) ld hl,_low_offset_3 ld c,(hl+a) ld hl,_high_offset_1 ld b,(hl+a) ld a,(work+1) or a,b ld b,a ld l,(work+4) ; Bend Depth ld h,0 add hl,bc ld a,(calc+0) ld (hl),a ld a,(work+0) ld hl,_low_offset_3 ld c,(hl+a) ld hl,_high_offset_1 ld b,(hl+a) ld a,(work+2) or a,b ld b,a ld l,(work+4) ; Bend Depth ld h,0 add hl,bc ld a,(calc+1) ld (hl),a ld a,(work+0) ld hl,_low_offset_3 ld c,(hl+a) ld hl,_high_offset_1 ld b,(hl+a) ld a,(work+3) or a,b ld b,a ld l,(work+4) ; Bend Depth ld h,0 add hl,bc ld a,(calc+2) ld (hl),a ; Pitch Data Set ! ret temp_compute: ld (work+0),0 ; Check Note [C-B] ld (work+4),0 ; Temp. Offset Bias ld (work+5),0 ; Temp Select NO. call _temp_select _temp_set_loop: ld (work+1),090h ld (work+2),0a0h ld (work+3),0b0h call _temp_sub ; Each Temp. Set inc (work+0) cp (work+0),12 jr nz,_temp_set_loop ret _temp_select: ld hl,_temp_sel_tb ld a,(work+5) ld c,(hl+a) bit 7,c jr nz,_temp_sel_cont ld (work+5),c ret _temp_sel_cont: ld b,c and b,11110000b ; 80=Pytha/C0=Mean/E0=Q*/F0=T* and c,00001111b ; Shift Data cp b,80h jr z,_temp_sel_80 cp b,0c0h jr z,_temp_sel_c0 cp b,0e0h jr z,_temp_sel_e0 ld (work+5),22 ; Pure [T-*] Temp. jr _temp_sel_next _temp_sel_80: ld (work+5),1 ; Pythagorean Temp. jr _temp_sel_next _temp_sel_c0: ld (work+5),2 ; Meantone Temp. jr _temp_sel_next _temp_sel_e0: ld (work+5),21 ; Pure [Q-*] Temp. _temp_sel_next: ld a,(work+4) ; Temp Bias add a,c cp a,12 jr c,_temp_sel_exit sub a,12 _temp_sel_exit: ld (work+4),a ret _temp_sub: ld a,(work+0) ld hl,_low_offset_2 ld c,(hl+a) ld hl,_high_offset_1 ld b,(hl+a) ld a,(work+1) or a,b ld b,a ld a,(bc) ld (calc+0),a ld a,(work+0) ld hl,_low_offset_2 ld c,(hl+a) ld hl,_high_offset_1 ld b,(hl+a) ld a,(work+2) or a,b ld b,a ld a,(bc) ld (calc+1),a ld a,(work+0) ld hl,_low_offset_2 ld c,(hl+a) ld hl,_high_offset_1 ld b,(hl+a) ld a,(work+3) or a,b ld b,a ld a,(bc) ld (calc+2),a ; Current Pitch Data Get ! ld hl,_temp_offset ld a,(work+0) ; My Note ld c,(hl+a) ld b,0 add hl,bc ld a,(work+4) ; Temp Offset Bias ld c,(hl+a) ld l,3 mul hl,c ld bc,hl ; Temp Data Note Offset ld l,(work+5) ; Temp Select NO. mul hl,36 ld de,hl ; Temp Select Offset ld hl,_temp_table add hl,bc add hl,de ld a,(hl) ld (calc+5),a inc hl ld a,(hl) ld (calc+4),a inc hl ld a,(hl) ld (calc+3),a ; Temp Multi. Data Set ! call @_24_24_to_48 ; BIOS call @_48_cut_to_24 ; BIOS ld a,(work+0) ld hl,_low_offset_2 ld c,(hl+a) ld hl,_high_offset_1 ld b,(hl+a) ld a,(work+1) or a,b ld b,a ld a,(calc+0) ld (bc),a ld a,(work+0) ld hl,_low_offset_2 ld c,(hl+a) ld hl,_high_offset_1 ld b,(hl+a) ld a,(work+2) or a,b ld b,a ld a,(calc+1) ld (bc),a ld a,(work+0) ld hl,_low_offset_2 ld c,(hl+a) ld hl,_high_offset_1 ld b,(hl+a) ld a,(work+3) or a,b ld b,a ld a,(calc+2) ld (bc),a ; Pitch Data Set ! ret note_devide: ld (work+0),1 _note_dev_loop: ld (work+1),090h ld (work+2),0a0h ld (work+3),0b0h call _note_sub ; Each Notes Set inc (work+0) cp (work+0),12 jr nz,_note_dev_loop ret _note_sub: ld hl,_low_offset_1 ld c,(hl) ld hl,_high_offset_1 ld b,(hl) ld a,(work+1) or a,b ld b,a ld a,(bc) ld (calc+0),a ld hl,_low_offset_1 ld c,(hl) ld hl,_high_offset_1 ld b,(hl) ld a,(work+2) or a,b ld b,a ld a,(bc) ld (calc+1),a ld hl,_low_offset_1 ld c,(hl) ld hl,_high_offset_1 ld b,(hl) ld a,(work+3) or a,b ld b,a ld a,(bc) ld (calc+2),a ; Standard Pitch Data Get ! %move_3byte(calc+3,_dev_data) ld (work+4),0 _note_sub_loop: call @_24_24_to_48 ; BIOS call @_48_cut_to_24 ; BIOS inc (work+4) ld a,(work+4) cp a,(work+0) jr nz,_note_sub_loop ld a,(work+0) ld hl,_low_offset_1 ld c,(hl+a) ld hl,_high_offset_1 ld b,(hl+a) ld a,(work+1) or a,b ld b,a ld a,(calc+0) ld (bc),a ld a,(work+0) ld hl,_low_offset_1 ld c,(hl+a) ld hl,_high_offset_1 ld b,(hl+a) ld a,(work+2) or a,b ld b,a ld a,(calc+1) ld (bc),a ld a,(work+0) ld hl,_low_offset_1 ld c,(hl+a) ld hl,_high_offset_1 ld b,(hl+a) ld a,(work+3) or a,b ld b,a ld a,(calc+2) ld (bc),a ; Pitch Data Set ! ret pitch_shift: ld (work+0),020h ld (work+1),090h ld (work+2),0a0h ld (work+3),0b0h call _pitch_sub ; [G 9] Set ret _pitch_sub: ld a,(work+0) and a,00111111b ld l,3 mul hl,a ld bc,_hz_set_table add hl,bc ld a,(hl) ld (calc+2),a inc hl ld a,(hl) ld (calc+1),a inc hl ld a,(hl) ld (calc+0),a %move_3byte(calc+3,_g9_data) call @_24_24_to_48 ; BIOS call @_48_cut_to_24 ; BIOS ld hl,_low_offset_1 ld c,(hl) ld hl,_high_offset_1 ld b,(hl) ld a,(work+1) or a,b ld b,a ld a,(calc+0) ld (bc),a ld hl,_low_offset_1 ld c,(hl) ld hl,_high_offset_1 ld b,(hl) ld a,(work+2) or a,b ld b,a ld a,(calc+1) ld (bc),a ld hl,_low_offset_1 ld c,(hl) ld hl,_high_offset_1 ld b,(hl) ld a,(work+3) or a,b ld b,a ld a,(calc+2) ld (bc),a ; [G9] Pitch Data Set ! ret _low_offset_3: db 00h,20h,40h,60h,80h,0a0h,0c0h,0e0h,80h,0a0h,0c0h,0e0h _low_offset_2: db 10h,30h,50h,70h,90h,0b0h,0d0h,0f0h,90h,0b0h,0d0h,0f0h _high_offset_1: db 0fh,0fh,0fh,0fh,0fh,0fh,0fh,0fh,0eh,0eh,0eh,0eh _low_offset_1: db 0f0h,0d0h,0b0h,90h,70h,50h,30h,10h,0f0h,0d0h,0b0h,90h _temp_sel_tb: db 0,0 _temp_offset: db 11,10,9,8,7,6,5,4,3,2,1,0,11,10,9,8,7,6,5,4,3,2,1 _g9_data: db 0bch,084h,0cdh _dev_data: db 0bfh,0a1h,0f1h _hz_set_table: db 076h,0B0h,0DFh,076h,0FBh,058h,077h,045h,0D1h,077h,090h,04Ah ; 408-411(Hz) db 077h,0DAh,0C3h,078h,025h,03Ch,078h,06Fh,0B5h,078h,0BAh,02Eh ; 412-415 db 079h,004h,0A7h,079h,04Fh,020h,079h,099h,099h,079h,0E4h,012h ; 416-419 db 07Ah,02Eh,08Bh,07Ah,079h,004h,07Ah,0C3h,07Dh,07Bh,00Dh,0F6h ; 420-423 db 07Bh,058h,06Fh,07Bh,0A2h,0E8h,07Bh,0EDh,061h,07Ch,037h,0DAh ; 424-427 db 07Ch,082h,053h,07Ch,0CCh,0CCh,07Dh,017h,045h,07Dh,061h,0BEh ; 428-431 db 07Dh,0ACh,037h,07Dh,0F6h,0B0h,07Eh,041h,029h,07Eh,08Bh,0A2h ; 432-435 db 07Eh,0D6h,01Bh,07Fh,020h,094h,07Fh,06Bh,00Dh,07Fh,0B5h,086h ; 436-439 db 080h,000h,000h,080h,04Ah,079h,080h,094h,0F2h,080h,0DFh,06Bh ; 440-443 db 081h,029h,0E4h,081h,074h,05Dh,081h,0BEh,0D6h,082h,009h,04Fh ; 444-447 db 082h,053h,0C8h,082h,09Eh,041h,082h,0E8h,0BAh,083h,033h,033h ; 448-451 db 083h,07Dh,0ACh,083h,0C8h,025h,084h,012h,09Eh,084h,05Dh,017h ; 452-455 db 084h,0A7h,090h,084h,0F2h,009h,085h,03Ch,082h,085h,086h,0FBh ; 456-459 db 085h,0D1h,074h,086h,01Bh,0EDh,086h,066h,066h,086h,0B0h,0DFh ; 460-463 db 086h,0FBh,058h,087h,045h,0D1h,087h,090h,04Ah,087h,0DAh,0C3h ; 464-467 db 088h,025h,03Ch,088h,06Fh,0B5h,088h,0BAh,02Eh,089h,004h,0A7h ; 468-471 _bend_table: db 07Ch,05Bh,028h,07Ch,094h,0ACh,07Ch,0CEh,04Bh,07Dh,008h,005h ; -16/-13 db 07Dh,041h,0D9h,07Dh,07Bh,0C8h,07Dh,0B5h,0D2h,07Dh,0EFh,0F6h ; -12/-9 db 07Eh,02Ah,036h,07Eh,064h,090h,07Eh,09Fh,006h,07Eh,0D9h,096h ; -8/-5 db 07Fh,014h,042h,07Fh,04Fh,008h,07Fh,089h,0EAh,07Fh,0C4h,0E7h ; -4/-1 db 080h,000h,000h,080h,03Bh,033h,080h,076h,082h,080h,0B1h,0EDh ; 0/+3 db 080h,0EDh,073h,081h,029h,014h,081h,064h,0D1h,081h,0A0h,0AAh ; +4/+7 db 081h,0DCh,09Fh,082h,018h,0AFh,082h,054h,0DBh,082h,091h,022h ; +8/+11 db 082h,0CDh,086h,083h,00Ah,006h,083h,046h,0A1h,083h,083h,059h ; +12/+15 _temp_table: ;*** Temp [0] 12-Equal db 080h,000h,000h,080h,000h,000h,080h,000h,000h,080h,000h,000h db 080h,000h,000h,080h,000h,000h,080h,000h,000h,080h,000h,000h db 080h,000h,000h,080h,000h,000h,080h,000h,000h,080h,000h,000h ;========== Initial Settings ============================= ;<< Initial Tone Data Setting >> init_tone_set: call pitch_shift ; [G9] 408Hz-471Hz Standard Pitch call note_devide ; Other 11-Notes Devide call temp_compute ; Temperaments Computing call bend_compute ; Bend [-16/+15] Computing call all_range ; All Range Data Only Copy call shift_set ; Each Range Data Shift ld ix,0 ld iy,0 ld bc,128*10 ld hl,default_tone ld de,tone_data_bank ldir ld (work),0 _tone_loop_1: ld hl,init_tone_table ld a,(work) ld b,(hl+a) ld hl,assign_pc ld (hl+a),b ld (dsp_channel),a call dsp_prog_change inc (work) cp (work),16 jr nz,_tone_loop_1 ret init_tone_table: db 0,68,48,95,78,41,3,110,122,0 ; 0-8 db 70,34,7,11,62,89 ; 10-15 ;========== Defaule Tone Data Area ======================== default_tone: db 001h,000h,047h,047h,0C0h,06Fh,00Fh,000h,0C8h,099h db 001h,048h,08Fh,08Fh,0C0h,07Fh,00Fh,000h,0BBh,099h db 001h,0B0h,0EFh,0EFh,0C2h,07Fh,00Fh,000h,0A8h,098h db 001h,090h,0AFh,0AFh,0C0h,064h,02Fh,000h,0C9h,098h db 001h,0AFh,0AFh,0AFh,0C0h,07Fh,018h,000h,0C8h,098h db 001h,0B0h,0CFh,0CFh,0C0h,064h,00Fh,000h,0CAh,098h db 009h,0CFh,0CFh,0CFh,0C0h,07Fh,018h,000h,0CAh,098h db 001h,0E8h,0FEh,0FEh,0C0h,073h,00Fh,000h,0CFh,088h db 001h,000h,000h,000h,0C5h,052h,03Fh,000h,0FFh,04Fh db 001h,001h,001h,001h,0C5h,052h,03Fh,000h,0FFh,04Fh db 001h,002h,002h,002h,0C5h,064h,03Fh,000h,0FFh,04Fh db 001h,003h,003h,003h,0C5h,064h,03Fh,000h,0FFh,04Fh db 001h,004h,004h,004h,0C5h,038h,068h,038h,08Ah,098h db 001h,005h,005h,005h,0C5h,04Fh,07Ah,04Fh,08Ah,098h db 001h,006h,006h,006h,0C5h,04Fh,07Ah,048h,08Ah,098h db 015h,028h,03Fh,03Fh,0C1h,054h,06Fh,05Ah,0AAh,065h db 001h,000h,01Fh,01Fh,0C2h,07Fh,00Fh,000h,0CFh,088h db 00Dh,01Fh,01Fh,01Fh,0C2h,07Fh,00Fh,000h,0B8h,088h db 000h,01Dh,01Dh,01Dh,0C5h,07Fh,00Fh,000h,0B8h,088h db 000h,01Fh,01Fh,01Fh,0C5h,07Fh,00Fh,000h,0BFh,068h db 000h,018h,018h,018h,0C5h,07Fh,00Fh,000h,0BFh,06Bh db 004h,01Bh,01Bh,01Bh,0C5h,07Fh,00Fh,000h,0A8h,066h db 000h,02Dh,02Dh,02Dh,0C5h,055h,00Fh,000h,0A8h,098h db 01Ch,02Eh,02Eh,02Eh,0C5h,055h,00Fh,000h,0A8h,098h db 01Ch,030h,03Fh,03Fh,0C3h,05Fh,04Fh,03Fh,0AAh,088h db 01Dh,0A8h,0BFh,0BFh,0C4h,048h,00Fh,05Ah,088h,088h db 01Dh,0C0h,0C0h,0D7h,0C3h,06Fh,03Fh,000h,0F8h,088h db 01Dh,088h,088h,0A7h,0C3h,055h,04Fh,000h,0F8h,088h db 002h,090h,09Fh,09Fh,0C5h,07Fh,018h,038h,0CFh,088h db 001h,03Fh,03Fh,03Fh,0C3h,06Fh,008h,000h,0DAh,078h db 001h,09Fh,09Fh,09Fh,0C5h,07Fh,00Fh,000h,0C8h,078h db 000h,01Ah,01Ah,01Ah,0C5h,064h,01Fh,000h,0C8h,08Fh db 01Ah,040h,057h,057h,0C1h,07Fh,068h,048h,0A9h,098h db 01Dh,058h,06Fh,06Fh,0C1h,064h,088h,03Fh,0EEh,098h db 01Eh,070h,070h,09Fh,0C4h,078h,06Fh,048h,0ADh,098h db 07Dh,060h,067h,067h,0C3h,058h,06Fh,000h,0DDh,0A8h db 0B9h,070h,070h,0AFh,0C2h,04Fh,06Fh,048h,0DFh,0AFh db 01Ch,025h,025h,025h,0C5h,05Fh,03Fh,000h,0B8h,0A8h db 018h,015h,015h,015h,0C5h,06Fh,018h,000h,0B8h,0A8h db 018h,007h,007h,007h,0C5h,064h,058h,03Eh,0ADh,09Fh db 0DDh,008h,008h,008h,0C5h,06Fh,02Fh,000h,0BFh,0BFh db 07Ch,009h,009h,009h,0C5h,064h,018h,000h,0C8h,0A8h db 05Ch,00Ah,00Ah,00Ah,0C5h,048h,048h,038h,0DDh,08Ch db 054h,00Bh,00Bh,00Bh,0C5h,04Fh,048h,048h,0A8h,0A8h db 01Dh,0A8h,0BFh,0BFh,0C4h,04Fh,05Fh,058h,0A8h,09Fh db 019h,000h,000h,000h,0C5h,028h,018h,04Fh,088h,08Dh db 085h,014h,014h,014h,0C5h,07Fh,02Fh,000h,0A9h,0A9h db 01Ch,00Ch,00Ch,00Ch,0C5h,044h,018h,038h,0C8h,078h db 001h,070h,070h,0AFh,0C2h,048h,018h,04Fh,0BFh,0AFh db 01Dh,0B0h,0CFh,0CFh,0C1h,06Fh,048h,000h,0CFh,0AFh db 01Dh,0CFh,0CFh,0CFh,0C1h,064h,078h,038h,0CFh,0AFh db 000h,040h,04Fh,04Fh,0C3h,05Fh,02Fh,000h,088h,088h db 019h,010h,01Fh,01Fh,0C4h,05Fh,058h,048h,0B8h,088h db 01Ch,021h,021h,021h,0C5h,058h,078h,048h,0B8h,088h db 01Dh,0A0h,0A7h,0A7h,0C4h,07Fh,078h,038h,099h,088h db 018h,022h,022h,022h,0C5h,064h,09Fh,048h,099h,088h db 001h,040h,04Fh,04Fh,0C3h,054h,048h,000h,0DFh,088h db 018h,025h,025h,025h,0C5h,058h,018h,000h,0B8h,0AAh db 000h,025h,025h,025h,0C5h,06Fh,02Eh,000h,0ACh,0ACh db 008h,00Dh,00Dh,00Dh,0C5h,064h,01Fh,000h,0B8h,088h db 008h,00Eh,00Eh,00Eh,0C5h,05Fh,00Fh,000h,0B8h,088h db 001h,0D0h,0E7h,0E7h,0C0h,06Fh,018h,000h,0DFh,088h db 008h,019h,019h,019h,0C5h,06Fh,01Fh,000h,0D8h,088h db 055h,078h,08Fh,08Fh,0C5h,06Fh,04Fh,000h,0C8h,098h db 001h,000h,00Fh,00Fh,0C3h,06Fh,00Fh,000h,0C8h,088h db 001h,00Fh,00Fh,00Fh,0C3h,074h,01Fh,000h,0C8h,088h db 001h,010h,01Fh,01Fh,0C3h,06Fh,00Fh,000h,0D8h,088h db 059h,010h,01Fh,01Fh,0C3h,07Fh,03Eh,000h,098h,088h db 001h,020h,02Fh,02Fh,0C3h,074h,01Fh,000h,0C8h,088h db 01Dh,024h,02Fh,02Fh,0C3h,07Fh,00Fh,000h,0BCh,078h db 01Ch,028h,028h,028h,0C5h,074h,04Fh,000h,0DCh,068h db 01Ch,029h,029h,029h,0C5h,074h,04Fh,000h,0DCh,068h db 019h,0D8h,0E7h,0E7h,0C3h,04Fh,044h,058h,0A8h,088h db 01Ch,02Ch,02Ch,02Ch,0C5h,064h,07Fh,048h,088h,088h db 019h,0D8h,0E7h,0E7h,0C3h,064h,048h,038h,02Fh,08Fh db 01Dh,0E7h,0E7h,0E7h,0C3h,064h,038h,028h,098h,078h db 008h,00Fh,00Fh,00Fh,0C5h,054h,07Fh,03Fh,099h,078h db 01Dh,068h,087h,087h,0C3h,072h,07Fh,04Fh,0E8h,088h db 01Dh,080h,097h,097h,0C1h,07Fh,038h,058h,0C8h,088h db 00Dh,097h,097h,097h,0C1h,07Fh,048h,048h,0A8h,078h db 00Dh,098h,0AFh,0AFh,0C1h,07Fh,018h,048h,0BFh,088h db 019h,0ACh,0ACh,0ACh,0C1h,07Fh,03Fh,048h,0A8h,08Ch db 018h,010h,010h,010h,0C5h,064h,08Fh,02Eh,0AAh,088h db 018h,00Ch,00Ch,00Ch,0C5h,048h,088h,02Eh,0A8h,09Fh db 01Ch,00Ah,00Ah,00Ah,0C5h,07Fh,068h,04Fh,098h,08Fh db 01Dh,0A8h,0BFh,0BFh,0C3h,064h,00Fh,028h,0CCh,088h db 019h,00Ah,00Ah,00Ah,0C5h,07Fh,07Fh,048h,058h,078h db 019h,01Ah,01Ah,01Ah,0C5h,064h,06Fh,03Eh,0ADh,078h db 019h,0E8h,0FEh,0FEh,0C3h,064h,00Fh,048h,0AFh,088h db 01Ch,023h,023h,023h,0C5h,04Fh,038h,048h,0AFh,088h db 005h,020h,02Fh,02Fh,0C4h,064h,038h,04Fh,09Fh,08Dh db 01Ch,024h,024h,024h,0C5h,06Fh,068h,048h,078h,08Fh db 001h,030h,047h,047h,0C5h,064h,00Fh,04Fh,098h,088h db 01Dh,047h,047h,047h,0C5h,064h,078h,038h,0BCh,09Fh db 009h,030h,03Fh,03Fh,0C4h,06Fh,028h,000h,0D8h,088h db 00Dh,040h,057h,057h,0C4h,064h,00Fh,000h,0E8h,088h db 01Dh,058h,06Fh,06Fh,0C4h,064h,06Fh,000h,0D8h,088h db 000h,012h,012h,012h,0C5h,06Fh,01Eh,000h,0A8h,0A8h db 014h,013h,013h,013h,0C5h,05Fh,00Fh,000h,0A5h,099h db 001h,048h,05Fh,05Fh,0C5h,07Fh,00Fh,000h,09Fh,09Fh db 000h,014h,014h,014h,0C5h,07Fh,01Fh,000h,0AAh,0AAh db 048h,026h,026h,026h,0C5h,06Fh,01Ah,000h,0AFh,0AFh db 040h,015h,015h,015h,0C5h,064h,038h,000h,0BEh,0BEh db 011h,018h,027h,027h,0C1h,064h,01Fh,000h,0ADh,098h db 001h,000h,017h,017h,0C1h,05Fh,00Fh,000h,0BDh,098h db 005h,0E0h,0EFh,0EFh,0C4h,07Fh,00Fh,000h,098h,098h db 05Ah,0F0h,0FEh,0FEh,0C4h,07Fh,00Fh,000h,0AFh,0AFh db 009h,0C4h,0DFh,0DFh,0C4h,064h,038h,05Ah,09Ah,088h db 018h,02Ah,02Ah,02Ah,0C5h,04Fh,07Fh,038h,08Fh,09Ch db 058h,010h,010h,010h,0C5h,02Fh,08Fh,038h,098h,09Ch db 019h,050h,067h,067h,0C3h,064h,00Fh,048h,078h,088h db 016h,060h,077h,077h,0C5h,064h,07Fh,000h,0A8h,088h db 001h,0C0h,0E7h,0E7h,0C5h,07Fh,00Fh,000h,0B8h,098h db 001h,0E8h,0F7h,0F7h,0C5h,07Fh,00Fh,000h,088h,088h db 001h,0A0h,0BFh,0BFh,0C5h,07Fh,00Fh,000h,0BBh,0BBh db 002h,050h,05Fh,05Fh,0C2h,07Fh,00Fh,000h,0CFh,098h db 001h,060h,06Fh,06Fh,0C2h,07Fh,00Fh,000h,0C8h,098h db 042h,070h,07Fh,07Fh,0C1h,07Fh,00Fh,000h,0C8h,0A8h db 002h,000h,00Fh,00Fh,0C4h,07Fh,00Fh,000h,0DDh,0DDh db 002h,090h,0AAh,0BAh,0C6h,07Fh,00Fh,000h,0DDh,0A8h db 002h,048h,04Fh,04Fh,0C2h,07Fh,00Fh,000h,0B8h,0A9h db 041h,020h,047h,047h,0C2h,07Fh,03Fh,05Fh,0A8h,099h db 002h,0D0h,0FEh,0FEh,0C1h,07Fh,00Fh,000h,0CFh,0A8h db 029h,052h,058h,058h,080h,064h,00Fh,000h,0D8h,088h db 029h,042h,04Ch,04Ch,080h,064h,00Fh,000h,0D8h,088h db 019h,000h,000h,000h,080h,058h,038h,000h,0D8h,088h db 01Dh,052h,05Fh,05Fh,080h,064h,00Fh,000h,0B8h,088h db 0D9h,050h,057h,057h,080h,064h,018h,000h,0D8h,088h ;<< NO.[ 6 ] 1msec Timer Interrupt Sequence >> @_int_1msec_seq: bit int_bit_tim_1,(int_flg) ret z res int_bit_tim_1,(int_flg) bit 0,(led_timer+0) ; Odd/Even ? jr z,_int_1msec_even ld (port_treg3),187 ; 1msec Interval Constant(1) jr _int_1msec_cont _int_1msec_even: ld (port_treg3),188 ; 1msec Interval Constant(2) _int_1msec_cont: inc (led_timer+0) cp (led_timer+0),5 ; 5msec Interval ? ret c ld (led_timer+0),0 ld c,(port_adreg) ld b,0 ld hl,(ad_sum) add hl,bc ld (ad_sum),hl ld (port_admod),11111000b ; A/D Start ! inc (led_timer+1) cp (led_timer+1),20 ; 20 Times ? ret c ld (led_timer+1),0 ld hl,(ad_sum) ldw (ad_sum),0 div hl,20 zzz: cp l,0a0h ; Trigger Level ! jr c,_ad_eve ld (ad_flg),0 ret _ad_eve: cp (ad_flg),0 ret nz ld (ad_flg),1 bit 0,(active_status) jr z,_on_0 bit 1,(active_status) jr z,_on_1 bit 2,(active_status) jr z,_on_2 bit 3,(active_status) jr z,_on_3 ret _on_0: set real_play,(run_mode) set 0,(active_status) ld (play_data_1+0),0 ld (play_counter+0),0 ldw (pointer_1),sequence_data ret _on_1: set real_play,(run_mode) set 1,(active_status) ld (play_data_1+1),0 ld (play_counter+1),0 ldw (pointer_2),sequence_data ret _on_2: set real_play,(run_mode) set 2,(active_status) ld (play_data_1+2),0 ld (play_counter+2),0 ldw (pointer_3),sequence_data ret _on_3: set real_play,(run_mode) set 3,(active_status) ld (play_data_1+3),0 ld (play_counter+3),0 ldw (pointer_4),sequence_data ret %include(pre-1.hex) ; <--- Song Data !!! end