Skip to content

Commit

Permalink
Adding code to switch to OPL3 mode.
Browse files Browse the repository at this point in the history
More SD Card code for FAT12.
  • Loading branch information
dtremblay committed Apr 21, 2020
1 parent 1c49f98 commit dddcd3a
Show file tree
Hide file tree
Showing 10 changed files with 411 additions and 100 deletions.
2 changes: 2 additions & 0 deletions OPL2_Library.asm
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ OPL2_INIT
STA RAD_ADDR + 2
setas
;LDA $2F
;STA OPL3_R_CONN_SEL
LDA #1
STA OPL3_R_OPL3_MODE
RTL
Expand Down
74 changes: 37 additions & 37 deletions OPL3_def.asm
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
; Direct Access to Right Channel
; R = Right
OPL3_R_BASE = $AFE600
OPL3_R_BASE_LL = $E600
OPL3_R_BASE_HL = $00AF
OPL3_R_TEST = $AFE601 ; TEST
OPL3_R_TIMER1 = $AFE602 ; TIMER-1
OPL3_R_TIMER2 = $AFE603 ; TIMER-2
OPL3_R_IRQ = $AFE604 ;
OPL3_R_OPL3_MODE = $AFE605 ; Set bit 0 to 1 if you want to use in OPL3 Mode
OPL3_R_CSM = $AFE608 ;
OPL3_R_AM_VID_EG_KSR_MULT = $AFE620 ; $40..$35 (21 Registers)
OPL3_R_KSL_TL = $AFE640; $40..$55 (21 Registers)
OPL3_R_AR_DR = $AFE660; $60..$75 (21 Registers)
OPL3_R_SL_RR = $AFE680; $80..$95 (21 Registers)
OPL3_R_FNumber = $AFE6A0; $A0..$A8
OPL3_R_KON_BLOCK_FNumber = $AFE6B0; $B0..$B9
OPL3_R_DPTH_RHYTM = $AFE6BD; $BD
OPL3_R_FEEDBACK = $AFE6C0; $C0..$C9
OPL3_R_WAVE_SELECT = $AFE6E0; $E0..$F5
; R = Right => A1 =H
OPL3_R_BASE = $AFE700
; delete OPL3_R_BASE_LL = $E600
; delete OPL3_R_BASE_HL = $00AF
OPL3_R_TEST = $AFE701 ; TEST
OPL3_R_CONN_SEL = $AFE704 ; six bits for 4 op channels
OPL3_R_OPL3_MODE = $AFE705 ; Set bit 0 to 1 if you want to use in OPL3 Mode
; delete OPL3_R_CSM = $AFE608 ;
OPL3_R_AM_VID_EG_KSR_MULT = $AFE720 ; $40..$35 (21 Registers)
OPL3_R_KSL_TL = $AFE740; $40..$55 (21 Registers)
OPL3_R_AR_DR = $AFE760; $60..$75 (21 Registers)
OPL3_R_SL_RR = $AFE780; $80..$95 (21 Registers)
OPL3_R_FNumber = $AFE7A0; $A0..$A8
OPL3_R_KON_BLOCK_FNumber = $AFE7B0; $B0..$B9
OPL3_R_DPTH_RHYTM = $AFE7BD; $BD
OPL3_R_FEEDBACK = $AFE7C0; $C0..$C9
OPL3_R_WAVE_SELECT = $AFE7E0; $E0..$F5

; Direct Access to Left Channel
; L = Left
OPL3_L_BASE = $AFE700
OPL3_L_BASE_LL = $E700
OPL3_L_BASE_HL = $00AF
OPL3_L_TEST = $AFE701 ; TEST
OPL3_L_TIMER1 = $AFE702 ; TIMER-1
OPL3_L_TIMER2 = $AFE703 ; TIMER-2
OPL3_L_IRQ = $AFE704 ;
OPL3_L_CSM = $AFE708 ;
OPL3_L_AM_VID_EG_KSR_MULT = $AFE720 ; $40..$35 (21 Registers)
OPL3_L_KSL_TL = $AFE740; $40..$55 (21 Registers)
OPL3_L_AR_DR = $AFE760; $60..$75 (21 Registers)
OPL3_L_SL_RR = $AFE780; $80..$95 (21 Registers)
OPL3_L_FNumber = $AFE7A0; $A0..$A8
OPL3_L_KON_BLOCK_FNumber = $AFE7B0; $B0..$B9
OPL3_L_DPTH_RHYTM = $AFE7BD; $BD
OPL3_L_FEEDBACK = $AFE7C0; $C0..$C9
OPL3_L_WAVE_SELECT = $AFE7E0; $E0..$F5
; L = Left => A1 = L
OPL3_L_TIMER1 = $AFE602 ; TIMER-1
OPL3_L_TIMER2 = $AFE603 ; TIMER-2
OPL3_L_IRQ = $AFE604 ;
.comment OPL3_L_BASE = $AFE700
;OPL3_L_BASE_LL = $E700
;OPL3_L_BASE_HL = $00AF
OPL3_L_TEST = $AFE701 ; TEST
OPL3_L_CSM = $AFE708 ;
OPL3_L_AM_VID_EG_KSR_MULT = $AFE720 ; $40..$35 (21 Registers)
OPL3_L_KSL_TL = $AFE740; $40..$55 (21 Registers)
OPL3_L_AR_DR = $AFE760; $60..$75 (21 Registers)
OPL3_L_SL_RR = $AFE780; $80..$95 (21 Registers)
OPL3_L_FNumber = $AFE7A0; $A0..$A8
OPL3_L_KON_BLOCK_FNumber = $AFE7B0; $B0..$B9
OPL3_L_DPTH_RHYTM = $AFE7BD; $BD
OPL3_L_FEEDBACK = $AFE7C0; $C0..$C9
OPL3_L_WAVE_SELECT = $AFE7E0; $E0..$F5
.endc

TREMOLO = $80
VIBRATO = $40
Expand Down
90 changes: 71 additions & 19 deletions Rad_Player.asm
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,15 @@ RAD_INIT_PLAYER
LDY #$0010
LDA [OPL2_ADDY_PTR_LO],Y
CMP #$10 ; BCD version 1.0 or 2.1
BNE LOAD_VERSION_21
BNE RI_LOAD_VERSION_21
JSL READ_VERSION_10
RTL ; End of RAD_INIT_PLAYER

LOAD_VERSION_21
RI_LOAD_VERSION_21
CMP #$21
BNE RI_INVALID
JSL READ_VERSION_21
RI_INVALID
RTL ; End of RAD_INIT_PLAYER

; ************************************************************************************************
Expand All @@ -63,24 +66,19 @@ READ_VERSION_21
;not implemented
LDA #2
STA @lTuneInfo.version
JSR READ_TIMER
JSR PARSER_RAD_FILE_INSTRUMENT_21; Parse the Instrument
RTL ; End of READ_VERSION_21

; ************************************************************************************************
; Read a RAD file version 1.1
; The timer setting is at offset $11 for both 1.0 and 2.1 RAD Formats
; ************************************************************************************************
READ_VERSION_10
.as
LDA #1
STA @lTuneInfo.version
JSR PARSER_RAD_FILE_INSTRUMENT_10; Go Parse the Instrument and Order list
JSR PROCESS_ORDER_LIST_10
JSR READ_PATTERNS_10
READ_TIMER
LDY #$11
LDA [OPL2_ADDY_PTR_LO],Y
BIT #$40
BEQ NORMAL_TIMER
BEQ RT_NOT_SLOW
LDA #1
STA @lTuneInfo.hasSlowTimer
Expand All @@ -95,7 +93,18 @@ READ_VERSION_10
STA TIMER0_CMP_H
BRA SET_TIMER

NORMAL_TIMER
RT_NOT_SLOW
BIT #$20
BEQ RT_NOT_BPM
INY
setal
LDA [OPL2_ADDY_PTR_LO],Y
setas
INY
BRA SET_TIMER
RT_NOT_BPM
LDA #0
STA @lTuneInfo.hasSlowTimer
Expand All @@ -109,12 +118,28 @@ READ_VERSION_10
STA TIMER0_CMP_H
SET_TIMER
JSR INIT_TIMER0
RTS

; ************************************************************************************************
; Read a RAD file version 1.1
; ************************************************************************************************
READ_VERSION_10
.as
LDA #1
STA @lTuneInfo.version
JSR PARSER_RAD_FILE_INSTRUMENT_10; Parse the Instrument
JSR PROCESS_ORDER_LIST_10 ; Parse the Order List
JSR READ_PATTERNS_10
JSR READ_TIMER
RTL ; End of READ_VERSION_10

ADLIB_OFFSETS .byte 7,1,8,2,9,3,10,4,5,11,6

; ************************************************************************************************
; Read the instrument table
; Read the instrument table.
; RAD V1.0 Format
; ************************************************************************************************
PARSER_RAD_FILE_INSTRUMENT_10
INY ; $11 bit 7: description, bit6: slow timer, bits4..0: speed
Expand All @@ -140,10 +165,10 @@ PARSER_RAD_FILE_INSTRUMENT_10
STA RAD_ADDR + 2
; Let's Read Some Instruments HERE
ProcessNextInstruments
ProcessNextInstruments_10
setas
LDA [OPL2_ADDY_PTR_LO],Y ; Read Instrument Number
BEQ DoneProcessingInstrument;
BEQ DoneProcessingInstrument_10
setal
; find the address of the instrument by multiplying by the record length
Expand Down Expand Up @@ -190,13 +215,40 @@ PARSER_RAD_FILE_INSTRUMENT_10
BNE BLANK_INSTR_DESCR
PLY
BRA ProcessNextInstruments;
BRA ProcessNextInstruments_10
DoneProcessingInstrument
DoneProcessingInstrument_10
INY
RTS

; ************************************************************************************************
; Read the instrument table.
; RAD V2.1 Format
; ************************************************************************************************
PARSER_RAD_FILE_INSTRUMENT_21
PR_LOOP
; skip the description
LDA [OPL2_ADDY_PTR_LO],Y
INY
CMP #0
BNE PR_LOOP
; Let's Init the Address Point for the instrument Tables
LDA #<`INSTRUMENT_ACCORDN
STA RAD_ADDR + 2
; Let's Read Some Instruments HERE
ProcessNextInstruments_21
setas
LDA [OPL2_ADDY_PTR_LO],Y ; Read Instrument Number
BEQ DoneProcessingInstrument_21
; TODO _ CONTINUE HERE
DoneProcessingInstrument_21
INY
RTS
; ************************************************************************************************
; * Read the orders list
; ************************************************************************************************
PROCESS_ORDER_LIST_10
Expand Down
Loading

0 comments on commit dddcd3a

Please sign in to comment.