Subversion Repositories svn.mios

Compare Revisions

Ignore whitespace Rev 1212 → Rev 1213

/playground/Antichambre/midibox_tia/setup_tia_cartridge.lst
New file
0,0 → 1,17375
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 1
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00001 ; $Id: setup_tia_base.asm bdupeyron.tech@gmail.com(Antichambre)
00002 LIST R=DEC
00003 ;
00004 ; Prepared Setup File for TIA Cartridge version
00005 ;
00006
00007 ;; here you can change the default device ID - if you are using
00008 ;; some cores as slave, set:
00009 ;; o DEFAULT_DEVICE_ID 0x01 ; for the first slave
00010 ;; o DEFAULT_DEVICE_ID 0x02 ; for the second slave
00011 ;; o DEFAULT_DEVICE_ID 0x03 ; for the third slave
0000 00012 #define DEFAULT_DEVICE_ID 0x00
00013
00014 ;; if this option is enabled (1), the DEFAULT_DEVICE_ID won't be used, but
00015 ;; it will be automatically derived from the MIOS Device ID instead
0000 00016 #define AUTO_DEVICE_ID 0
00017
00018 ;; default MIDI channel:
0000 00019 #define DEFAULT_MIDI_CHANNEL 1
00020
00021 ;; if != 0, special variations for cartridge version hardware:
0000 00022 #define DEFAULT_IS_CARTRIDGE 1
00023
00024 ;; Kit and Wavetable fisrt:
00025 ;; position, banks start at this bankstick address(id):
00026 ;; Becarrefull! Change this value may reformat your BankStick
00027 ;; look at DEFAULT_BS_FPROTECT Value *!
0000 00028 #define DEFAULT_BS_KBANK_ID 5
00029 ;; Default BankStick format protection:
00030 ;; 0: No protection.
00031 ;; *1: Protects banks which are not good type or position.
00032 ;; Depend on DEFAULT_BS_KBANK_ID.
00033 ;; 2: Never format at startup.
0000 00034 #define DEFAULT_BS_FPROTECT 1
00035 ;; BankStick read only:
0000 00036 #define DEFAULT_BS_READONLY 0
00037
00038 ;; Default EEPROM Protection:
00039 ;; Eeprom read only:
0000 00040 #define DEFAULT_EE_READONLY 1
00041 ;; internal patch Protection
00042
00043 ;; Adjustable Gate fade out option:
00044 ;; to avoid click when envelope is off or envelope release is null.
00045 ;; Uses USER_Timer period N * 819 (us), default N=2 (1.638ms).
0000 00046 #define DEFAULT_TIA_GATE_FADEOUT 2
00047
00048 ;; use PORTA and PORTE (J5 of the core module) as output
00049 ;; you can address these pins in cs_menu_io_tables.inc as "shift register" #0
0000 00050 #define ENABLE_J5 0
00051
0000 00052 #define TIA_LEDMTR_ENABLE 1
00053 ;; define the shift registers (note: HERE the shift register begin with 0: 1st SR is 0, 2nd is 1, 3rd is 2, ...)
0000 00054 #define TIA_LEDMTR_REG 0 ; shift register for led metering (HERE: first shift register in the chain)
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 2
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00055
00056 ;; For MIDI activity monitor:
0000 00057 #define DEFAULT_MIDI_MONITOR_ENABLED 1 ; if 1, the Tx/Rx LEDs are enabled
00058 ;;define the DOUT pins for the Rx and Tx LED:
00059 ;; if 0: MIDI Rx/Tx LEDs are assigned to the DOUT chain, pin 0x00-0x7f
00060 ;; if 1: MIDI Rx/Tx LEDs are assigned to specials pins
0000 00061 #define MIDI_RXTX_USE_IO 1
00062 #if MIDI_RXTX_USE_IO
0000 00063 #define DEFAULT_MIDI_RX_LAT LATD
0000 00064 #define DEFAULT_MIDI_RX_TRIS TRISD
0000 00065 #define DEFAULT_MIDI_RX_PIN 6 ; Pin D.6
0000 00066 #define DEFAULT_MIDI_TX_LAT LATD
0000 00067 #define DEFAULT_MIDI_TX_TRIS TRISD
0000 00068 #define DEFAULT_MIDI_TX_PIN 7 ; Pin D.7
00069 #else
00070 #define DEFAULT_MIDI_RX_LED 0x41 ; DOUT SR#9, pin D1
00071 #define DEFAULT_MIDI_TX_LED 0x42 ; DOUT SR#9, pin D2
00072 #endif
00073
00074 ;; define the AOUT interface which is used here:
00075 ;; 1: one MBHP_AOUT module
00076 ;; 2: up to 4 (chained) MBHP_AOUT_LC modules
00077 ;; 3: one MBHP_AOUT_NG module
00078 ;; all other values invalid!
0000 00079 #define AOUT_INTERFACE_TYPE 0
00080
00081 ;; only relevant if one or more AOUT_LC modules are used:
00082 ;; define the resolution configuration here
00083 ;; 0: first channel 12bit, second channel 4bit
00084 ;; 1: first channel 8bit, second channel 8bit
00085 ;; 2: combines M1,M2 and/or M3/M4: first channel 12bit, second channel 12bit, third channel 8bit, fourth channel ignored!
00086 ;; all other values invalid!
0000 00087 #define AOUT_LC_RESOLUTION_OPTION_M1 0
0000 00088 #define AOUT_LC_RESOLUTION_OPTION_M2 0
0000 00089 #define AOUT_LC_RESOLUTION_OPTION_M3 0
0000 00090 #define AOUT_LC_RESOLUTION_OPTION_M4 0
00091
00092 ;; enable the 6th LFO waveform (analog inputs)
0000 00093 #define ENABLE_AIN_LFO_WAVEFORM 0
00094
00095 #include "src/main.inc"
00001 ; $Id: main.inc bdupeyron.tech@gmail.com(Antichambre)
00002 ;
00003 ; MIOS Application
00004 ; MIDIbox TIA
00005 ;
00006 ; -> see README.txt for details
00007 ;
00008 ; ==========================================================================
00009 ;
00010 ; Copyright 1998-2006 Thorsten Klose (tk@midibox.org)
00011 ; Licensed for personal non-commercial use only.
00012 ; All other rights reserved.
00013 ;
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 3
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00014 ; ==========================================================================
00015 ;
00016 ; Version: <-------------------->
0000 00017 #define MBTIA_VERSION_STR "MIDIboxTIA V1.beta "
00018 ; (fixed string length - 20 characters!)
00019 ;
00020
00021 ;; ---[ MIOS header file ]---
00022 #include <mios.h>
00001 ; $Id: mios.h 822 2009-09-17 18:39:53Z tk $
00002 ;
00003 ; MIOS Definitions file
00004 ;
00005 ; ==========================================================================
00006 ;
00007 ; Copyright 1998-2008 Thorsten Klose (tk@midibox.org)
00008 ; Licensed for personal non-commercial use only.
00009 ; All other rights reserved.
00010 ;
00011 ; ==========================================================================
00012
00013
00014 ;; ==========================================================================
00015 ;; Include basic defines which characterize the derivative to
00016 ;; simplify dependencies within MIOS source code
00017 ;; ==========================================================================
00018 #include <hw_flags.h>
00001
00002 #ifndef _HW_FLAGS_H
0000 00003 #define _HW_FLAGS_H
00004
00005 #ifdef __18F452
00006 #define PIC_DERIVATIVE_CODE_SIZE 0x08000
00007 #define PIC_DERIVATIVE_RAM_SIZE 0x600
00008 #define PIC_DERIVATIVE_EEPROM_SIZE 0x100
00009 #define PIC_DERIVATIVE_IRQ_WORKAROUND 0
00010 #define PIC_DERIVATIVE_NEW_ADC 0
00011 #define PIC_DERIVATIVE_CMCON_INIT 0
00012 #define PIC_DERIVATIVE_T08BIT_INVERTED 0
00013 #define PIC_DERIVATIVE_SET_LCD_4BIT 0
00014 #endif
00015
00016 #ifdef __18F4620
00017 #define PIC_DERIVATIVE_CODE_SIZE 0x10000
00018 #define PIC_DERIVATIVE_RAM_SIZE 0xf80
00019 #define PIC_DERIVATIVE_EEPROM_SIZE 0x400
00020 #define PIC_DERIVATIVE_IRQ_WORKAROUND 1
00021 #define PIC_DERIVATIVE_NEW_ADC 1
00022 #define PIC_DERIVATIVE_CMCON_INIT 1
00023 #define PIC_DERIVATIVE_T08BIT_INVERTED 1
00024 #define PIC_DERIVATIVE_SET_LCD_4BIT 0
00025 #endif
00026
00027 #ifdef __18F4520
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 4
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00028 #define PIC_DERIVATIVE_CODE_SIZE 0x08000
00029 #define PIC_DERIVATIVE_RAM_SIZE 0x600
00030 #define PIC_DERIVATIVE_EEPROM_SIZE 0x100
00031 #define PIC_DERIVATIVE_IRQ_WORKAROUND 1
00032 #define PIC_DERIVATIVE_NEW_ADC 1
00033 #define PIC_DERIVATIVE_CMCON_INIT 1
00034 #define PIC_DERIVATIVE_T08BIT_INVERTED 0
00035 #define PIC_DERIVATIVE_SET_LCD_4BIT 0
00036 #endif
00037
00038 #ifdef __18F4682
00039 #define PIC_DERIVATIVE_CODE_SIZE 0x14000
00040 #define PIC_DERIVATIVE_RAM_SIZE 0xd00
00041 #define PIC_DERIVATIVE_EEPROM_SIZE 0x400
00042 #define PIC_DERIVATIVE_IRQ_WORKAROUND 0
00043 #define PIC_DERIVATIVE_NEW_ADC 1
00044 #define PIC_DERIVATIVE_CMCON_INIT 1
00045 #define PIC_DERIVATIVE_T08BIT_INVERTED 0
00046 #define PIC_DERIVATIVE_SET_LCD_4BIT 1
00047 #endif
00048
00049 #ifdef __18F4685
0000 00050 #define PIC_DERIVATIVE_CODE_SIZE 0x18000
0000 00051 #define PIC_DERIVATIVE_RAM_SIZE 0xd00
0000 00052 #define PIC_DERIVATIVE_EEPROM_SIZE 0x400
0000 00053 #define PIC_DERIVATIVE_IRQ_WORKAROUND 0
0000 00054 #define PIC_DERIVATIVE_NEW_ADC 1
0000 00055 #define PIC_DERIVATIVE_CMCON_INIT 1
0000 00056 #define PIC_DERIVATIVE_T08BIT_INVERTED 0
0000 00057 #define PIC_DERIVATIVE_SET_LCD_4BIT 1
00058 #endif
00059
00060 #endif
00019
00020 ;; ==========================================================================
00021 ;; Assembler directives & device specific include file
00022 ;;
00023 ;; Natively supported devices are listed here.
00024 ;; ==========================================================================
00025
00026 #ifdef __18F452
00027 LIST R=DEC
00028 #include <p18f452.inc>
00029 #endif
00030
00031 #ifdef __18F4620
00032 LIST R=DEC
00033 #include <p18f4620.inc>
00034 #endif
00035
00036 #ifdef __18F4520
00037 LIST R=DEC
00038 #include <p18f4520.inc>
00039 #endif
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 5
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00040
00041 #ifdef __18F4682
00042 LIST R=DEC
00043 #include <p18f4682.inc>
00044 #endif
00045
00046 #ifdef __18F4685
00047 LIST R=DEC
00048 #include <p18f4685.inc>
00001 LIST
00002
00003 ;==========================================================================
00004 ; MPASM PIC18F4685 processor include
00005 ;
00006 ; (c) Copyright 1999-2007 Microchip Technology, All rights reserved
00007 ;==========================================================================
00008
04822 LIST
00049 #endif
00050
00051
00052 ;; ==========================================================================
00053 ;; General constants
00054 ;; ==========================================================================
00055
00056 ;; used by MIOS_MIDI_Interface*
00000000 00057 MIOS_MIDI_INTERFACE_COMMON EQU 0x00
00000001 00058 MIOS_MIDI_INTERFACE_TO_HOST EQU 0x01
00059
00060 ;; used by MIOS_MIDI_Merger*
00000000 00061 MIOS_MIDI_MERGER_DISABLED EQU 0x00
00000001 00062 MIOS_MIDI_MERGER_ENABLED EQU 0x01
00000002 00063 MIOS_MIDI_MERGER_MBLINK_EP EQU 0x02
00000003 00064 MIOS_MIDI_MERGER_MBLINK_FP EQU 0x03
00065
00066 ;; used by MIOS_ENC_PIN_TABLE
00067 #ifdef MIOS_OLD_ENCODER_MODES
00068 MIOS_ENC_MODE_NON_DETENTED EQU 0x00
00069 MIOS_ENC_MODE_DETENTED EQU 0x80
00070 MIOS_ENC_MODE_DETENTED1 EQU 0x80
00071 MIOS_ENC_MODE_DETENTED2 EQU 0x81
00072 MIOS_ENC_MODE_DETENTED3 EQU 0x82
00073 #else
00074 ;; new encoder modes: each bit of MIOS_ENC_MODE_xx tells, if an INC / DEC is
00075 ;; being triggered on the corresponding edge.
00076 ;; Bit 7 6 5 4
00077 ;; DEC <- <- <- <-
00078 ;; Pin A ___|-------|_______
00079 ;; Pin B _______|-------|___
00080 ;; INC -> -> -> ->
00081 ;; Bit 0 1 2 3
00082 ;; Ex.: Bit 76543210
00083 ;; DETENTED2 = 0b00100010 = 0x22
00084 ;; -> INC will be triggered on edge 1, DEC on edge 5
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 6
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
000000FF 00085 MIOS_ENC_MODE_NON_DETENTED EQU 0xff
000000AA 00086 MIOS_ENC_MODE_DETENTED EQU 0xaa
000000AA 00087 MIOS_ENC_MODE_DETENTED1 EQU 0xaa
00000022 00088 MIOS_ENC_MODE_DETENTED2 EQU 0x22
00000088 00089 MIOS_ENC_MODE_DETENTED3 EQU 0x88
000000A5 00090 MIOS_ENC_MODE_DETENTED4 EQU 0xa5
0000005A 00091 MIOS_ENC_MODE_DETENTED5 EQU 0x5a
00092 #endif
00093
00094 ;; used by MIOS_ENC_Speed*
00000000 00095 MIOS_ENC_SPEED_SLOW EQU 0
00000001 00096 MIOS_ENC_SPEED_NORMAL EQU 1
00000002 00097 MIOS_ENC_SPEED_FAST EQU 2
00098
00099 ;; used by MIOS_LCD_Type*
00000000 00100 MIOS_LCD_TYPE_CLCD EQU 0x00
00000001 00101 MIOS_LCD_TYPE_GLCD0 EQU 0x01
00000002 00102 MIOS_LCD_TYPE_GLCD1 EQU 0x02
00000003 00103 MIOS_LCD_TYPE_GLCD2 EQU 0x03
00000004 00104 MIOS_LCD_TYPE_GLCD3 EQU 0x04
00000005 00105 MIOS_LCD_TYPE_GLCD4 EQU 0x05
00000006 00106 MIOS_LCD_TYPE_MLCD EQU 0x06
00000007 00107 MIOS_LCD_TYPE_GLCD_CUSTOM EQU 0x07
00108
00109 ;; location of default 5x8 font for graphical displays
00007CFC 00110 MIOS_GLCD_FONT EQU 0x7cfc
00111
00112 ;; general config flags (never overwrite this flags directly!!!)
00000000 00113 MIOS_BOX_CFG0_LCD_TYPE0 EQU 0 ; selects LCD type, bit 0
00000001 00114 MIOS_BOX_CFG0_LCD_TYPE1 EQU 1 ; selects LCD type, bit 1
00000002 00115 MIOS_BOX_CFG0_LCD_TYPE2 EQU 2 ; selects LCD type, bit 2
00000003 00116 MIOS_BOX_CFG0_USE_GLCD EQU 3 ; if 1, graphical LCD is connected
00000004 00117 MIOS_BOX_CFG0_MERGER EQU 4 ; if 1, MIDI merger is enabled
00000005 00118 MIOS_BOX_CFG0_MBLINK EQU 5 ; if 1, MIDIbox Link is enabled
00000006 00119 MIOS_BOX_CFG0_TO_HOST EQU 6 ; if 1, MIDI interface will run with 38400 baud instead of 31250
00000007 00120 MIOS_BOX_CFG0_20MHz EQU 7 ; if 1, it is assumed that box is running with 20 MHz, else with 40 MHz
00121
00000000 00122 MIOS_BOX_CFG1_BS_A0 EQU 0 ; A0 of BankStick (never change the bit position)
00000001 00123 MIOS_BOX_CFG1_BS_A1 EQU 1 ; A1 of BankStick (never change the bit position)
00000002 00124 MIOS_BOX_CFG1_BS_A2 EQU 2 ; A2 of BankStick (never change the bit position)
00000003 00125 MIOS_BOX_CFG1_BS_DIS_VERIFY EQU 3 ; if 1, writes to the BankStick will not be verified
00000004 00126 MIOS_BOX_CFG1_IIC_STRETCH_CLK EQU 4 ; if 1, IIC clock stretching enabled
00127
00128 ;; general status flags (never overwrite this flags directly!!!)
00000000 00129 MIOS_BOX_STAT_BS_AVAILABLE EQU 0 ; if 1, BankStick is available
00000001 00130 MIOS_BOX_STAT_MBLINK_TUNNEL_PASS EQU 1 ; if 1, a MBLinked event will be tunnled
00000002 00131 MIOS_BOX_STAT_SUSPEND_ALL EQU 2 ; if 1, all system and user tasks are suspended
00000003 00132 MIOS_BOX_STAT_SUSPEND_USER EQU 3 ; if 1, all user tasks are suspended
00000004 00133 MIOS_BOX_STAT_AUTOREPEAT EQU 4 ; if 1, start the auto-repeat handler
00000005 00134 MIOS_BOX_STAT_MLCD_TRANSFER EQU 5 ; if 1, a transfer to the MLCD has been started
00000006 00135 MIOS_BOX_STAT_FERR EQU 6 ; if 1, a frame error happened during MIDI receive
00136
00137 ;; ==========================================================================
00138 ;; MIOS Special Function Registers
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 7
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00139 ;; ==========================================================================
00140
00000000 00141 MIOS_BOX_CFG0 EQU 0x000
00000001 00142 MIOS_BOX_CFG1 EQU 0x001
00000002 00143 MIOS_BOX_STAT EQU 0x002
00000003 00144 MIOS_PARAMETER1 EQU 0x003
00000004 00145 MIOS_PARAMETER2 EQU 0x004
00000005 00146 MIOS_PARAMETER3 EQU 0x005
00147
00148 ;; ==========================================================================
00149 ;; temporary registers for main programs
00150 ;; ==========================================================================
00000006 00151 TMP1 EQU 0x006
00000007 00152 TMP2 EQU 0x007
00000008 00153 TMP3 EQU 0x008
00000009 00154 TMP4 EQU 0x009
0000000A 00155 TMP5 EQU 0x00a
00156
00157 ;; ==========================================================================
00158 ;; temporary registers for IRQs
00159 ;; ==========================================================================
0000000B 00160 IRQ_TMP1 EQU 0x00b
0000000C 00161 IRQ_TMP2 EQU 0x00c
0000000D 00162 IRQ_TMP3 EQU 0x00d
0000000E 00163 IRQ_TMP4 EQU 0x00e
0000000F 00164 IRQ_TMP5 EQU 0x00f
00165
00166 ;; ==========================================================================
00167 ;; free memory space for user application:
00168 ;; ==========================================================================
00169 ;; 0x010-0x37f
00170
00171 ;; ==========================================================================
00172 ;; MIOS System Registers -- not defined here --
00173 ;; never use these memory locations!
00174 ;; ==========================================================================
00175 ;; 0x380-0x6ff
00176
00177 ;; ==========================================================================
00178 ;; MIOS System Registers for custom LCD driver
00179 ;; ==========================================================================
00000570 00180 MIOS_GLCD_BUFFER EQU 0x570 ; note: the buffer must be located at ...0-...7
00000578 00181 MIOS_LCD_OPTION1 EQU 0x578 ; contains the first LCD option given by MIOS_LCD_TypeSet
00000579 00182 MIOS_LCD_OPTION2 EQU 0x579 ; contains the second LCD option given by MIOS_LCD_TypeSet
0000057A 00183 MIOS_LCD_CURSOR_POS EQU 0x57a ; the current cursor pos of characters (GLCD: multiplied by width)
0000057B 00184 MIOS_GLCD_GCURSOR_X EQU 0x57b ; for GLCDs: the current X position of graphical cursor
0000057C 00185 MIOS_GLCD_GCURSOR_Y EQU 0x57c ; for GLCDs: the current Y position of graphical cursor
0000057D 00186 MIOS_GLCD_FONT_WIDTH EQU 0x57d ; for GLCDs: the fontwidth given by MIOS_GLCD_FontInit
0000057E 00187 MIOS_GLCD_FONT_HEIGHT EQU 0x57e ; for GLCDs: the fontheight given by MIOS_GLCD_FontInit
0000057F 00188 MIOS_GLCD_FONT_X0 EQU 0x57f ; for GLCDs: the first byte within a char entry
00000580 00189 MIOS_GLCD_FONT_OFFSET EQU 0x580 ; for GLCDs: the byte offset between the characters
00000581 00190 MIOS_GLCD_FONT_PTRL EQU 0x581 ; for GLCDs: pointer to the character table, low-byte
00000582 00191 MIOS_GLCD_FONT_PTRH EQU 0x582 ; for GLCDs: pointer to the character table, high-byte
00000583 00192 MIOS_LCD_TIMEOUT0 EQU 0x583 ; can be used for timeout loops
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 8
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00000584 00193 MIOS_LCD_TIMEOUT1 EQU 0x584 ; can be used for timeout loops
00000585 00194 MIOS_GLCD_TMP1 EQU 0x585 ; can be used as temporary buffer
00000586 00195 MIOS_GLCD_TMP2 EQU 0x586 ; can be used as temporary buffer
00000587 00196 MIOS_GLCD_TMP3 EQU 0x587 ; can be used as temporary buffer
00000588 00197 MIOS_GLCD_TMP4 EQU 0x588 ; can be used as temporary buffer
00000589 00198 MIOS_LCD_Y0_OFFSET EQU 0x589 ; Y0 offset of LCD
0000058A 00199 MIOS_LCD_Y1_OFFSET EQU 0x58a ; Y1 offset of LCD
0000058B 00200 MIOS_LCD_Y2_OFFSET EQU 0x58b ; Y2 offset of LCD
0000058C 00201 MIOS_LCD_Y3_OFFSET EQU 0x58c ; Y3 offset of LCD
0000058D 00202 MIOS_LCD_CURSOR_POS_REAL EQU 0x58d ; unmapped cursor position which has been set with MIOS_LCD_CursorSet
0000058E 00203 MIOS_GLCD_FONT_PTRU EQU 0x58e ; for GLCDs: pointer to the character table, upper-byte (>64k flash derivatives only)
00023
00024 ;; ---[ useful macros ]---
00025 #include <macros.h>
00001 ; $Id: macros.h 49 2008-01-30 21:47:31Z tk $
00002 ;
00003 ; Macro Definitions
00004 ;
00005 ; ==========================================================================
00006 ;
00007 ; Copyright 1998-2006 Thorsten Klose (tk@midibox.org)
00008 ; Licensed for personal non-commercial use only.
00009 ; All other rights reserved.
00010 ;
00011 ; ==========================================================================
00012
00013 BRA_IFSET MACRO reg, bit, reg_a, label
00014 btfsc reg, bit, reg_a
00015 bra label
00016 ENDM
00017
00018
00019 BRA_IFCLR MACRO reg, bit, reg_a, label
00020 btfss reg, bit, reg_a
00021 bra label
00022 ENDM
00023
00024 GOTO_IFSET MACRO reg, bit, reg_a, label
00025 btfsc reg, bit, reg_a
00026 goto label
00027 ENDM
00028
00029
00030 GOTO_IFCLR MACRO reg, bit, reg_a, label
00031 btfss reg, bit, reg_a
00032 goto label
00033 ENDM
00034
00035 CALL_IFSET MACRO reg, bit, reg_a, label
00036 btfsc reg, bit, reg_a
00037 call label
00038 ENDM
00039
00040
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 9
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00041 CALL_IFCLR MACRO reg, bit, reg_a, label
00042 btfss reg, bit, reg_a
00043 call label
00044 ENDM
00045
00046 RCALL_IFSET MACRO reg, bit, reg_a, label
00047 btfsc reg, bit, reg_a
00048 rcall label
00049 ENDM
00050
00051
00052 RCALL_IFCLR MACRO reg, bit, reg_a, label
00053 btfss reg, bit, reg_a
00054 rcall label
00055 ENDM
00056
00057 ;; ==========================================================================
00058
00059 IRQ_DISABLE MACRO
00060 bcf INTCON, GIE
00061 ENDM
00062
00063 IRQ_ENABLE MACRO
00064 bsf INTCON, GIE
00065 ENDM
00066
00067 ;; ==========================================================================
00068
00069 TABLE_ADDR_FULL MACRO addr
00070 movlw LOW(addr) ; store Lo Byte
00071 movwf TBLPTRL
00072 movlw HIGH(addr) ; store Hi Byte
00073 movwf TBLPTRH
00074 movlw UPPER(addr) ; store upper Byte
00075 movwf TBLPTRU
00076 ENDM
00077
00078 TABLE_ADDR MACRO addr
00079 movlw LOW(addr) ; store Lo Byte
00080 movwf TBLPTRL
00081 movlw HIGH(addr) ; store Hi Byte
00082 movwf TBLPTRH
00083 #if PIC_DERIVATIVE_CODE_SIZE > 0x10000
00084 movlw UPPER(addr) ; store Upper Byte
00085 movwf TBLPTRU
00086 #endif
00087 ENDM
00088
00089 TABLE_H MACRO addr
00090 movlw HIGH(addr) ; store Hi Byte
00091 movwf TBLPTRH
00092 ENDM
00093
00094 TABLE_L MACRO addr
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 10
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00095 movlw LOW(addr) ; store Lo Byte
00096 movwf TBLPTRL
00097 ENDM
00098
00099 TABLE_ADD_W MACRO
00100 addwf TBLPTRL, F
00101 movlw 0x00
00102 addwfc TBLPTRH, F
00103 #if PIC_DERIVATIVE_CODE_SIZE > 0x10000
00104 movlw 0x00
00105 addwfc TBLPTRU, F
00106 #endif
00107 ENDM
00108
00109 TABLE_ADDR_MUL_W MACRO addr, multiplicator
00110 mullw multiplicator
00111 movlw LOW(addr)
00112 addwf PRODL, W
00113 movwf TBLPTRL
00114 movlw HIGH(addr)
00115 addwfc PRODH, W
00116 movwf TBLPTRH
00117 #if PIC_DERIVATIVE_CODE_SIZE > 0x10000
00118 clrf TBLPTRU
00119 movlw UPPER(addr)
00120 addwfc TBLPTRU, F
00121 #endif
00122 ENDM
00123
00124 ;; ==========================================================================
00125
00126 JUMPTABLE_2BYTES MACRO max_value
00127 addlw -(max_value) ; ensure that jump index is not greater than (max_value-1)
00128 skpnc
00129 movlw -(max_value)
00130 addlw max_value
00131 call MIOS_HLP_GetIndex_2bytes
00132 ENDM
00133
00134 JUMPTABLE_2BYTES_UNSECURE MACRO
00135 call MIOS_HLP_GetIndex_2bytes
00136 ENDM
00137
00138 JUMPTABLE_4BYTES MACRO max_value
00139 addlw -(max_value) ; ensure that jump index is not greater than (max_value-1)
00140 skpnc
00141 return
00142 addlw (max_value)
00143 call MIOS_HLP_GetIndex_4bytes
00144 ENDM
00145
00146 JUMPTABLE_4BYTES_UNSECURE MACRO
00147 call MIOS_HLP_GetIndex_4bytes
00148 ENDM
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 11
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00149
00150 ;; ==========================================================================
00151
00152 TWOBYTE_ENTRY MACRO low_byte, high_byte
00153 dw (high_byte << 8) | (low_byte)
00154 ENDM
00155
00156 ;; ==========================================================================
00157
0000 00158 #define skpnz btfsc STATUS, Z
0000 00159 #define skpz btfss STATUS, Z
0000 00160 #define skpndc btfsc STATUS, DC
0000 00161 #define skpdc btfss STATUS, DC
0000 00162 #define skpnc btfsc STATUS, C
0000 00163 #define skpc btfss STATUS, C
0000 00164 #define clrc bcf STATUS, C
0000 00165 #define setc bsf STATUS, C
0000 00166 #define clrz bcf STATUS, Z
0000 00167 #define setz bsf STATUS, Z
0000 00168 #define rrf rrcf
0000 00169 #define rlf rlcf
00170
00171 rgoto MACRO label
00172 bra label
00173 ENDM
00174
00175 SET_BSR MACRO reg
00176 movlb HIGH(reg)
00177 ENDM
00178
00179 ;; ==========================================================================
00180
00181 FONT_ENTRY MACRO width, height, x0, char_offset
00182 dw ((height) << 8) | (width), ((char_offset) << 8) | (x0)
00183 ENDM
00184
00185 ;; ==========================================================================
00186
00187 STRING MACRO length, pos, str
00188 da ((length) << 8) | (pos), str
00189 ENDM
00190
00191 ;; ==========================================================================
00026
00027 ;; ---[ vectors to MIOS functions (never change!) ]---
00028 #include <mios_vectors.inc>
00001 ; $Id: mios_vectors.inc 49 2008-01-30 21:47:31Z tk $
00002
00002C00 00003 MIOS_MIDI_BeginStream EQU 0x2c00
00002C04 00004 MIOS_MIDI_DeviceIDAutoSet EQU 0x2c04
00002C08 00005 MIOS_MIDI_DeviceIDGet EQU 0x2c08
00002C0C 00006 MIOS_MIDI_DeviceIDSet EQU 0x2c0c
00002C10 00007 MIOS_MIDI_EndStream EQU 0x2c10
00002C14 00008 MIOS_MIDI_Init EQU 0x2c14
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 12
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00002C18 00009 MIOS_MIDI_InterfaceAutoSet EQU 0x2c18
00002C1C 00010 MIOS_MIDI_InterfaceGet EQU 0x2c1c
00002C20 00011 MIOS_MIDI_InterfaceSet EQU 0x2c20
00002C24 00012 MIOS_MIDI_MergerGet EQU 0x2c24
00002C28 00013 MIOS_MIDI_MergerSet EQU 0x2c28
00002C2C 00014 MIOS_MIDI_RxBufferFree EQU 0x2c2c
00002C30 00015 MIOS_MIDI_RxBufferGet EQU 0x2c30
00002C34 00016 MIOS_MIDI_RxBufferPut EQU 0x2c34
00002C38 00017 MIOS_MIDI_RxBufferUsed EQU 0x2c38
00002C3C 00018 MIOS_MIDI_TxBufferFlush EQU 0x2c3c
00002C40 00019 MIOS_MIDI_TxBufferFree EQU 0x2c40
00002C44 00020 MIOS_MIDI_TxBufferGet EQU 0x2c44
00002C48 00021 MIOS_MIDI_TxBufferPut EQU 0x2c48
00002C4C 00022 MIOS_MIDI_TxBufferUsed EQU 0x2c4c
00002C50 00023 MIOS_MPROC_MergerDisable EQU 0x2c50
00002C54 00024 MIOS_MPROC_MergerEnable EQU 0x2c54
00002C58 00025 MIOS_MPROC_MergerGet EQU 0x2c58
00002C5C 00026 MIOS_AIN_DeadbandGet EQU 0x2c5c
00002C60 00027 MIOS_AIN_DeadbandSet EQU 0x2c60
00002C64 00028 MIOS_AIN_Muxed EQU 0x2c64
00002C68 00029 MIOS_AIN_NumberGet EQU 0x2c68
00002C6C 00030 MIOS_AIN_NumberSet EQU 0x2c6c
00002C70 00031 MIOS_AIN_Pin7bitGet EQU 0x2c70
00002C74 00032 MIOS_AIN_PinGet EQU 0x2c74
00002C78 00033 MIOS_AIN_PinLSBGet EQU 0x2c78
00002C7C 00034 MIOS_AIN_PinMSBGet EQU 0x2c7c
00002C80 00035 MIOS_AIN_UnMuxed EQU 0x2c80
00002C84 00036 MIOS_MF_PWM_DutyCycleDownGet EQU 0x2c84
00002C88 00037 MIOS_MF_PWM_DutyCycleDownSet EQU 0x2c88
00002C8C 00038 MIOS_MF_PWM_DutyCycleUpGet EQU 0x2c8c
00002C90 00039 MIOS_MF_PWM_DutyCycleUpSet EQU 0x2c90
00002C94 00040 MIOS_MF_DeadbandGet EQU 0x2c94
00002C98 00041 MIOS_MF_DeadbandSet EQU 0x2c98
00002C9C 00042 MIOS_MF_Disable EQU 0x2c9c
00002CA0 00043 MIOS_MF_Enable EQU 0x2ca0
00002CA4 00044 MIOS_MF_FaderMove EQU 0x2ca4
00002CA8 00045 MIOS_MF_SuspendDisable EQU 0x2ca8
00002CAC 00046 MIOS_MF_SuspendEnable EQU 0x2cac
00002CB0 00047 MIOS_MF_SuspendGet EQU 0x2cb0
00002CB4 00048 MIOS_DIN_PinGet EQU 0x2cb4
00002CB8 00049 MIOS_DIN_SRGet EQU 0x2cb8
00002CBC 00050 MIOS_DOUT_PinGet EQU 0x2cbc
00002CC0 00051 MIOS_DOUT_PinSet EQU 0x2cc0
00002CC4 00052 MIOS_DOUT_PinSet0 EQU 0x2cc4
00002CC8 00053 MIOS_DOUT_PinSet1 EQU 0x2cc8
00002CCC 00054 MIOS_DOUT_SRGet EQU 0x2ccc
00002CD0 00055 MIOS_DOUT_SRSet EQU 0x2cd0
00002CD4 00056 MIOS_ENC_Abs7bitAdd EQU 0x2cd4
00002CD8 00057 MIOS_ENC_Abs7bitGet EQU 0x2cd8
00002CDC 00058 MIOS_ENC_Abs7bitSet EQU 0x2cdc
00002CE0 00059 MIOS_ENC_NumberGet EQU 0x2ce0
00002CE4 00060 MIOS_ENC_SpeedGet EQU 0x2ce4
00002CE8 00061 MIOS_ENC_SpeedSet EQU 0x2ce8
00002CEC 00062 MIOS_SRIO_NumberGet EQU 0x2cec
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 13
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00002CF0 00063 MIOS_SRIO_NumberSet EQU 0x2cf0
00002CF4 00064 MIOS_SRIO_TS_SensitivityGet EQU 0x2cf4
00002CF8 00065 MIOS_SRIO_TS_SensitivitySet EQU 0x2cf8
00002CFC 00066 MIOS_SRIO_UpdateFrqGet EQU 0x2cfc
00002D00 00067 MIOS_SRIO_UpdateFrqSet EQU 0x2d00
00002D04 00068 MIOS_LCD_Clear EQU 0x2d04
00002D08 00069 MIOS_LCD_Cmd EQU 0x2d08
00002D0C 00070 MIOS_LCD_CursorGet EQU 0x2d0c
00002D10 00071 MIOS_LCD_CursorSet EQU 0x2d10
00002D14 00072 MIOS_LCD_Data EQU 0x2d14
00002D18 00073 MIOS_LCD_Init EQU 0x2d18
00002D1C 00074 MIOS_LCD_PrintBCD1 EQU 0x2d1c
00002D20 00075 MIOS_LCD_PrintBCD2 EQU 0x2d20
00002D24 00076 MIOS_LCD_PrintBCD3 EQU 0x2d24
00002D28 00077 MIOS_LCD_PrintChar EQU 0x2d28
00002D2C 00078 MIOS_LCD_PrintHex1 EQU 0x2d2c
00002D30 00079 MIOS_LCD_PrintHex2 EQU 0x2d30
00002D34 00080 MIOS_LCD_PrintMessage EQU 0x2d34
00002D38 00081 MIOS_LCD_PrintPreconfString EQU 0x2d38
00002D3C 00082 MIOS_LCD_PrintString EQU 0x2d3c
00002D40 00083 MIOS_LCD_TypeAutoSet EQU 0x2d40
00002D44 00084 MIOS_LCD_TypeGet EQU 0x2d44
00002D48 00085 MIOS_LCD_TypeSet EQU 0x2d48
00002D4C 00086 MIOS_LCD_YAddressGet EQU 0x2d4c
00002D50 00087 MIOS_LCD_YAddressSet EQU 0x2d50
00002D54 00088 MIOS_GLCD_FontInit EQU 0x2d54
00002D58 00089 MIOS_GLCD_GCursorGet EQU 0x2d58
00002D5C 00090 MIOS_GLCD_GCursorSet EQU 0x2d5c
00002D60 00091 MIOS_EEPROM_Read EQU 0x2d60
00002D64 00092 MIOS_EEPROM_Write EQU 0x2d64
00002D68 00093 MIOS_FLASH_Read EQU 0x2d68
00002D6C 00094 MIOS_FLASH_Write EQU 0x2d6c
00002D70 00095 MIOS_BANKSTICK_Read EQU 0x2d70
00002D74 00096 MIOS_BANKSTICK_Write EQU 0x2d74
00002D78 00097 MIOS_TIMER_Init EQU 0x2d78
00002D7C 00098 MIOS_TIMER_Start EQU 0x2d7c
00002D80 00099 MIOS_TIMER_Stop EQU 0x2d80
00002D84 00100 MIOS_HLP_AddressFromTable EQU 0x2d84
00002D88 00101 MIOS_HLP_GetBitANDMask EQU 0x2d88
00002D8C 00102 MIOS_HLP_GetBitORMask EQU 0x2d8c
00002D90 00103 MIOS_HLP_GetIndex_2bytes EQU 0x2d90
00002D94 00104 MIOS_HLP_GetIndex_4bytes EQU 0x2d94
00002D98 00105 MIOS_HLP_IndirectJump EQU 0x2d98
00002D9C 00106 MIOS_Delay EQU 0x2d9c
00002DA0 00107 MIOS_GPCounterGet EQU 0x2da0
00002DA4 00108 MIOS_Reset EQU 0x2da4
00002DA8 00109 MIOS_SystemResume EQU 0x2da8
00002DAC 00110 MIOS_SystemSuspend EQU 0x2dac
00002DB0 00111 MIOS_UserResume EQU 0x2db0
00002DB4 00112 MIOS_UserSuspend EQU 0x2db4
00002DB8 00113 MIOS_HLP_16bitAddSaturate EQU 0x2db8
00002DBC 00114 MIOS_DIN_PinAutoRepeatEnable EQU 0x2dbc
00002DC0 00115 MIOS_DIN_PinAutoRepeatDisable EQU 0x2dc0
00002DC4 00116 MIOS_DIN_PinAutoRepeatGet EQU 0x2dc4
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 14
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00002DC8 00117 MIOS_CLCD_SpecialCharInit EQU 0x2dc8
00002DCC 00118 MIOS_CLCD_SpecialCharsInit EQU 0x2dcc
00002DD0 00119 MIOS_AIN_DynamicPrioSet EQU 0x2dd0
00002DD4 00120 MIOS_AIN_DynamicPrioGet EQU 0x2dd4
00002DD8 00121 MIOS_AIN_LastPinsGet EQU 0x2dd8
00002DDC 00122 MIOS_BANKSTICK_CtrlSet EQU 0x2ddc
00002DE0 00123 MIOS_BANKSTICK_CtrlGet EQU 0x2de0
00002DE4 00124 MIOS_BANKSTICK_WritePage EQU 0x2de4
00002DE8 00125 MIOS_HLP_Dec2BCD EQU 0x2de8
00002DEC 00126 MIOS_LCD_PrintBCD4 EQU 0x2dec
00002DF0 00127 MIOS_LCD_PrintBCD5 EQU 0x2df0
00002DF4 00128 MIOS_LCD_MessageStart EQU 0x2df4
00002DF8 00129 MIOS_LCD_MessageStop EQU 0x2df8
00002DFC 00130 MIOS_MF_PWM_PeriodGet EQU 0x2dfc
00002E00 00131 MIOS_MF_PWM_PeriodSet EQU 0x2e00
00002E04 00132 MIOS_IIC_Start EQU 0x2e04
00002E08 00133 MIOS_IIC_Stop EQU 0x2e08
00002E0C 00134 MIOS_IIC_ByteSend EQU 0x2e0c
00002E10 00135 MIOS_IIC_ByteReceive EQU 0x2e10
00002E14 00136 MIOS_IIC_AckSend EQU 0x2e14
00002E18 00137 MIOS_IIC_NakSend EQU 0x2e18
00002E1C 00138 MIOS_IIC_CtrlSet EQU 0x2e1c
00002E20 00139 MIOS_IIC_CtrlGet EQU 0x2e20
00002E24 00140 MIOS_SRIO_DebounceSet EQU 0x2e24
00002E28 00141 MIOS_SRIO_DebounceGet EQU 0x2e28
00002E2C 00142 MIOS_MF_TouchDetectionReset EQU 0x2e2c
00002E30 00143 MIOS_BANKSTICK_ReadPage EQU 0x2e30
00002E34 00144 MIOS_EEPROM_ReadPage EQU 0x2e34
00002E38 00145 MIOS_EEPROM_WritePage EQU 0x2e38
00002E3C 00146 MIOS_TIMER_ReInit EQU 0x2e3c
00002E40 00147 MIOS_RESERVED_144 EQU 0x2e40
00002E44 00148 MIOS_RESERVED_145 EQU 0x2e44
00002E48 00149 MIOS_RESERVED_146 EQU 0x2e48
00002E4C 00150 MIOS_RESERVED_147 EQU 0x2e4c
00002E50 00151 MIOS_RESERVED_148 EQU 0x2e50
00002E54 00152 MIOS_RESERVED_149 EQU 0x2e54
00002E58 00153 MIOS_RESERVED_150 EQU 0x2e58
00002E5C 00154 MIOS_RESERVED_151 EQU 0x2e5c
00002E60 00155 MIOS_RESERVED_152 EQU 0x2e60
00002E64 00156 MIOS_RESERVED_153 EQU 0x2e64
00002E68 00157 MIOS_RESERVED_154 EQU 0x2e68
00002E6C 00158 MIOS_RESERVED_155 EQU 0x2e6c
00002E70 00159 MIOS_RESERVED_156 EQU 0x2e70
00002E74 00160 MIOS_RESERVED_157 EQU 0x2e74
00002E78 00161 MIOS_RESERVED_158 EQU 0x2e78
00002E7C 00162 MIOS_RESERVED_159 EQU 0x2e7c
00002E80 00163 MIOS_RESERVED_160 EQU 0x2e80
00002E84 00164 MIOS_RESERVED_161 EQU 0x2e84
00002E88 00165 MIOS_RESERVED_162 EQU 0x2e88
00002E8C 00166 MIOS_RESERVED_163 EQU 0x2e8c
00002E90 00167 MIOS_RESERVED_164 EQU 0x2e90
00002E94 00168 MIOS_RESERVED_165 EQU 0x2e94
00002E98 00169 MIOS_RESERVED_166 EQU 0x2e98
00002E9C 00170 MIOS_RESERVED_167 EQU 0x2e9c
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 15
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00002EA0 00171 MIOS_RESERVED_168 EQU 0x2ea0
00002EA4 00172 MIOS_RESERVED_169 EQU 0x2ea4
00002EA8 00173 MIOS_RESERVED_170 EQU 0x2ea8
00002EAC 00174 MIOS_RESERVED_171 EQU 0x2eac
00002EB0 00175 MIOS_RESERVED_172 EQU 0x2eb0
00002EB4 00176 MIOS_RESERVED_173 EQU 0x2eb4
00002EB8 00177 MIOS_RESERVED_174 EQU 0x2eb8
00002EBC 00178 MIOS_RESERVED_175 EQU 0x2ebc
00002EC0 00179 MIOS_RESERVED_176 EQU 0x2ec0
00002EC4 00180 MIOS_RESERVED_177 EQU 0x2ec4
00002EC8 00181 MIOS_RESERVED_178 EQU 0x2ec8
00002ECC 00182 MIOS_RESERVED_179 EQU 0x2ecc
00002ED0 00183 MIOS_RESERVED_180 EQU 0x2ed0
00002ED4 00184 MIOS_RESERVED_181 EQU 0x2ed4
00002ED8 00185 MIOS_RESERVED_182 EQU 0x2ed8
00002EDC 00186 MIOS_RESERVED_183 EQU 0x2edc
00002EE0 00187 MIOS_RESERVED_184 EQU 0x2ee0
00002EE4 00188 MIOS_RESERVED_185 EQU 0x2ee4
00002EE8 00189 MIOS_RESERVED_186 EQU 0x2ee8
00002EEC 00190 MIOS_RESERVED_187 EQU 0x2eec
00002EF0 00191 MIOS_RESERVED_188 EQU 0x2ef0
00002EF4 00192 MIOS_RESERVED_189 EQU 0x2ef4
00002EF8 00193 MIOS_RESERVED_190 EQU 0x2ef8
00002EFC 00194 MIOS_RESERVED_191 EQU 0x2efc
00002F00 00195 MIOS_RESERVED_192 EQU 0x2f00
00002F04 00196 MIOS_RESERVED_193 EQU 0x2f04
00002F08 00197 MIOS_RESERVED_194 EQU 0x2f08
00002F0C 00198 MIOS_RESERVED_195 EQU 0x2f0c
00002F10 00199 MIOS_RESERVED_196 EQU 0x2f10
00002F14 00200 MIOS_RESERVED_197 EQU 0x2f14
00002F18 00201 MIOS_RESERVED_198 EQU 0x2f18
00002F1C 00202 MIOS_RESERVED_199 EQU 0x2f1c
00002F20 00203 MIOS_RESERVED_200 EQU 0x2f20
00002F24 00204 MIOS_RESERVED_201 EQU 0x2f24
00002F28 00205 MIOS_RESERVED_202 EQU 0x2f28
00002F2C 00206 MIOS_RESERVED_203 EQU 0x2f2c
00002F30 00207 MIOS_RESERVED_204 EQU 0x2f30
00002F34 00208 MIOS_RESERVED_205 EQU 0x2f34
00002F38 00209 MIOS_RESERVED_206 EQU 0x2f38
00002F3C 00210 MIOS_RESERVED_207 EQU 0x2f3c
00002F40 00211 MIOS_RESERVED_208 EQU 0x2f40
00002F44 00212 MIOS_RESERVED_209 EQU 0x2f44
00002F48 00213 MIOS_RESERVED_210 EQU 0x2f48
00002F4C 00214 MIOS_RESERVED_211 EQU 0x2f4c
00002F50 00215 MIOS_RESERVED_212 EQU 0x2f50
00002F54 00216 MIOS_RESERVED_213 EQU 0x2f54
00002F58 00217 MIOS_RESERVED_214 EQU 0x2f58
00002F5C 00218 MIOS_RESERVED_215 EQU 0x2f5c
00002F60 00219 MIOS_RESERVED_216 EQU 0x2f60
00002F64 00220 MIOS_RESERVED_217 EQU 0x2f64
00002F68 00221 MIOS_RESERVED_218 EQU 0x2f68
00002F6C 00222 MIOS_RESERVED_219 EQU 0x2f6c
00002F70 00223 MIOS_RESERVED_220 EQU 0x2f70
00002F74 00224 MIOS_RESERVED_221 EQU 0x2f74
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 16
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00002F78 00225 MIOS_RESERVED_222 EQU 0x2f78
00002F7C 00226 MIOS_RESERVED_223 EQU 0x2f7c
00002F80 00227 MIOS_RESERVED_224 EQU 0x2f80
00002F84 00228 MIOS_RESERVED_225 EQU 0x2f84
00002F88 00229 MIOS_RESERVED_226 EQU 0x2f88
00002F8C 00230 MIOS_RESERVED_227 EQU 0x2f8c
00002F90 00231 MIOS_RESERVED_228 EQU 0x2f90
00002F94 00232 MIOS_RESERVED_229 EQU 0x2f94
00002F98 00233 MIOS_RESERVED_230 EQU 0x2f98
00002F9C 00234 MIOS_RESERVED_231 EQU 0x2f9c
00002FA0 00235 MIOS_RESERVED_232 EQU 0x2fa0
00002FA4 00236 MIOS_RESERVED_233 EQU 0x2fa4
00002FA8 00237 MIOS_RESERVED_234 EQU 0x2fa8
00002FAC 00238 MIOS_RESERVED_235 EQU 0x2fac
00002FB0 00239 MIOS_RESERVED_236 EQU 0x2fb0
00002FB4 00240 MIOS_RESERVED_237 EQU 0x2fb4
00002FB8 00241 MIOS_RESERVED_238 EQU 0x2fb8
00002FBC 00242 MIOS_RESERVED_239 EQU 0x2fbc
00002FC0 00243 MIOS_RESERVED_240 EQU 0x2fc0
00002FC4 00244 MIOS_RESERVED_241 EQU 0x2fc4
00002FC8 00245 MIOS_RESERVED_242 EQU 0x2fc8
00002FCC 00246 MIOS_RESERVED_243 EQU 0x2fcc
00002FD0 00247 MIOS_RESERVED_244 EQU 0x2fd0
00002FD4 00248 MIOS_RESERVED_245 EQU 0x2fd4
00002FD8 00249 MIOS_RESERVED_246 EQU 0x2fd8
00002FDC 00250 MIOS_RESERVED_247 EQU 0x2fdc
00002FE0 00251 MIOS_RESERVED_248 EQU 0x2fe0
00002FE4 00252 MIOS_RESERVED_249 EQU 0x2fe4
00002FE8 00253 MIOS_RESERVED_250 EQU 0x2fe8
00002FEC 00254 MIOS_RESERVED_251 EQU 0x2fec
00002FF0 00255 MIOS_RESERVED_252 EQU 0x2ff0
00002FF4 00256 MIOS_RESERVED_253 EQU 0x2ff4
00002FF8 00257 MIOS_RESERVED_254 EQU 0x2ff8
00002FFC 00258 MIOS_RESERVED_255 EQU 0x2ffc
00029
00030 ;; ---[ user hooks (never change!) ]---
00031 #include <user_vectors.inc>
00001 ; $Id: user_vectors.inc 49 2008-01-30 21:47:31Z tk $
00002 ;
00003 ; User vectortable - contains user hooks to MIOS
00004 ;
00005 ; ==========================================================================
00006 ;
00007 ; Copyright 1998-2006 Thorsten Klose (tk@midibox.org)
00008 ; Licensed for personal non-commercial use only.
00009 ; All other rights reserved.
00010 ;
00011 ; ==========================================================================
00012
00013 ;; never change the origin or the order of entries!
3000 00014 org 0x3000
3000 00015 _User_Init
3000 EF87 F019 00016 goto USER_Init
3004 00017 _USER_Tick
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 17
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
3004 EFA9 F019 00018 goto USER_Tick
3008 00019 _USER_Timer
3008 EFB0 F019 00020 goto USER_Timer
300C 00021 _USER_MPROC_DebugTrigger
300C EFB3 F019 00022 goto USER_MPROC_DebugTrigger
3010 00023 _USER_DISPLAY_Init
3010 EFB4 F019 00024 goto USER_DISPLAY_Init
3014 00025 _USER_DISPLAY_Tick
3014 EFB5 F019 00026 goto USER_DISPLAY_Tick
3018 00027 _USER_SR_Service_Prepare
3018 EFD9 F019 00028 goto USER_SR_Service_Prepare
301C 00029 _USER_SR_Service_Finish
301C EFDA F019 00030 goto USER_SR_Service_Finish
3020 00031 _USER_DIN_NotifyToggle
3020 EFD7 F019 00032 goto USER_DIN_NotifyToggle
3024 00033 _USER_ENC_NotifyChange
3024 EFD8 F019 00034 goto USER_ENC_NotifyChange
3028 00035 _USER_AIN_NotifyChange
3028 EFDB F019 00036 goto USER_AIN_NotifyChange
302C 00037 _USER_MPROC_NotifyReceivedByte
302C EFC1 F019 00038 goto USER_MPROC_NotifyReceivedByte
3030 00039 _USER_MPROC_NotifyTimeout
3030 EFBE F019 00040 goto USER_MPROC_NotifyTimeout
3034 00041 _USER_MPROC_NotifyReceivedEvent
3034 EFBA F019 00042 goto USER_MPROC_NotifyReceivedEvent
3038 00043 _USER_MPROC_NotifyFoundEvent
3038 EFBD F019 00044 goto USER_MPROC_NotifyFoundEvent
303C 00045 _USER_LCD_Init
303C EF80 F019 00046 goto USER_LCD_Init
3040 00047 _USER_LCD_Clear
3040 EF81 F019 00048 goto USER_LCD_Clear
3044 00049 _USER_LCD_CursorSet
3044 EF82 F019 00050 goto USER_LCD_CursorSet
3048 00051 _USER_LCD_PrintChar
3048 EF83 F019 00052 goto USER_LCD_PrintChar
304C 00053 _USER_MIDI_NotifyRx
304C EFC7 F019 00054 goto USER_MIDI_NotifyRx
3050 00055 _USER_MIDI_NotifyTx
3050 EFC4 F019 00056 goto USER_MIDI_NotifyTx
3054 00057 _USER_LCD_Data
3054 EF84 F019 00058 goto USER_LCD_Data
3058 00059 _USER_LCD_Cmd
3058 EF85 F019 00060 goto USER_LCD_Cmd
305C 00061 _USER_LCD_SpecialCharInit
305C EF86 F019 00062 goto USER_LCD_SpecialCharInit
3060 00063 USER_RESERVED_25
3060 0012 00064 return
3062 0000 00065 nop
3064 00066 USER_RESERVED_26
3064 0012 00067 return
3066 0000 00068 nop
3068 00069 USER_RESERVED_27
3068 0012 00070 return
306A 0000 00071 nop
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 18
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
306C 00072 USER_RESERVED_28
306C 0012 00073 return
306E 0000 00074 nop
3070 00075 USER_RESERVED_29
3070 0012 00076 return
3072 0000 00077 nop
3074 00078 USER_RESERVED_30
3074 0012 00079 return
3076 0000 00080 nop
3078 00081 USER_RESERVED_31
3078 0012 00082 return
307A 0000 00083 nop
307C 00084 USER_RESERVED_32
307C 0012 00085 return
307E 0000 00086 nop
00032
00033 ;; ---[ variables used by application ]---
00034 #include "app_defines.h"
00001 ; $Id: app_defines.h bdupeyron.tech@gmail.com(Antichambre)
00002 ;
00003 ; Specific Defines and variables of MIOS Application
00004 ;
00005 ; ==========================================================================
00006 ;
00007 ; Copyright 1998-2006 Thorsten Klose (tk@midibox.org)
00008 ; Licensed for personal non-commercial use only.
00009 ; All other rights reserved.
00010 ;
00011 ; ==========================================================================
00012
3080 00013 #define TIA_STAT_ENGINE_DISABLE 0 ; if set, TIA tick and TIA interrupt will not be processed
3080 00014 #define TIA_STAT_FORCE_REFRESH 1 ; if set, a refresh will be forced with next TIA_Tick
3080 00015 #define TIA_STAT_CC_DUMP_REQ 2 ; if set, a CC dump will be sent
3080 00016 #define TIA_STAT_SAVED_GIE 3 ; save the GIE bit for nested interrupt disables
3080 00017 #define TIA_STAT_TRIGGER_RESET 4 ; if set, the TIA will be reset with next TIA_Tick
00018
00019 ;; ==========================================================================
00020
3080 00021 #define TIA_PLAY_MODE_POLY 0
3080 00022 #define TIA_PLAY_MODE_SUS_KEY 1
3080 00023 #define TIA_PLAY_MODE_LEGATO_OFF 2
3080 00024 #define TIA_PLAY_MODE_ONLY_WT_OFF 3
00025
00026 ;; ==========================================================================
3080 00027 #define TIA_MIDI_SYNC_SEND_CLK 0 ; send MIDI clock
3080 00028 #define TIA_MIDI_SYNC_F8 4 ; bit 4 notifies a received MIDI clock
3080 00029 #define TIA_MIDI_SYNC_FA 5 ; bit 5 notifies a received MIDI clock start
3080 00030 #define TIA_MIDI_SYNC_TICK_1 6 ; bit 6 notifies that the TIA_SW engine should be clocked with common resolution
3080 00031 #define TIA_MIDI_SYNC_TICK_2 7 ; bit 7 notifies that the TIA_SW engine should be clocked with double resolution
00032
00033 ;; ==========================================================================
00034
3080 00035 #define TIA_MOD_SYNC_LFO1 0 ; sync LFO1
3080 00036 #define TIA_MOD_SYNC_LFO2 1 ; sync LFO2
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 19
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
3080 00037 #define TIA_MOD_SYNC_LFO3 2 ; sync LFO3
3080 00038 #define TIA_MOD_SYNC_LFO4 3 ; sync LFO4
3080 00039 #define TIA_MOD_SYNC_ENV1 4 ; sync ENV1
3080 00040 #define TIA_MOD_SYNC_ENV2 5 ; sync ENV2
00041
00042 ;; ==========================================================================
00043
3080 00044 #define BANKSTICK_MAGIC0 0x83; magic numbers - if they don't exists in bankstick at BANK_MAGIC_ADDRESS,
3080 00045 #define BANKSTICK_MAGICP 0x12 ; the stick will be ignored until it has been formatted
3080 00046 #define BANKSTICK_MAGICK BANKSTICK_MAGICP+1 ; the stick will be ignored until it has been formatted
00047
00048 ;; ==========================================================================
00049 ;; free memory for user applications:
00050 ;; 0x010-0x37f
00051
00052 ;; ==========================================================================
00053 ;; General TIA Control Variables in ACCESS page
00054 ;; ==========================================================================
00000010 00055 TIA_STAT EQU 0x010
00056
00000011 00057 TIA_BANK EQU 0x011
00000012 00058 TIA_PRESET EQU 0x012
00000013 00059 TIA_PATCH EQU 0x013
00000014 00060 TIA_PBANK EQU 0x014
00000015 00061 TIA_KIT EQU 0x015
00000016 00062 TIA_KBANK EQU 0x016
00000017 00063 TIA_WT EQU 0x017
00000018 00064 TIA_WBANK EQU 0x018
00000019 00065 TIA_BANKSTICK_CHK_CTR EQU 0x019
0000001A 00066 TIA_BANKSTICK_ID EQU 0x01a
0000001B 00067 TIA_BANKSTICK_RDY EQU 0x01b
0000001C 00068 TIA_BANKSTICK_STAT EQU 0x01c
0000001D 00069 TIA_BANKSTICK_SIZE EQU 0x01d
00070
00000020 00071 TIA_MIDI_DEVICE EQU 0x020
00072
00073 ;; ==========================================================================
00074 ;; Variables used by the MIDI processor in tia_sysex.inc
00075 ;; ==========================================================================
00000021 00076 TIA_SYSEX_STATE EQU 0x021
00000022 00077 TIA_SYSEX_ACTION EQU 0x022
00000023 00078 TIA_SYSEX_IN EQU 0x023
00000024 00079 TIA_SYSEX_CHECKSUM EQU 0x024
00000025 00080 TIA_SYSEX_ADDRESS EQU 0x025
00000026 00081 TIA_SYSEX_ERROR EQU 0x026
00082
00083 ;; ==========================================================================
00084 ;; free: 0x27-0x66
00085
00086 ;; ==========================================================================
00087
00000067 00088 MIDI_RXTX_RX_CTR EQU 0x067
00000068 00089 MIDI_RXTX_TX_CTR EQU 0x068
00000069 00090 MIDI_RXTX_BEAT_CTR EQU 0x069
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 20
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00091
00092 ;; ==========================================================================
00093
0000006A 00094 TIA_LEDMTR_STAT EQU 0x06a
0000006B 00095 TIA_LEDMTR_VALUE EQU 0x06b
00096
00097 ;; ==========================================================================
00098
0000006C 00099 AOUT_FILTER_TMP_L EQU 0x06c ; used in tia_sw.inc as temporary storage for [filter value
0000006D 00100 AOUT_FILTER_TMP_H EQU 0x06d
00101
00102 ;; ==========================================================================
00103
0000006E 00104 AOUT_INVERTED EQU 0x06e
0000006F 00105 AOUT_UPDATE_REQ EQU 0x06f
00000070 00106 AOUT_VALUES EQU 0x070 ; ..0x07f (8 * 16bit words)
00107
00108 ;; ==========================================================================
00109 ;; note: 0x080-0x0ff used by CS_TIAS1
00110 ;; ==========================================================================
00111 ;; a lot of TIA control variables in BANKED page
00112 ;; ==========================================================================
00000100 00113 TIA_SW_CLEAR_BEGIN EQU 0x100 ; used to initialize the whole TIA_SW memory
000001FF 00114 TIA_SW_CLEAR_END EQU 0x1ff ; also used as 256 byte download buffer (!)
00115
00000100 00116 TIA_BASE EQU 0x100 ; address space of TIA chip (used: 0x00-0x05)
00117
00000100 00118 TIA_AUDC0 EQU TIA_BASE+0x00 ;; control. for voice 1 (Aud0)
00000101 00119 TIA_AUDC1 EQU TIA_BASE+0x01 ;; control. for voice 2 (Aud1)
00000102 00120 TIA_AUDF0 EQU TIA_BASE+0x02 ;; freq. for voice 1 (Aud0)
00000103 00121 TIA_AUDF1 EQU TIA_BASE+0x03 ;; freq. for voice 2 (Aud1)
00000104 00122 TIA_AUDV0 EQU TIA_BASE+0x04 ;; vol. for voice 1 (Aud0)
00000105 00123 TIA_AUDV1 EQU TIA_BASE+0x05 ;; vol. for voice 2 (Aud1)
00124
0000010B 00125 TIA_MASTER_VOL EQU TIA_BASE+0x0b ; internal TIA_SW register
0000010C 00126 TIA_PLAY_MODE EQU TIA_BASE+0x0c ; internal TIA_SW register
0000010D 00127 TIA_SE_OPTION EQU TIA_BASE+0x0d ; internal TIA_SW register
0000010E 00128 TIA_SW_VOICE EQU TIA_BASE+0x0e ; internal TIA_SW register
0000010F 00129 TIA_SW_LFO_NUMBER EQU TIA_BASE+0x0f ; internal TIA_SW register
0000010F 00130 TIA_SW_ENV_NUMBER EQU TIA_SW_LFO_NUMBER
00131
0000010F 00132 TIA_BASE_END EQU 0x10f
00133
00134 ;; ==========================================================================
00135
00000110 00136 TIA_SHADOW_BASE EQU 0x110 ; shadow addresses, necessary to determine changes (used: 0x00-0x05)
00137
00138 ;; (TIA_SHADOW_BASE + 0x00) to (TIA_SHADOW_BASE + 0x05) allocated by shadow registers
00139
0000011C 00140 TIA_LFO_RANDOM_SEED_L EQU TIA_SHADOW_BASE+0x0c ; internal TIA_SW register
0000011D 00141 TIA_LFO_RANDOM_SEED_H EQU TIA_SHADOW_BASE+0x0d ; internal TIA_SW register
0000011E 00142 TIA_ENVx_CURVES EQU TIA_SHADOW_BASE+0x0e ; internal TIA_SW register
0000011F 00143 TIA_MOD_SYNC EQU TIA_SHADOW_BASE+0x0f ; internal TIA_SW register
00144
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 21
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
0000011F 00145 TIA_SHADOW_END EQU 0x11f
00146
00147 ;; ==========================================================================
00148
00000040 00149 TIA_Vx_RECORD_LEN EQU 64 ;; 64 Max
00150
00000000 00151 TIA_Vx_MIDI_CHANNEL EQU 0x00
00000001 00152 TIA_Vx_SPLIT_LOWER EQU 0x01
00000002 00153 TIA_Vx_SPLIT_UPPER EQU 0x02
00000003 00154 TIA_Vx_STAT EQU 0x03
00000004 00155 TIA_Vx_MODE EQU 0x04 ; Always follow TIA_Vx_STAT
00000005 00156 TIA_Vx_KEY_OFFSET EQU 0x05
00000006 00157 TIA_Vx_KEY_LENGTH EQU 0x06
00000007 00158 TIA_Vx_TARGET_FRQ_L EQU 0x07
00000008 00159 TIA_Vx_TARGET_FRQ_H EQU 0x08
00000009 00160 TIA_Vx_FRQ_L EQU 0x09
0000000A 00161 TIA_Vx_FRQ_H EQU 0x0a
0000000B 00162 TIA_Vx_PITCHBENDER EQU 0x0b
0000000C 00163 TIA_Vx_TRANSPOSE EQU 0x0c
0000000D 00164 TIA_Vx_PITCHRANGE EQU 0x0d
0000000E 00165 TIA_Vx_PORTA_RATE EQU 0x0e
0000000F 00166 TIA_Vx_VOLUME EQU 0x0f
00000010 00167 TIA_Vx_NOTE EQU 0x10
00000011 00168 TIA_Vx_NOTE_DELAY EQU 0x11
00000012 00169 TIA_Vx_NOTE_DELAY_CTR EQU 0x12
00000013 00170 TIA_Vx_ARP_RATE EQU 0x13
00000014 00171 TIA_Vx_ARP_NOTE_NUMBER EQU 0x14
00000015 00172 TIA_Vx_ARP_CTR EQU 0x15
00000016 00173 TIA_Vx_PITCH_MOD EQU 0x16
00000017 00174 TIA_Vx_AMP_MOD EQU 0x17
00000018 00175 TIA_Vx_SPARE EQU 0x18
00176
00000019 00177 TIA_Vx_SPARE1 EQU 0x19 ; allocated
0000001A 00178 TIA_Vx_SPARE2 EQU 0x1a ; only free of constant time portamento not activated
0000001B 00179 TIA_Vx_SPARE3 EQU 0x1b ; only free of constant time portamento not activated
0000001C 00180 TIA_Vx_SPARE4 EQU 0x1c ; only free of constant time portamento not activated
0000001D 00181 TIA_Vx_SPARE5 EQU 0x1d ; only free of constant time portamento not activated
00182
0000001A 00183 TIA_Vx_PORTA_CTR_L EQU TIA_Vx_SPARE2
0000001B 00184 TIA_Vx_PORTA_CTR_H EQU TIA_Vx_SPARE3
0000001C 00185 TIA_Vx_PORTA_FRQ_L EQU TIA_Vx_SPARE4
0000001D 00186 TIA_Vx_PORTA_FRQ_H EQU TIA_Vx_SPARE5
00187
0000001E 00188 TIA_Vx_ARP_NOTE_0 EQU 0x1e
0000001F 00189 TIA_Vx_ARP_NOTE_1 EQU 0x1f
00000020 00190 TIA_Vx_ARP_NOTE_2 EQU 0x20
00000021 00191 TIA_Vx_ARP_NOTE_3 EQU 0x21
00000022 00192 TIA_Vx_NOTE_STACK_0 EQU 0x22
00000023 00193 TIA_Vx_NOTE_STACK_1 EQU 0x23
00000024 00194 TIA_Vx_NOTE_STACK_2 EQU 0x24
00000025 00195 TIA_Vx_NOTE_STACK_3 EQU 0x25
00000004 00196 TIA_NOTE_STACK_LEN EQU TIA_Vx_NOTE_STACK_3-TIA_Vx_NOTE_STACK_0+1
00197
00000026 00198 TIA_Vx_ASSIGN_VEL EQU 0x26
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 22
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00000027 00199 TIA_Vx_INIT_VEL EQU 0x27
00000028 00200 TIA_Vx_LAST_VEL EQU 0x28
00000029 00201 TIA_Vx_DEPTH_VEL EQU 0x29
00202
0000002A 00203 TIA_Vx_ENV_OPTION EQU 0x2a
0000002B 00204 TIA_Vx_OPTION EQU 0x2b
0000002C 00205 TIA_Vx_WBANK EQU 0x2c
0000002D 00206 TIA_Vx_WT EQU 0x2d
0000002E 00207 TIA_Vx_WT_STATE EQU 0x2e
0000002F 00208 TIA_Vx_WT_RATE EQU 0x2f
00000030 00209 TIA_Vx_WT_CLK_REQ_CTR EQU 0x30
00000031 00210 TIA_Vx_WT_CTR EQU 0x31
00000032 00211 TIA_Vx_WT_POS EQU 0x32
00000033 00212 TIA_Vx_WT_SAVED_PATCH EQU 0x33 ;; a eliminer
00000034 00213 TIA_Vx_WT_ASSIGN_P1 EQU 0x34
00000035 00214 TIA_Vx_WT_ASSIGN_P2 EQU 0x35
00000036 00215 TIA_Vx_WT_ASSIGN_P3 EQU 0x36
00000037 00216 TIA_Vx_WT_303_TICK_CTR EQU 0x37
00000038 00217 TIA_Vx_KBANK EQU 0x38
00000039 00218 TIA_Vx_KIT EQU 0x39
0000003A 00219 TIA_Vx_KIT_STATE EQU 0x3a
0000003B 00220 TIA_Vx_KIT_RATE EQU 0x3b
0000003C 00221 TIA_Vx_KIT_CLK_REQ_CTR EQU 0x3c
0000003D 00222 TIA_Vx_KIT_CTR EQU 0x3d
0000003E 00223 TIA_Vx_KIT_POS EQU 0x3e
00224
0000003F 00225 TIA_Vx_FREE1 EQU 0x3f
00226
00000120 00227 TIA_V1_BASE EQU 0x120 + 0 * TIA_Vx_RECORD_LEN ; 0x0120-0x15f
00000160 00228 TIA_V2_BASE EQU 0x120 + 1 * TIA_Vx_RECORD_LEN ; 0x0160-0x19f
00229
00230 ;; ==========================================================================
00231
00000007 00232 TIA_LFOx_RECORD_LEN EQU 7
00000000 00233 TIA_LFOx_MODE EQU 0x00
00000001 00234 TIA_LFOx_RATE EQU 0x01
00000002 00235 TIA_LFOx_CTR EQU 0x02
00000003 00236 TIA_LFOx_VALUE EQU 0x03
00000004 00237 TIA_LFOx_DEPTH EQU 0x04
00000005 00238 TIA_LFOx_RVALUE_L EQU 0x05
00000006 00239 TIA_LFOx_RVALUE_H EQU 0x06
00240
000001A0 00241 TIA_LFO1_BASE EQU 0x1a0 + 0 * TIA_LFOx_RECORD_LEN ; 0x1a0-0x1a6
000001A7 00242 TIA_LFO2_BASE EQU 0x1a0 + 1 * TIA_LFOx_RECORD_LEN ; 0x1a7-0x1ad
000001AE 00243 TIA_LFO3_BASE EQU 0x1a0 + 2 * TIA_LFOx_RECORD_LEN ; 0x1ae-0x1b4
000001B5 00244 TIA_LFO4_BASE EQU 0x1a0 + 3 * TIA_LFOx_RECORD_LEN ; 0x1b5-0x1bb
00245
00246 ;; ==========================================================================
00247
0000000B 00248 TIA_ENVx_RECORD_LEN EQU 11
00000000 00249 TIA_ENVx_MODE EQU 0x00
00000001 00250 TIA_ENVx_CTR_L EQU 0x01
00251
00000002 00252 TIA_ENVx_CTR_H EQU 0x02
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 23
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00000003 00253 TIA_ENVx_ATTACK EQU 0x03
00000004 00254 TIA_ENVx_DECAY EQU 0x04
00000005 00255 TIA_ENVx_SUSTAIN EQU 0x05
00000006 00256 TIA_ENVx_RELEASE EQU 0x06
00000007 00257 TIA_ENVx_CURVE EQU 0x07
00000008 00258 TIA_ENVx_DEPTH EQU 0x08
00000009 00259 TIA_ENVx_RVALUE_L EQU 0x09
0000000A 00260 TIA_ENVx_RVALUE_H EQU 0x0a
00261
000001BC 00262 TIA_ENVAUD0_BASE EQU 0x1bc + 0 * TIA_ENVx_RECORD_LEN ; 0x1bc-0x1c6
000001C7 00263 TIA_ENVAUD1_BASE EQU 0x1bc + 1 * TIA_ENVx_RECORD_LEN ; 0x1c7-0x1d1
000001D2 00264 TIA_ENV1_BASE EQU 0x1bc + 2 * TIA_ENVx_RECORD_LEN ; 0x1d2-0x1dc
000001DD 00265 TIA_ENV2_BASE EQU 0x1bc + 3 * TIA_ENVx_RECORD_LEN ; 0x1dd-0x1e7
00266
00267 ;; ==========================================================================
00268
00000004 00269 TIA_CTRLx_RECORD_LEN EQU 4
00000000 00270 TIA_CTRLx_ASSIGN EQU 0x00
00000001 00271 TIA_CTRLx_INIT EQU 0x01
00000002 00272 TIA_CTRLx_LAST EQU 0x02
00000003 00273 TIA_CTRLx_DEPTH EQU 0x03
00274
000001E8 00275 TIA_CTRL_AFTERTOUCH_BASE EQU 0x1e8 + 0 * TIA_CTRLx_RECORD_LEN ; 0x1e8-0x1eb
000001EC 00276 TIA_CTRL_MODWHEEL_BASE EQU 0x1e8 + 1 * TIA_CTRLx_RECORD_LEN ; 0x1ec-0x1ef
00277
00278 ;; ==========================================================================
00279
000001F0 00280 TIA_MIDI_SYNC EQU 0x1f0
000001F1 00281 TIA_MIDI_SYNC_CTR EQU 0x1f1
000001F2 00282 TIA_MIDI_SYNC_CTR_REG EQU 0x1f2
00283
00284 ;; ==========================================================================
00285
00286 ; free 0x1f4-0x1f5
00287 ;; ==========================================================================
00288
000001F6 00289 SAVED_PRODL EQU 0x1f6 ; used by tia_sw.inc
000001F7 00290 SAVED_PRODH EQU 0x1f7 ; used by tia_sw.inc
00291
00292 ;; ==========================================================================
000001F8 00293 MUL_A_L EQU 0x1f8 ; used by math_mul16_16.inc
000001F9 00294 MUL_A_H EQU 0x1f9
000001FA 00295 MUL_B_L EQU 0x1fa
000001FB 00296 MUL_B_H EQU 0x1fb
000001FC 00297 MUL_R_0 EQU 0x1fc
000001FD 00298 MUL_R_1 EQU 0x1fd
000001FE 00299 MUL_R_2 EQU 0x1fe
000001FF 00300 MUL_R_3 EQU 0x1ff
00301
00302
000001F8 00303 DIV_A_0 EQU MUL_A_L ; used by math_div16_16.inc
000001F9 00304 DIV_A_1 EQU MUL_A_H
000001FA 00305 DIV_A_2 EQU MUL_B_L
000001FB 00306 DIV_B_0 EQU MUL_B_H
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 24
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
000001FC 00307 DIV_B_1 EQU MUL_R_0
000001FD 00308 DIV_COUNT EQU MUL_R_1
000001FE 00309 DIV_REM_0 EQU MUL_R_2
000001FF 00310 DIV_REM_1 EQU MUL_R_3
00311
00312
00313 ;; ==========================================================================
00000700 00314 BANKSTICK_FORMAT_BEGIN EQU 0x700 ; buffer temporary used to format the BankStick
000007FF 00315 BANKSTICK_FORMAT_END EQU 0x7ff ; CS variables have to be initialized again after formatting
00316
00317
00318
00319
00320
00321
00322 ;; ==========================================================================
00323
00324
00325
00326 ;;free 0x3c8-0x37f
00035
00036 ; ==========================================================================
00037
00038 ;; ---[ configuration table for MIDI processor and rotary encoders ]---
00039 #include "mios_tables.inc"
00001 ; $Id: mios_tables.inc 339 2008-05-14 20:26:50Z tk $
00002 ;
00003 ; Configuration Tables for MIOS Application
00004 ;
00005 ; ==========================================================================
00006 ;
00007 ; Copyright 1998-2006 Thorsten Klose (tk@midibox.org)
00008 ; Licensed for personal non-commercial use only.
00009 ; All other rights reserved.
00010 ;
00011 ; ==========================================================================
00012
3080 00013 org 0x3080 ; never change the origin!
00014
00015 ;; --------------------------------------------------------------------------
00016 ;; The MIDI Trigger table maps incoming MIDI events to control elements
00017 ;; (pots/faders, encoders, buttons, LEDs, ...)
00018 ;;
00019 ;; After the MIOS MIDI processor (MPROC) has received a complete event, it
00020 ;; searches in this table for a matching entry and calls USER_MPROC_NotifyFoundEvent
00021 ;; with the table index in WREG and the MIDI event in MIOS_PARAMETER[123]
00022 ;;
00023 ;; Note also that the MIDI processor stops scanning the table after
00024 ;; the first MT_EOT entry
00025 ;;
00026 ;; Note2: never change the origin (memory location) of this table!
00027 ;;
00028 ;; Optionally this table can also be used to define events, which should be
00029 ;; transmitted (Example: see example_ain64_din128_dout128), so that incoming
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 25
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00030 ;; and outgoing events are located at one place
00031 ;;
00032 ;; The table *must* contain 256 entries. Unused entries should be filled with
00033 ;; MT_EOT.
00034 ;; --------------------------------------------------------------------------
00035
00036 ;; MIDI Trigger entry structure
00037 MT_ENTRY MACRO event_0, event_1
00038 dw (event_1 << 8) | event_0
00039 ENDM
00040
00041 MT_EOT MACRO
00042 dw 0xffff
00043 ENDM
00044
00045
3080 00046 MIOS_MPROC_EVENT_TABLE
00047 ;; this "end of table" entry ensures that MIOS will stop searching here
00048 MT_EOT
3080 FFFF M dw 0xffff
00049
00050
00051 ;; dirty but allowed so long as MT_EOT can be found at 0x3080:
00052 ;; since the MIDIbox TIA application doesn't get use of the MPROC_EVENT_TABLE,
00053 ;; we are using the address range from 0x3082 to 0x327f for other
00054 ;; application specific tables
00055
00056 #include "tia_frq_table.inc"
00001 ; $Id: tia_frq_table.inc 111 2008-02-22 00:41:21Z tk $
00002 ;
00003 ; MIDIbox TIA
00004 ; Frequency Table (refer to the TIA spec)
00005 ;
00006 ; ==========================================================================
00007 ;
00008 ; Copyright 1998-2006 Thorsten Klose (tk@midibox.org)
00009 ; Licensed for personal non-commercial use only.
00010 ; All other rights reserved.
00011 ;
00012 ; ==========================================================================
00013
00014 ;; --------------------------------------------------------------------------
00015 ;; In: note index (0x00-0x7f) in WREG
00016 ;; Out: frq low byte in WREG and MIOS_PARAMETER1, frq high byte in MIOS_PARAMETER2
00017 ;; --------------------------------------------------------------------------
3082 00018 TIA_FRQ_TABLE_Get
3082 90D8 00019 clrc
3084 34E8 00020 rlf WREG, W
3086 0FA0 00021 addlw TIA_FRQ_TABLE & 0xff
3088 6EF6 00022 movwf TBLPTRL
308A 6AF7 00023 clrf TBLPTRH
308C 0E30 00024 movlw TIA_FRQ_TABLE >> 8
308E 22F7 00025 addwfc TBLPTRH, F
00026
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 26
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
3090 0009 00027 tblrd*+
3092 CFF5 F003 00028 movff TABLAT, MIOS_PARAMETER1
3096 0009 00029 tblrd*+
3098 CFF5 F004 00030 movff TABLAT, MIOS_PARAMETER2
309C 5003 00031 movf MIOS_PARAMETER1, W
309E 0012 00032 return
00033
00034 ; ==========================================================================
00035
30A0 00036 TIA_FRQ_TABLE
30A0 0028 002B 00037 dw 0x0028,0x002b,0x002d,0x0030,0x0033,0x0036,0x0039,0x003d,0x0040,0x0044,0x0048,0x004c
002D 0030
0033 0036
0039 003D
0040 0044
0048 004C
30B8 0051 0056 00038 dw 0x0051,0x0056,0x005b,0x0060,0x0066,0x006c,0x0073,0x007a,0x0081
005B 0060
0066 006C
0073 007A
0081
00039
30CA 0089 0091 00040 dw 0x0089,0x0091,0x0099,0x00a3,0x00ac,0x00b7,0x00c1,0x00cd,0x00d9,0x00e6,0x00f4,0x0102 ; c-2
0099 00A3
00AC 00B7
00C1 00CD
00D9 00E6
00F4 0102
30E2 0112 0122 00041 dw 0x0112,0x0122,0x0133,0x0146,0x0159,0x016e,0x0183,0x019b,0x01b3,0x01cd,0x01e8,0x0205 ; c-1
0133 0146
0159 016E
0183 019B
01B3 01CD
01E8 0205
30FA 0224 0245 00042 dw 0x0224,0x0245,0x0267,0x028c,0x02b3,0x02da,0x0307,0x0336,0x0366,0x039a,0x03d1,0x040b ; c-0
0267 028C
02B3 02DA
0307 0336
0366 039A
03D1 040B
3112 0449 048A 00043 dw 0x0449,0x048a,0x04cf,0x0518,0x0566,0x05b8,0x060f,0x066c,0x06cd,0x0735,0x07a3,0x0817 ; C-1
04CF 0518
0566 05B8
060F 066C
06CD 0735
07A3 0817
312A 0892 0915 00044 dw 0x0892,0x0915,0x099f,0x0A31,0x0Acd,0x0B71,0x0C1f,0x0Cd8,0x0D9b,0x0E6a,0x0F46,0x102e ; C-2
099F 0A31
0ACD 0B71
0C1F 0CD8
0D9B 0E6A
0F46 102E
3142 1125 122A 00045 dw 0x1125,0x122a,0x133e,0x1463,0x159a,0x16e3,0x183f,0x19b0,0x1B37,0x1Cd5,0x1E8c,0x205d ; C-3
133E 1463
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 27
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
159A 16E3
183F 19B0
1B37 1CD5
1E8C 205D
315A 224A 2454 00046 dw 0x224a,0x2454,0x267d,0x28c7,0x2B34,0x2Dc6,0x307e,0x3361,0x366f,0x39ab,0x3D19,0x40bc ; C-4
267D 28C7
2B34 2DC6
307E 3361
366F 39AB
3D19 40BC
3172 4495 48A8 00047 dw 0x4495,0x48a8,0x4Cfc,0x518f,0x5668,0x5B8c,0x60fe,0x66c2,0x6Cde,0x7357,0x7A34,0x8177 ; C-5
4CFC 518F
5668 5B8C
60FE 66C2
6CDE 7357
7A34 8177
318A 892A 9153 00048 dw 0x892a,0x9153,0x99f6,0xA31e,0xACd1,0xB718,0xC1fc,0xCD85,0xD9bc,0xE6af,0xF467 ; C-6
99F6 A31E
ACD1 B718
C1FC CD85
D9BC E6AF
F467
00049
00057 #include "tia_sin_table.inc"
00001 ; $Id: tia_sin_table.inc 111 2008-02-22 00:41:21Z tk $
00002 ;
00003 ; MIDIbox TIA
00004 ; Sinus Table
00005 ; generated with tiatab.pl
00006 ;
00007 ; ==========================================================================
00008 ;
00009 ; Copyright 1998-2006 Thorsten Klose (tk@midibox.org)
00010 ; Licensed for personal non-commercial use only.
00011 ; All other rights reserved.
00012 ;
00013 ; ==========================================================================
00014
00015 ;; --------------------------------------------------------------------------
00016 ;; In: index (0x00-0xff) in WREG
00017 ;; Out: Sin value in WREG and MIOS_PARAMETER1
00018 ;; --------------------------------------------------------------------------
31A0 00019 TIA_SIN_TABLE_Get
00020 ;; note: the table has only 128 entries, the upper entries are just
00021 ;; inverted, so we can save some memory
31A0 6E03 00022 movwf MIOS_PARAMETER1
31A2 AE03 00023 btfss MIOS_PARAMETER1, 7
31A4 0A7F 00024 xorlw 0x7f
31A6 0B7F 00025 andlw 0x7f
00026
31A8 0FBE 00027 addlw TIA_SIN_TABLE & 0xff
31AA 6EF6 00028 movwf TBLPTRL
31AC 6AF7 00029 clrf TBLPTRH
31AE 0E31 00030 movlw TIA_SIN_TABLE >> 8
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 28
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
31B0 22F7 00031 addwfc TBLPTRH, F
00032
31B2 0009 00033 tblrd*+
31B4 50F5 00034 movf TABLAT, W
31B6 BE03 00035 btfsc MIOS_PARAMETER1, 7
31B8 0980 00036 iorlw 0x80
31BA 6E03 00037 movwf MIOS_PARAMETER1
31BC 0012 00038 return
00039
00040 ; ==========================================================================
00041
31BE 00042 TIA_SIN_TABLE
31BE 0100 00043 db 0x00, 0x01
31C0 0403 00044 db 0x03, 0x04
31C2 0706 00045 db 0x06, 0x07
31C4 0A09 00046 db 0x09, 0x0a
31C6 0E0C 00047 db 0x0c, 0x0e
31C8 110F 00048 db 0x0f, 0x11
31CA 1412 00049 db 0x12, 0x14
31CC 1715 00050 db 0x15, 0x17
31CE 1A18 00051 db 0x18, 0x1a
31D0 1D1C 00052 db 0x1c, 0x1d
31D2 201F 00053 db 0x1f, 0x20
31D4 2322 00054 db 0x22, 0x23
31D6 2625 00055 db 0x25, 0x26
31D8 2928 00056 db 0x28, 0x29
31DA 2C2B 00057 db 0x2b, 0x2c
31DC 2F2E 00058 db 0x2e, 0x2f
31DE 3230 00059 db 0x30, 0x32
31E0 3533 00060 db 0x33, 0x35
31E2 3836 00061 db 0x36, 0x38
31E4 3A39 00062 db 0x39, 0x3a
31E6 3D3C 00063 db 0x3c, 0x3d
31E8 403F 00064 db 0x3f, 0x40
31EA 4341 00065 db 0x41, 0x43
31EC 4544 00066 db 0x44, 0x45
31EE 4847 00067 db 0x47, 0x48
31F0 4A49 00068 db 0x49, 0x4a
31F2 4D4C 00069 db 0x4c, 0x4d
31F4 4F4E 00070 db 0x4e, 0x4f
31F6 5251 00071 db 0x51, 0x52
31F8 5453 00072 db 0x53, 0x54
31FA 5755 00073 db 0x55, 0x57
31FC 5958 00074 db 0x58, 0x59
31FE 5B5A 00075 db 0x5a, 0x5b
3200 5D5C 00076 db 0x5c, 0x5d
3202 5F5E 00077 db 0x5e, 0x5f
3204 6160 00078 db 0x60, 0x61
3206 6362 00079 db 0x62, 0x63
3208 6564 00080 db 0x64, 0x65
320A 6766 00081 db 0x66, 0x67
320C 6968 00082 db 0x68, 0x69
320E 6B6A 00083 db 0x6a, 0x6b
3210 6C6C 00084 db 0x6c, 0x6c
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 29
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
3212 6E6D 00085 db 0x6d, 0x6e
3214 706F 00086 db 0x6f, 0x70
3216 7170 00087 db 0x70, 0x71
3218 7372 00088 db 0x72, 0x73
321A 7473 00089 db 0x73, 0x74
321C 7575 00090 db 0x75, 0x75
321E 7676 00091 db 0x76, 0x76
3220 7777 00092 db 0x77, 0x77
3222 7978 00093 db 0x78, 0x79
3224 7A79 00094 db 0x79, 0x7a
3226 7A7A 00095 db 0x7a, 0x7a
3228 7B7B 00096 db 0x7b, 0x7b
322A 7C7C 00097 db 0x7c, 0x7c
322C 7D7C 00098 db 0x7c, 0x7d
322E 7D7D 00099 db 0x7d, 0x7d
3230 7E7E 00100 db 0x7e, 0x7e
3232 7E7E 00101 db 0x7e, 0x7e
3234 7F7F 00102 db 0x7f, 0x7f
3236 7F7F 00103 db 0x7f, 0x7f
3238 7F7F 00104 db 0x7f, 0x7f
323A 7F7F 00105 db 0x7f, 0x7f
323C 7F7F 00106 db 0x7f, 0x7f
00058 #include "tia_depth_table.inc"
00001 ; $Id: tia_depth_table.inc 111 2008-02-22 00:41:21Z tk $
00002 ;
00003 ; MIDIbox TIA
00004 ; Depth Table
00005 ; derived from MIDIbox TIA V1.5
00006 ; required since the frequency table has been changed to keep the influence
00007 ; of the depth parameter compatible with older firmware versions
00008 ;
00009 ; ==========================================================================
00010 ;
00011 ; Copyright 1998-2006 Thorsten Klose (tk@midibox.org)
00012 ; Licensed for personal non-commercial use only.
00013 ; All other rights reserved.
00014 ;
00015 ; ==========================================================================
00016
323E 00017 TIA_DEPTH_TABLE
323E 0100 0302 00018 db 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
0504 0706
3246 0A08 0E0C 00019 db 0x08, 0x0a, 0x0c, 0x0e, 0x11, 0x12, 0x13, 0x14
1211 1413
324E 1615 1818 00020 db 0x15, 0x16, 0x18, 0x18, 0x1b, 0x1c, 0x1e, 0x20
1C1B 201E
3256 2422 2826 00021 db 0x22, 0x24, 0x26, 0x28, 0x2b, 0x2d, 0x30, 0x33
2D2B 3330
325E 3936 403D 00022 db 0x36, 0x39, 0x3d, 0x40, 0x44, 0x48, 0x4d, 0x51
4844 514D
3266 5B56 6661 00023 db 0x56, 0x5b, 0x61, 0x66, 0x6c, 0x73, 0x7a, 0x81
736C 817A
326E 9189 A399 00024 db 0x89, 0x91, 0x99, 0xa3, 0xac, 0xb7, 0xc2, 0xcd
B7AC CDC2
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 30
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
3276 E6D9 FFF4 00025 db 0xd9, 0xe6, 0xf4, 0xff, 0xff, 0xff, 0xff, 0xff
FFFF FFFF
00059
00060 ; ==========================================================================
00061
3280 00062 org 0x3280 ; never change the origin!
00063
00064 ;; --------------------------------------------------------------------------
00065 ;; In this table DIN pins have to be assigned to rotary encoders for the
00066 ;; MIOS_ENC driver
00067 ;;
00068 ;; up to 64 entries are provided
00069 ;;
00070 ;; The table must be terminated with an ENC_EOT entry. Unused entries should
00071 ;; be filled with ENC_EOT
00072 ;;
00073 ;; ENC_ENTRY provides following parameters
00074 ;; o first parameter: number of shift register - 1, 2, 3, ... 16
00075 ;; o second parameter: number of pin; since two pins are necessary
00076 ;; for each encoder, an even number is expected: 0, 2, 4 or 6
00077 ;; o the third parameter contains the encoder mode:
00078 ;; either MIOS_ENC_MODE_NON_DETENTED
00079 ;; or MIOS_ENC_MODE_DETENTED
00080 ;; or MIOS_ENC_MODE_DETENTED2
00081 ;;
00082 ;; Configuration Examples:
00083 ;; ENC_ENTRY 1, 0, MIOS_ENC_MODE_NON_DETENTED ; non-detented encoder at pin 0 and 1 of SR 1
00084 ;; ENC_ENTRY 1, 2, MIOS_ENC_MODE_DETENTED ; detented encoder at pin 2 and 3 of SR 1
00085 ;; ENC_ENTRY 9, 6, MIOS_ENC_MODE_NON_DETENTED ; non-detented encoder at pin 6 and 7 of SR 9
00086 ;; --------------------------------------------------------------------------
00087
00088 ;; encoder entry structure
00089 ENC_ENTRY MACRO sr, din_0, mode
00090 dw (mode << 8) | (din_0 + 8*(sr-1))
00091 ENDM
00092 ENC_EOT MACRO
00093 dw 0xffff
00094 ENDM
00095
3280 00096 MIOS_ENC_PIN_TABLE
00097 ;; encoders 1-16
00098 ENC_EOT
3280 FFFF M dw 0xffff
00099 ENC_EOT
3282 FFFF M dw 0xffff
00100 ENC_EOT
3284 FFFF M dw 0xffff
00101 ENC_EOT
3286 FFFF M dw 0xffff
00102 ENC_EOT
3288 FFFF M dw 0xffff
00103 ENC_EOT
328A FFFF M dw 0xffff
00104 ENC_EOT
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 31
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
328C FFFF M dw 0xffff
00105 ENC_EOT
328E FFFF M dw 0xffff
00106 ENC_EOT
3290 FFFF M dw 0xffff
00107 ENC_EOT
3292 FFFF M dw 0xffff
00108 ENC_EOT
3294 FFFF M dw 0xffff
00109 ENC_EOT
3296 FFFF M dw 0xffff
00110 ENC_EOT
3298 FFFF M dw 0xffff
00111 ENC_EOT
329A FFFF M dw 0xffff
00112 ENC_EOT
329C FFFF M dw 0xffff
00113 ENC_EOT
329E FFFF M dw 0xffff
00114
00115 ;; encoders 17-32
00116 ENC_EOT
32A0 FFFF M dw 0xffff
00117 ENC_EOT
32A2 FFFF M dw 0xffff
00118 ENC_EOT
32A4 FFFF M dw 0xffff
00119 ENC_EOT
32A6 FFFF M dw 0xffff
00120 ENC_EOT
32A8 FFFF M dw 0xffff
00121 ENC_EOT
32AA FFFF M dw 0xffff
00122 ENC_EOT
32AC FFFF M dw 0xffff
00123 ENC_EOT
32AE FFFF M dw 0xffff
00124 ENC_EOT
32B0 FFFF M dw 0xffff
00125 ENC_EOT
32B2 FFFF M dw 0xffff
00126 ENC_EOT
32B4 FFFF M dw 0xffff
00127 ENC_EOT
32B6 FFFF M dw 0xffff
00128 ENC_EOT
32B8 FFFF M dw 0xffff
00129 ENC_EOT
32BA FFFF M dw 0xffff
00130 ENC_EOT
32BC FFFF M dw 0xffff
00131 ENC_EOT
32BE FFFF M dw 0xffff
00132
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 32
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00133 ;; encoders 33-48
00134 ENC_EOT
32C0 FFFF M dw 0xffff
00135 ENC_EOT
32C2 FFFF M dw 0xffff
00136 ENC_EOT
32C4 FFFF M dw 0xffff
00137 ENC_EOT
32C6 FFFF M dw 0xffff
00138 ENC_EOT
32C8 FFFF M dw 0xffff
00139 ENC_EOT
32CA FFFF M dw 0xffff
00140 ENC_EOT
32CC FFFF M dw 0xffff
00141 ENC_EOT
32CE FFFF M dw 0xffff
00142 ENC_EOT
32D0 FFFF M dw 0xffff
00143 ENC_EOT
32D2 FFFF M dw 0xffff
00144 ENC_EOT
32D4 FFFF M dw 0xffff
00145 ENC_EOT
32D6 FFFF M dw 0xffff
00146 ENC_EOT
32D8 FFFF M dw 0xffff
00147 ENC_EOT
32DA FFFF M dw 0xffff
00148 ENC_EOT
32DC FFFF M dw 0xffff
00149 ENC_EOT
32DE FFFF M dw 0xffff
00150
00151 ;; encoders 49-64
00152 ENC_EOT
32E0 FFFF M dw 0xffff
00153 ENC_EOT
32E2 FFFF M dw 0xffff
00154 ENC_EOT
32E4 FFFF M dw 0xffff
00155 ENC_EOT
32E6 FFFF M dw 0xffff
00156 ENC_EOT
32E8 FFFF M dw 0xffff
00157 ENC_EOT
32EA FFFF M dw 0xffff
00158 ENC_EOT
32EC FFFF M dw 0xffff
00159 ENC_EOT
32EE FFFF M dw 0xffff
00160 ENC_EOT
32F0 FFFF M dw 0xffff
00161 ENC_EOT
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 33
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
32F2 FFFF M dw 0xffff
00162 ENC_EOT
32F4 FFFF M dw 0xffff
00163 ENC_EOT
32F6 FFFF M dw 0xffff
00164 ENC_EOT
32F8 FFFF M dw 0xffff
00165 ENC_EOT
32FA FFFF M dw 0xffff
00166 ENC_EOT
32FC FFFF M dw 0xffff
00167 ENC_EOT
32FE FFFF M dw 0xffff
00168
00169
3300 00170 org 0x3300 ; never change the origin!
00040
00041 ;; ---[ Custom LCD driver ]---
00042 #include "app_lcd.inc"
00001 ; $Id: app_lcd.inc 69 2008-02-01 00:20:18Z tk $
00002 ;
00003 ; MIOS Custom LCD Driver Skeleton
00004 ;
00005 ; ==========================================================================
00006 ;
00007 ; Copyright 1998-2006 Thorsten Klose (tk@midibox.org)
00008 ; Licensed for personal non-commercial use only.
00009 ; All other rights reserved.
00010 ;
00011 ; ==========================================================================
00012
00013 ;; --------------------------------------------------------------------------
00014 ;; Following system variables are given by MIOS and can be directly
00015 ;; accessed by the driver. The addresses are defined in mios.h and
00016 ;; should not be changed
00017 ;;
00018 ;; MIOS_GLCD_BUFFER a 8 byte buffer for data transfers
00019 ;; MIOS_LCD_OPTION1 contains the first LCD option given by MIOS_LCD_TypeSet
00020 ;; MIOS_LCD_OPTION2 contains the second LCD option given by MIOS_LCD_TypeSet
00021 ;; MIOS_LCD_CURSOR_POS the current cursor pos of characters (GLCD: multiplied by width)
00022 ;; MIOS_GLCD_GCURSOR_X for GLCDs: the current X position of graphical cursor
00023 ;; MIOS_GLCD_GCURSOR_Y for GLCDs: the current Y position of graphical cursor
00024 ;; MIOS_GLCD_FONT_WIDTH for GLCDs: the fontwidth given by MIOS_GLCD_FontInit
00025 ;; MIOS_GLCD_FONT_HEIGHT for GLCDs: the fontheight given by MIOS_GLCD_FontInit
00026 ;; MIOS_GLCD_FONT_X0 for GLCDs: the first byte within a char entry
00027 ;; MIOS_GLCD_FONT_OFFSET for GLCDs: the byte offset between the characters
00028 ;; MIOS_GLCD_FONT_PTRL for GLCDs: pointer to the character table, low-byte
00029 ;; MIOS_GLCD_FONT_PTRH for GLCDs: pointer to the character table, high-byte
00030 ;; MIOS_LCD_TIMEOUT0 can be used for timeout loops
00031 ;; MIOS_LCD_TIMEOUT1 can be used for timeout loops
00032 ;; MIOS_GLCD_TMP1 can be used as temporary buffer
00033 ;; MIOS_GLCD_TMP2 can be used as temporary buffer
00034 ;; MIOS_GLCD_TMP3 can be used as temporary buffer
00035 ;; MIOS_GLCD_TMP4 can be used as temporary buffer
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 34
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00036 ;; MIOS_LCD_Y0_OFFSET Y0 offset of LCD
00037 ;; MIOS_LCD_Y1_OFFSET Y1 offset of LCD
00038 ;; MIOS_LCD_Y2_OFFSET Y2 offset of LCD
00039 ;; MIOS_LCD_Y3_OFFSET Y3 offset of LCD
00040 ;; MIOS_LCD_CURSOR_POS_REAL unmapped cursor position which has been set with MIOS_LCD_CursorSet
00041 ;;
00042 ;; Note: the addresses are located in an upper bank and therefore have to
00043 ;; be accessed with the BANKED flag. Also the BSR has to be justified
00044 ;; before using the registers
00045 ;; Example:
00046 ;; SET_BSR MIOS_LCD_OPTION1 ; sets BSR to the bank where MIOS_LCD_*
00047 ;; ; has been located. You don't need to
00048 ;; ; change the BSR for the other LCD registers
00049 ;; movf MIOS_LCD_OPTION1, W, BANKED ; get LCD option #1
00050 ;;
00051 ;; Important: to allow a proper interaction with MIOS applications, you are
00052 ;; only allowed to modify MIOS_PARAMETER[123], the mutliplication registers
00053 ;; and FSR1. You are not allowed to change TMP[1-5] or FSR0
00054 ;; if you need some temporary registers, use the given addresses above or
00055 ;; locate them to addresses which are not used by the application
00056 ;; --------------------------------------------------------------------------
00057
00058 ;; --------------------------------------------------------------------------
00059 ;; This function is called by MIOS when the custom LCD should be initialized
00060 ;; In: MIOS_LCD_OPTION1 - contains the first LCD option given by MIOS_LCD_TypeSet
00061 ;; MIOS_LCD_OPTION2 - contains the second LCD option given by MIOS_LCD_TypeSet
00062 ;; Out: -
00063 ;; --------------------------------------------------------------------------
3300 00064 USER_LCD_Init
3300 0012 00065 return
00066
00067 ;; --------------------------------------------------------------------------
00068 ;; This function is called by MIOS when the custom LCD should be cleared
00069 ;; In: MIOS_LCD_OPTION1 - contains the first LCD option given by MIOS_LCD_TypeSet
00070 ;; MIOS_LCD_OPTION2 - contains the second LCD option given by MIOS_LCD_TypeSet
00071 ;; Out: -
00072 ;; --------------------------------------------------------------------------
3302 00073 USER_LCD_Clear
3302 0012 00074 return
00075
00076 ;; --------------------------------------------------------------------------
00077 ;; This function is called by MIOS when the cursor should be changed
00078 ;; In: MIOS_LCD_OPTION1 - contains the first LCD option given by MIOS_LCD_TypeSet
00079 ;; MIOS_LCD_OPTION2 - contains the second LCD option given by MIOS_LCD_TypeSet
00080 ;; MIOS_GLCD_CURSOR_X - horizontal cursor position (for GLCDs)
00081 ;; MIOS_GLCD_CURSOR_X - vertical cursor position (for GLCDs)
00082 ;; MIOS_LCD_CURSOR - character cursor position (for CLCDs)
00083 ;; Out: -
00084 ;; --------------------------------------------------------------------------
3304 00085 USER_LCD_CursorSet
3304 0012 00086 return
00087
00088 ;; --------------------------------------------------------------------------
00089 ;; This function is called by MIOS when a character should be print
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 35
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00090 ;; In: WREG - character
00091 ;; all other MIOS_*LCD_* registers
00092 ;; Out: GLCDs should justify the X/Y cursor position
00093 ;; --------------------------------------------------------------------------
3306 00094 USER_LCD_PrintChar
3306 0012 00095 return
00096
00097 ;; --------------------------------------------------------------------------
00098 ;; FUNCTION: USER_LCD_Data
00099 ;; DESCRIPTION: sends a data value to the LCD display.<BR>
00100 ;; On CLCDs: branch directly to USER_LCD_PrintChar<BR>
00101 ;; On GLCDs: ignore this function!
00102 ;; IN: data which should be sent
00103 ;; OUT: -
00104 ;; NOTE: see the custom_lcd_example for further details
00105 ;; --------------------------------------------------------------------------
3308 00106 USER_LCD_Data
3308 0012 00107 return
00108
00109 ;; --------------------------------------------------------------------------
00110 ;; FUNCTION: USER_LCD_Cmd
00111 ;; DESCRIPTION: sends a command to the LCD display.<BR>
00112 ;; On CLCDs: use this function to decode the HD44780 commands if required<BR>
00113 ;; On GLCDs: ignore this function!
00114 ;; IN: command which should be sent
00115 ;; OUT: -
00116 ;; NOTE: see the custom_lcd_example for further details
00117 ;; --------------------------------------------------------------------------
330A 00118 USER_LCD_Cmd
330A 0012 00119 return
00120
00121 ;; --------------------------------------------------------------------------
00122 ;; FUNCTION: USER_LCD_SpecialCharInit
00123 ;; DESCRIPTION: see MIOS_CLCD_SpecialCharInit
00124 ;; IN: number of special character (0-7) in WREG
00125 ;; pointer to special char pattern in TBLPTR (consists of 8
00126 ;; entries for every character-line)
00127 ;; OUT: TBLPTR has to be set to next table entry (TBLPTR+=8)
00128 ;; NOTE: see the custom_lcd_example for further details
00129 ;; --------------------------------------------------------------------------
330C 00130 USER_LCD_SpecialCharInit
330C 0012 00131 return
00043
00044 ;; ==========================================================================
00045 ;; All MIOS hooks in one file
00046 ;; ==========================================================================
00047
00048 ;; --------------------------------------------------------------------------
00049 ;; This function is called by MIOS after startup to initialize the
00050 ;; application
00051 ;; --------------------------------------------------------------------------
330E 00052 USER_Init
00053 ;; initialize application specific variables
330E 6A10 00054 clrf TIA_STAT
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 36
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
3310 6A21 00055 clrf TIA_SYSEX_STATE
3312 6A22 00056 clrf TIA_SYSEX_ACTION
3314 6819 00057 setf TIA_BANKSTICK_CHK_CTR ; (we have to start with BS0 in TIA_BANK_CheckStick)
00058
00059 ;; initialize the timer for the TIA_SW handler
3316 0EFE 00060 movlw 8190 & 0xff ; every 819 us
3318 6E03 00061 movwf MIOS_PARAMETER1
331A 0E1F 00062 movlw 8190 >> 8
331C 6E04 00063 movwf MIOS_PARAMETER2
331E 0E00 00064 movlw 0x00 ; prescaler 1:1
3320 ECBC F016 00065 call MIOS_TIMER_Init
00066
00067 ;; initialize the MBHP_TIA module
3324 EC60 F01E 00068 call TIA_SR_Init
00069
00070
00071 ;; init patch
3328 6A13 00072 clrf TIA_PATCH
332A 6A14 00073 clrf TIA_PBANK
332C ECBD F01A 00074 call TIA_PATCH_Init
00075
00076
00077 ;; initialize the shift registers
3330 0E01 00078 movlw 0x01 ; use only first register (maximum would be 16!)
3332 EC78 F016 00079 call MIOS_SRIO_NumberSet
3336 0E01 00080 movlw 0x01 ; set update frequncy
3338 EC80 F016 00081 call MIOS_SRIO_UpdateFrqSet
333C 0E00 00082 movlw 0x00 ; disable touch sensor
333E EC7C F016 00083 call MIOS_SRIO_TS_SensitivitySet
00084
00085 #if TIA_LEDMTR_ENABLE
3342 EC49 F01A 00086 call TIA_LEDMTR_Init
00087 #endif
00088
00089 ;; initialize J5 for driving LEDs if enabled
00090 #if ENABLE_J5
00091 movlw 0x00
00092 call J5_IO_Init
00093 #endif
00094
00095 #if MIDI_RXTX_USE_IO
3346 ECFA F019 00096 call MIDI_RXTX_IO_Init
00097 #endif
00098
00099 #if ENABLE_AIN_LFO_WAVEFORM
00100 movlw 0x06 ; enable the first 6 analog inputs
00101 call MIOS_AIN_NumberSet
00102 call MIOS_AIN_UnMuxed ; not multiplexed
00103 movlw 0x03 ; 8 bit resolution
00104 #endif
00105
00106 ;; initialize the AOUT module
00107 ;call AOUT_Init
00108
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 37
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00109 ;; initialize the integrated MIDI merger
334A 0E00 00110 movlw MIOS_MIDI_MERGER_DISABLED ; should be disabled for a synthesizer
334C EC14 F016 00111 call MIOS_MIDI_MergerSet
00112
3350 0012 00113 return
00114
00115
00116
00117 ;; --------------------------------------------------------------------------
00118 ;; This function is called by MIOS in the mainloop when nothing else is to do
00119 ;; --------------------------------------------------------------------------
3352 00120 USER_Tick
00121
00122 ;; ---[ check BankStick status ]---
3352 ECBB F01B 00123 call TIA_BANK_CheckStick
00124
00125 ;; ---[ update AOUTs channels (if enabled) ]---
00126 ; IRQ_DISABLE
00127 ; call AOUT_Update
00128 ; IRQ_ENABLE
00129
00130 ;; ---[ call TIA shift register handler ]---
3356 EC64 F01E 00131 call TIA_SR_Handler
00132
00133 ;; ---[ handle with CC dump reuqests ]---
335A EC04 F02C 00134 call TIA_CCOUT_Handler
00135
00136
00137
335E 0012 00138 return
00139
00140
00141 ;; --------------------------------------------------------------------------
00142 ;; This function is periodically called by MIOS. The frequency has to be
00143 ;; initialized with MIOS_Timer_Set
00144 ;; Note that this is an interrupt service routine! Use FSR2 instead of FSR0
00145 ;; and IRQ_TMPx instead of TMPx -- and make the routine as fast as possible!
00146 ;; --------------------------------------------------------------------------
3360 00147 USER_Timer
00148
00149 ;; ---[ call Software TIA Handler ]---
3360 ECEB F01E 00150 call TIA_SW_Handler
00151
3364 0012 00152 return
00153
00154 ;; --------------------------------------------------------------------------
00155 ;; This function is called by MIOS when a debug command has been received
00156 ;; via SysEx
00157 ;; Input:
00158 ;; o WREG, MIOS_PARAMETER1, MIOS_PARAMETER2, MIOS_PARAMETER3 like
00159 ;; specified in the debug command
00160 ;; Output:
00161 ;; o return values WREG, MIOS_PARAMETER1, MIOS_PARAMETER2, MIOS_PARAMETER3
00162 ;; --------------------------------------------------------------------------
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 38
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
3366 00163 USER_MPROC_DebugTrigger
3366 0012 00164 return
00165
00166
00167 ;; --------------------------------------------------------------------------
00168 ;; This function is called by MIOS when the display content should be
00169 ;; initialized. Thats the case during startup and after a temporary message
00170 ;; has been printed on the screen
00171 ;; --------------------------------------------------------------------------
3368 00172 USER_DISPLAY_Init
3368 0012 00173 return
00174
00175 ;; --------------------------------------------------------------------------
00176 ;; This function is called in the mainloop when no temporary message is shown
00177 ;; on screen. Print the realtime messages here
00178 ;; --------------------------------------------------------------------------
336A 00179 USER_DISPLAY_Tick
00180 ;; call MIDI RxTx handler and exit
336A EC0E F01A 00181 call MIDI_RXTX_Handler
00182
00183 #if TIA_LEDMTR_ENABLE
336E EC4C F01A 00184 call TIA_LEDMTR_Handler
00185 #endif
00186
00187
00188
3372 0012 00189 return
00190
00191 ;; --------------------------------------------------------------------------
00192 ;; This function is called by MIOS when a complete MIDI event has been received
00193 ;; Input:
00194 ;; o first MIDI event byte in MIOS_PARAMETER1
00195 ;; o second MIDI event byte in MIOS_PARAMETER2
00196 ;; o third MIDI event byte in MIOS_PARAMETER3
00197 ;; --------------------------------------------------------------------------
3374 00198 USER_MPROC_NotifyReceivedEvent
00199 ;; branch to ReceiveEvent function of TIA synth
00200
3374 EFBE F024 00201 goto TIA_MIDI_NotifyReceivedEvent
00202
3378 0012 00203 return
00204
00205 ;; --------------------------------------------------------------------------
00206 ;; This function is called by MIOS when a MIDI event has been received
00207 ;; which has been specified in the CONFIG_MIDI_IN table
00208 ;; Input:
00209 ;; o number of entry in WREG
00210 ;; o first MIDI event byte in MIOS_PARAMETER1
00211 ;; o second MIDI event byte in MIOS_PARAMETER2
00212 ;; o third MIDI event byte in MIOS_PARAMETER3
00213 ;; --------------------------------------------------------------------------
337A 00214 USER_MPROC_NotifyFoundEvent
00215
337A 0012 00216 return
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 39
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00217
00218
00219 ;; --------------------------------------------------------------------------
00220 ;; This function is called by MIOS when a MIDI event has not been completly
00221 ;; received within 2 seconds
00222 ;; --------------------------------------------------------------------------
337C 00223 USER_MPROC_NotifyTimeout
00224 ;; -> jump to "ActionInvalid" for a proper reset of the sysex parser
337C EFC6 F026 00225 goto TIA_SYSEX_ActionInvalid
3380 0012 00226 return
00227
00228 ;; --------------------------------------------------------------------------
00229 ;; This function is called by MIOS when a MIDI byte has been received
00230 ;; Input:
00231 ;; o received MIDI byte in WREG and MIOS_PARAMETER1
00232 ;; --------------------------------------------------------------------------
3382 00233 USER_MPROC_NotifyReceivedByte
00234 ;; -> continue at TIA_MPROC_SysExCheck
3382 EFA6 F026 00235 goto TIA_SYSEX_SysExCheck
3386 0012 00236 return
00237
00238 ;; --------------------------------------------------------------------------
00239 ;; This function is called by MIOS before the transfer of a MIDI byte.
00240 ;; It can be used to monitor the Tx activity or to do any other actions
00241 ;; (e.g. to switch a pin for multiplexed MIDI Outs) before the byte will
00242 ;; be sent.
00243 ;; Note that this is an interrupt service routine! Use FSR2 instead of FSR0
00244 ;; and IRQ_TMPx instead of TMPx -- and make the routine as fast as possible!
00245 ;; Input:
00246 ;; o transmitted byte in WREG
00247 ;; --------------------------------------------------------------------------
3388 00248 USER_MIDI_NotifyTx
00249 ;; notify Tx event to MIDI_RXTX handler
3388 EF0A F01A 00250 goto MIDI_RXTX_NotifyTx
338C 0012 00251 return
00252
00253 ;; --------------------------------------------------------------------------
00254 ;; This function is called by MIOS when a MIDI byte has been received.
00255 ;; It can be used to monitor the Rx activity or to do any action - e.g.
00256 ;; to react on realtime events like MIDI clock (0xf8) with a minimum latency
00257 ;; Note that this is an interrupt service routine! Use FSR2 instead of FSR0
00258 ;; and IRQ_TMPx instead of TMPx -- and make the routine as fast as possible!
00259 ;; Input:
00260 ;; o received byte in WREG
00261 ;; --------------------------------------------------------------------------
338E 00262 USER_MIDI_NotifyRx
00263 ;; temporary save received byte in IRQ_TMP1
338E 6E0B 00264 movwf IRQ_TMP1
00265
00266 ;; if MIDI clock: notify clock
3390 EE21 F0F0 00267 lfsr FSR2, TIA_MIDI_SYNC
3394 0AF8 00268 xorlw 0xf8
3396 E103 00269 bnz USER_MIDI_NotifyRx_NoF8
3398 88DF 00270 bsf INDF2, TIA_MIDI_SYNC_F8
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 40
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
339A EFFD F019 00271 goto MIDI_RXTX_NotifyRx_BeatClk
339E 00272 USER_MIDI_NotifyRx_NoF8
00273 ;; if MIDI start: notify start
339E 500B 00274 movf IRQ_TMP1, W
33A0 0AFA 00275 xorlw 0xfa
33A2 E102 00276 bnz USER_MIDI_NotifyRx_NoFA
33A4 8ADF 00277 bsf INDF2, TIA_MIDI_SYNC_FA
33A6 6B69 00278 clrf MIDI_RXTX_BEAT_CTR
33A8 00279 USER_MIDI_NotifyRx_NoFA
00280
00281 ;; notify Rx event to MIDI_RXTX handler
33A8 EF06 F01A 00282 goto MIDI_RXTX_NotifyRx
00283
00284
33AC 0012 00285 return
00286
00287 ;; --------------------------------------------------------------------------
00288 ;; This function is called by MIOS when an button has been toggled
00289 ;; Input:
00290 ;; o Button number in WREG and MIOS_PARAMETER1
00291 ;; o Button value MIOS_PARAMETER2:
00292 ;; - 1 if button has been released (=5V)
00293 ;; - 0 if button has been pressed (=0V)
00294 ;; --------------------------------------------------------------------------
33AE 00295 USER_DIN_NotifyToggle
33AE 0012 00296 return
00297
00298
00299 ;; --------------------------------------------------------------------------
00300 ;; This function is called by MIOS when an encoder has been moved
00301 ;; Input:
00302 ;; o Encoder number in WREG and MIOS_PARAMETER1
00303 ;; o signed incrementer value in MIOS_PARAMETER2:
00304 ;; - is positive when encoder has been turned clockwise
00305 ;; - is negative when encoder has been turned counter clockwise
00306 ;; --------------------------------------------------------------------------
33B0 00307 USER_ENC_NotifyChange
33B0 0012 00308 return
00309
00310
00311 ;; --------------------------------------------------------------------------
00312 ;; This function is called by MIOS before the shift register are loaded
00313 ;; Note that this is an interrupt service routine! Use FSR2 instead of FSR0
00314 ;; and IRQ_TMPx instead of TMPx -- and make the routine as fast as possible
00315 ;; --------------------------------------------------------------------------
33B2 00316 USER_SR_Service_Prepare
33B2 0012 00317 return
00318
00319 ;; --------------------------------------------------------------------------
00320 ;; This function is called by MIOS after the shift register have been loaded
00321 ;; Note that this is an interrupt service routine! Use FSR2 instead of FSR0
00322 ;; and IRQ_TMPx instead of TMPx -- and make the routine as fast as possible
00323 ;; --------------------------------------------------------------------------
33B4 00324 USER_SR_Service_Finish
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 41
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
33B4 0012 00325 return
00326
00327 ;; --------------------------------------------------------------------------
00328 ;; This function is called by MIOS when a pot has been moved
00329 ;; Input:
00330 ;; o Pot number in WREG and MIOS_PARAMETER1
00331 ;; o LSB value in MIOS_PARAMETER2
00332 ;; o MSB value in MIOS_PARAMETER3
00333 ;; --------------------------------------------------------------------------
33B6 00334 USER_AIN_NotifyChange
33B6 0012 00335 return
00336
00337
00338 ;; ==========================================================================
00339 ;; Application code (see comments in files)
00340 ;; ==========================================================================
00341
00342 ;; ---[ modules from code library ]---
00343 ; override default pin definitions of AOUT driver
00344 ;#define AOUT_LAT_CS LATC ; The chip select pin CS#
00345 ;#define AOUT_TRIS_CS TRISC ; is connected to Port C.3
00346 ;#define AOUT_PIN_CS 3 ; (CANNOT be shared with other outputs!)
00347 ;
00348 ;#define AOUT_LAT_DIN LATC ; The data input pin DIN
00349 ;#define AOUT_TRIS_DIN TRISC ; is connected to Port C.1
00350 ;#define AOUT_PIN_DIN 1 ; (can be shared with other outputs)
00351 ;;
00352 ;#define AOUT_LAT_SCLK LATC ; The shift clock input pin SCLK
00353 ;#define AOUT_TRIS_SCLK TRISC ; is connected to Port C.0
00354 ;#define AOUT_PIN_SCLK 0 ; (can be shared with other outputs)
00355 ; include AOUT driver (located in $MIOS_PATH/modules/aout/)
00356 ;#include <aout.inc>
00357
00358 ;#define J5_IO_DONT_USE_INPUT_FUNCTIONS 1
00359 ;#include <j5_io.inc>
00360
00361 ;; ---[ reusable functions ]---
00362 #include "math_mul16_16.inc"
00001 ; $Id: math_mul16_16.inc 111 2008-02-22 00:41:21Z tk $
00002 ;; Multiply 16x16 bit routine from the PIC18F452 datasheet, Chapter 7.2 "8 X 8 HARDWARE MULTIPLIER, Operation"
00003
00004 ;; MUL_R_3:MUL_R_0 = MUL_A_H:MUL_A_L * MUL_B_H:MUL_B_L
00005 ;; = (MUL_A_H * MUL_B_H * 2^16) +
00006 ;; (MUL_A_H * MUL_B_L * 2^8) +
00007 ;; (MUL_A_L * MUL_B_H * 2^8) +
00008 ;; (MUL_A_L * MUL_B_L)
00009
33B8 00010 MATH_MUL16_16
00011 SET_BSR MUL_R_0
33B8 0101 M movlb HIGH(reg)
00012
33BA 51F8 00013 movf MUL_A_L, W
33BC 03FA 00014 mulwf MUL_B_L ; MUL_A_L * MUL_B_L -> PRODH:PRODL
33BE CFF4 F1FD 00015 movff PRODH, MUL_R_1
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 42
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
33C2 CFF3 F1FC 00016 movff PRODL, MUL_R_0
00017
33C6 51F9 00018 movf MUL_A_H, W
33C8 03FB 00019 mulwf MUL_B_H ; MUL_A_H * MUL_B_H -> PRODH:PRODL
33CA CFF4 F1FF 00020 movff PRODH, MUL_R_3
33CE CFF3 F1FE 00021 movff PRODL, MUL_R_2
00022
33D2 51F8 00023 movf MUL_A_L, W
33D4 03FB 00024 mulwf MUL_B_H ; MUL_A_L * MUL_B_H -> PRODH:PRODL
33D6 50F3 00025 movf PRODL, W
33D8 27FD 00026 addwf MUL_R_1, F ; Add cross
33DA 50F4 00027 movf PRODH, W ; products
33DC 23FE 00028 addwfc MUL_R_2, F
33DE 6AE8 00029 clrf WREG
33E0 23FF 00030 addwfc MUL_R_3, F
00031
33E2 51F9 00032 movf MUL_A_H, W
33E4 03FA 00033 mulwf MUL_B_L ; MUL_A_H * MUL_B_L -> PRODH:PRODL
33E6 50F3 00034 movf PRODL, W
33E8 27FD 00035 addwf MUL_R_1, F ; Add cross
33EA 50F4 00036 movf PRODH, W ; products
33EC 23FE 00037 addwfc MUL_R_2, F
33EE 6AE8 00038 clrf WREG
33F0 23FF 00039 addwfc MUL_R_3, F
00040
33F2 0012 00041 return
00363 #include "midi_rxtx.inc"
00001 ; $Id: midi_rxtx.inc bdupeyron.tech@gmail.com(Antichambre)
00002 ;
00003 ; This file includes helpful functions to monitor the MIDI Rx/Tx activity
00004 ;
00005 ; o MIDI_RXTX_NotifyRx: to be called when a MIDI byte has been received
00006 ; o MIDI_RXTX_NotifyTx: to be called when a MIDI byte has been sent
00007 ; o MIDI_RXTX_Handler: to be called from USER_SR_Service_Prepare
00008 ;
00009 ; See the function headers for further details
00010 ;
00011 ; Settings which can be modified:
00012 ;
00013 ; Number of update cycles (* 1mS) the LEDs will stay active on a Rx/Tx event
33F4 00014 #define MIDI_RXTX_LED_DELAY 15
00015 ; DOUT pin number of Rx LED
33F4 00016 #define MIDI_RXTX_RX_LED DEFAULT_MIDI_RX_LED
00017 ; DOUT pin number of Tx LED
33F4 00018 #define MIDI_RXTX_TX_LED DEFAULT_MIDI_TX_LED
00019 ;
00020 ; Following registers have to be located to free addresses in app_defines.h:
00021 ;
00022 ;MIDI_RXTX_RX_CTR EQU 0x019
00023 ;MIDI_RXTX_TX_CTR EQU 0x01a
00024 ;
00025 ; ==========================================================================
00026 ;
00027 ; Copyright 1998-2006 Thorsten Klose (tk@midibox.org)
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 43
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00028 ; Licensed for personal non-commercial use only.
00029 ; All other rights reserved.
00030 ;
00031 ; ==========================================================================
00032
00033 ;; --------------------------------------------------------------------------
00034 ;; FUNCTION: MIDI_RXTX_IO_Init
00035 ;; DESCRIPTION: this function has to be called from the USER_Init
00036 ;; only if Leds are assigned to IO pins
00037 ;; --------------------------------------------------------------------------
33F4 00038 MIDI_RXTX_IO_Init
00039 #if MIDI_RXTX_USE_IO
33F4 9C95 00040 bcf DEFAULT_MIDI_RX_TRIS, DEFAULT_MIDI_RX_PIN
33F6 9E95 00041 bcf DEFAULT_MIDI_TX_TRIS, DEFAULT_MIDI_TX_PIN
00042 #endif
33F8 0012 00043 return
00044
00045 ;; --------------------------------------------------------------------------
00046 ;; FUNCTION: MIDI_RXTX_NotifyRx_BeatClk
00047 ;; DESCRIPTION: this function has to be called from the USER_MIDI_NotifyRx
00048 ;; on F8 event
00049 ;; --------------------------------------------------------------------------
33FA 00050 MIDI_RXTX_NotifyRx_BeatClk
33FA 2B69 00051 incf MIDI_RXTX_BEAT_CTR, F
33FC 0E17 00052 movlw 0x17
33FE 6569 00053 cpfsgt MIDI_RXTX_BEAT_CTR, BANKED
00054 rgoto MIDI_RXTX_NotifyRx_BeatClk_End
3400 D004 M bra label
3402 6B69 00055 clrf MIDI_RXTX_BEAT_CTR
3404 0E0F 00056 movlw MIDI_RXTX_LED_DELAY
00057 SET_BSR MIDI_RXTX_RX_CTR
3406 0100 M movlb HIGH(reg)
3408 6F67 00058 movwf MIDI_RXTX_RX_CTR, BANKED
340A 00059 MIDI_RXTX_NotifyRx_BeatClk_End
340A 0012 00060 return
00061
00062 ;; --------------------------------------------------------------------------
00063 ;; FUNCTION: MIDI_RXTX_NotifyRx
00064 ;; DESCRIPTION: this function has to be called from the USER_MIDI_NotifyRx
00065 ;; hook when a MIDI event has been received to reload the RX counter
00066 ;; --------------------------------------------------------------------------
340C 00067 MIDI_RXTX_NotifyRx
340C 0E0F 00068 movlw MIDI_RXTX_LED_DELAY
00069 SET_BSR MIDI_RXTX_RX_CTR
340E 0100 M movlb HIGH(reg)
3410 6F67 00070 movwf MIDI_RXTX_RX_CTR, BANKED
3412 0012 00071 return
00072
00073 ;; --------------------------------------------------------------------------
00074 ;; FUNCTION: MIDI_RXTX_NotifyTx
00075 ;; DESCRIPTION: this function has to be called from the USER_MIDI_NotifyTx
00076 ;; hook when a MIDI event will be transmitted to reload the TX counter
00077 ;; --------------------------------------------------------------------------
3414 00078 MIDI_RXTX_NotifyTx
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 44
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
3414 0E0F 00079 movlw MIDI_RXTX_LED_DELAY
00080 SET_BSR MIDI_RXTX_TX_CTR
3416 0100 M movlb HIGH(reg)
3418 6F68 00081 movwf MIDI_RXTX_TX_CTR, BANKED
341A 0012 00082 return
00083
00084 ;; --------------------------------------------------------------------------
00085 ;; FUNCTION: MIDI_RXTX_Handler
00086 ;; DESCRIPTION: this function has to be called from the USER_SR_ServicePrpeare
00087 ;; hook, it decrements the Rx/Tx counters and sets the LEDs depending on the
00088 ;; counter values
00089 ;; --------------------------------------------------------------------------
341C 00090 MIDI_RXTX_Handler
00091 #if DEFAULT_MIDI_MONITOR_ENABLED == 1
00092 ;; Decrement Rx counter if != 0
00093 SET_BSR MIDI_RXTX_RX_CTR
341C 0100 M movlb HIGH(reg)
341E 5167 00094 movf MIDI_RXTX_RX_CTR, W, BANKED
3420 A4D8 00095 skpz
3422 0767 00096 decf MIDI_RXTX_RX_CTR, F, BANKED
00097
00098 ;; Decrement Tx counter if != 0
00099 SET_BSR MIDI_RXTX_TX_CTR
3424 0100 M movlb HIGH(reg)
3426 5168 00100 movf MIDI_RXTX_TX_CTR, W, BANKED
3428 A4D8 00101 skpz
342A 0768 00102 decf MIDI_RXTX_TX_CTR, F, BANKED
00103
00104 ;;
00105 ;; remove the code below if you don't want to use LEDs to
00106 ;; indicate the counter state
00107 ;;
00108
00109 ;; set the Rx LED depending on counter state
00110 SET_BSR MIDI_RXTX_RX_CTR
342C 0100 M movlb HIGH(reg)
342E 5167 00111 movf MIDI_RXTX_RX_CTR, W, BANKED
3430 A4D8 00112 skpz
3432 0E01 00113 movlw 0x01
3434 6E03 00114 movwf MIOS_PARAMETER1
00115
00116 #if MIDI_RXTX_USE_IO
3436 9C8C 00117 bcf DEFAULT_MIDI_RX_LAT, DEFAULT_MIDI_RX_PIN
3438 5003 00118 movf MIOS_PARAMETER1, W
343A A4D8 00119 skpz
343C 8C8C 00120 bsf DEFAULT_MIDI_RX_LAT, DEFAULT_MIDI_RX_PIN
00121 #else
00122 movlw MIDI_RXTX_RX_LED
00123 call MIOS_DOUT_PinSet
00124 #endif
00125
00126 ;; set the Tx LED depending on counter state
00127 SET_BSR MIDI_RXTX_TX_CTR
343E 0100 M movlb HIGH(reg)
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 45
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
3440 5168 00128 movf MIDI_RXTX_TX_CTR, W, BANKED
3442 A4D8 00129 skpz
3444 0E01 00130 movlw 0x01
3446 6E03 00131 movwf MIOS_PARAMETER1
00132
00133 #if MIDI_RXTX_USE_IO
3448 9E8C 00134 bcf DEFAULT_MIDI_TX_LAT, DEFAULT_MIDI_TX_PIN
344A 5003 00135 movf MIOS_PARAMETER1, W
344C A4D8 00136 skpz
344E 8E8C 00137 bsf DEFAULT_MIDI_TX_LAT, DEFAULT_MIDI_TX_PIN
00138 #else
00139 movlw MIDI_RXTX_TX_LED
00140 call MIOS_DOUT_PinSet
00141 #endif
00142 #endif
3450 0012 00143 return
00364 #include "special_characters.inc"
00001 ; $Id: special_characters.inc 125 2008-02-27 09:10:44Z nils $
00002 ;
00003 ; This file contains all special characters used by the application
00004 ;
00005 ; ==========================================================================
00006 ;
00007 ; Copyright 1998-2006 Thorsten Klose (tk@midibox.org)
00008 ; Licensed for personal non-commercial use only.
00009 ; All other rights reserved.
00010 ;
00011 ; ==========================================================================
00012
00013 ;; --------------------------------------------------------------------------
00014 ;; Table of special characters
00015 ;; NOTE: only seven characters are really used by the CS, the others can contain
00016 ;; random bitpatterns, therefore this table only contains 16 bytes
00017 ;; --------------------------------------------------------------------------
3452 00018 CS_MENU_SPECIAL_CHARS
00019 ;; due to an imperfection in the MPASM we have
00020 ;; to write two bytes in every line :-(
00021 ;; char #0: left-arrow
3452 0301 00022 db b'00000001', b'00000011'; 1st and 2nd line of special char
3454 0307 00023 db b'00000111', b'00000011'; 3rd and 4th line of special char
3456 0001 00024 db b'00000001', b'00000000'; 5th and 6th line of special char
3458 0000 00025 db b'00000000', b'00000000'; 7th and 8th line of special char
00026 ;; char #1: right-arrow
345A 0000 00027 db b'00000000', b'00000000'; 1st and 2nd line of special char
345C 1000 00028 db b'00000000', b'00010000'; 3rd and 4th line of special char
345E 1C18 00029 db b'00011000', b'00011100'; 5th and 6th line of special char
3460 1018 00030 db b'00011000', b'00010000'; 7th and 8th line of special char
00031 ;; char #2: inverted 1
3462 131B 00032 db b'00011011', b'00010011'; 1st and 2nd line of special char
3464 1B1B 00033 db b'00011011', b'00011011'; 3rd and 4th line of special char
3466 1B1B 00034 db b'00011011', b'00011011'; 5th and 6th line of special char
3468 1F11 00035 db b'00010001', b'00011111'; 7th and 8th line of special char
00036 ;; char #3: inverted 2
346A 0E11 00037 db b'00010001', b'00001110'; 1st and 2nd line of special char
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 46
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
346C 1D1E 00038 db b'00011110', b'00011101'; 3rd and 4th line of special char
346E 171B 00039 db b'00011011', b'00010111'; 5th and 6th line of special char
3470 1F00 00040 db b'00000000', b'00011111'; 7th and 8th line of special char
00041 ;; char #4: inverted 3
3472 1D00 00042 db b'00000000', b'00011101'; 1st and 2nd line of special char
3474 1D1B 00043 db b'00011011', b'00011101'; 3rd and 4th line of special char
3476 0E1E 00044 db b'00011110', b'00001110'; 5th and 6th line of special char
3478 1F11 00045 db b'00010001', b'00011111'; 7th and 8th line of special char
00046 ;; char #5: inverted 4
347A 191D 00047 db b'00011101', b'00011001'; 1st and 2nd line of special char
347C 0D15 00048 db b'00010101', b'00001101'; 3rd and 4th line of special char
347E 1D00 00049 db b'00000000', b'00011101'; 5th and 6th line of special char
3480 1F1D 00050 db b'00011101', b'00011111'; 7th and 8th line of special char
00051 ;; char #6: inverted '-'
3482 1F1F 00052 db b'00011111', b'00011111'; 1st and 2nd line of special char
3484 001F 00053 db b'00011111', b'00000000'; 3rd and 4th line of special char
3486 1F1F 00054 db b'00011111', b'00011111'; 5th and 6th line of special char
3488 1F1F 00055 db b'00011111', b'00011111'; 7th and 8th line of special char
00056 ;; char #7: left/right arrow
348A 0301 00057 db b'00000001', b'00000011'; line 1 / 2
348C 1307 00058 db b'00000111', b'00010011'; line 3 / 4
348E 1C19 00059 db b'00011001', b'00011100'; line 5 / 6
3490 1018 00060 db b'00011000', b'00010000'; line 7 / 8
00365
00366 ;; ---[ TIA kernel ]---
00367 #include "tia_led_meter.inc"
00001 ; $Id: tia_led_meter.inc bdupeyron.tech@gmail.com(Antichambre)
00002 ;
00003 ; MIDIbox TIA
00004 ; TIA Cartridge Led Meter Module
00005 ;
00006 ; ==========================================================================
00007 ;
00008 ; Copyright 1998-2006 Thorsten Klose (tk@midibox.org)
00009 ; Licensed for personal non-commercial use only.
00010 ; All other rights reserved.
00011 ;
00012 ; ==========================================================================
00013 ;
00014 ; define the pins to which the Leds Meters are connected
00015 ;
00016
00000007 00017 TIA_LEDMTR0 EQU 7
00000006 00018 TIA_LEDMTR1 EQU 6
00000005 00019 TIA_LEDMTR2 EQU 5
00000004 00020 TIA_LEDMTR3 EQU 4
00021
00000003 00022 TIA_LEDMTR4 EQU 3
00000002 00023 TIA_LEDMTR5 EQU 2
00000001 00024 TIA_LEDMTR6 EQU 1
00000000 00025 TIA_LEDMTR7 EQU 0
00026
00000000 00027 TIA_LEDMTR_AUDX_REQ EQU 0
00000001 00028 TIA_LEDMTR_TIA_MODE EQU 1 ;; Swith between Normal & Sampler Mode
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 47
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00029
00030 ;; --------------------------------------------------------------------------
00031 ;; Initialize the LEDMTR module
00032 ;; --------------------------------------------------------------------------
3492 00033 TIA_LEDMTR_Init
3492 6B6A 00034 clrf TIA_LEDMTR_STAT
3494 6B6B 00035 clrf TIA_LEDMTR_VALUE
3496 0012 00036 return
00037 ;; reset will be released with first call of TIA_SR_Handler
00038
00039 ;; --------------------------------------------------------------------------
00040 ;; LEDMTR module Handler
00041 ;; --------------------------------------------------------------------------
3498 00042 TIA_LEDMTR_Handler
00043 SET_BSR TIA_BASE ; prepare BSR for TIA register access
3498 0101 M movlb HIGH(reg)
00044 ;; Template run prioity
00045 BRA_IFCLR TIA_LEDMTR_STAT, TIA_LEDMTR_AUDX_REQ, ACCESS, TIA_LEDMTR_Handler_End
349A A06A M btfss reg, bit, reg_a
349C D021 M bra label
00046
349E 00047 TIA_LEDMTR_Handler_Meter_Norm
00048 ;;BRA_IFSET TIA_LEDMTR_STAT, TIA_LEDMTR_TIA_MODE, ACCESS, TIA_LEDMTR_Handler_Meter_Sampler
349E 916A 00049 bcf TIA_LEDMTR_STAT, TIA_LEDMTR_AUDX_REQ
00050
34A0 6B6B 00051 clrf TIA_LEDMTR_VALUE
34A2 0E01 00052 movlw 0x01
34A4 6104 00053 cpfslt TIA_AUDV0
34A6 8F6B 00054 bsf TIA_LEDMTR_VALUE, TIA_LEDMTR0
34A8 0E07 00055 movlw 0x07
34AA 6104 00056 cpfslt TIA_AUDV0
34AC 8D6B 00057 bsf TIA_LEDMTR_VALUE, TIA_LEDMTR1
34AE 0E0B 00058 movlw 0x0b
34B0 6104 00059 cpfslt TIA_AUDV0
34B2 8B6B 00060 bsf TIA_LEDMTR_VALUE, TIA_LEDMTR2
34B4 0E0E 00061 movlw 0x0e
34B6 6104 00062 cpfslt TIA_AUDV0
34B8 896B 00063 bsf TIA_LEDMTR_VALUE, TIA_LEDMTR3
00064
34BA 0E01 00065 movlw 0x01
34BC 6105 00066 cpfslt TIA_AUDV1
34BE 876B 00067 bsf TIA_LEDMTR_VALUE, TIA_LEDMTR4
34C0 0E07 00068 movlw 0x07
34C2 6105 00069 cpfslt TIA_AUDV1
34C4 856B 00070 bsf TIA_LEDMTR_VALUE, TIA_LEDMTR5
34C6 0E0B 00071 movlw 0x0b
34C8 6105 00072 cpfslt TIA_AUDV1
34CA 836B 00073 bsf TIA_LEDMTR_VALUE, TIA_LEDMTR6
34CC 0E0E 00074 movlw 0x0e
34CE 6105 00075 cpfslt TIA_AUDV1
34D0 816B 00076 bsf TIA_LEDMTR_VALUE, TIA_LEDMTR7
00077
34D2 516B 00078 movf TIA_LEDMTR_VALUE, W
34D4 6E03 00079 movwf MIOS_PARAMETER1
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 48
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00080 rgoto TIA_LEDMTR_Handler_Set
34D6 D001 M bra label
00081
34D8 00082 TIA_LEDMTR_Handler_Meter_Sampler
34D8 6A03 00083 clrf MIOS_PARAMETER1
00084 ; To Do
00085 ;;rgoto TIA_LEDMTR_Handler_Set
00086
34DA 00087 TIA_LEDMTR_Handler_Set
34DA 0E00 00088 movlw TIA_LEDMTR_REG
34DC EC68 F016 00089 call MIOS_DOUT_SRSet
00090
34E0 00091 TIA_LEDMTR_Handler_End
34E0 0012 00092 return
00093
00094 ;; --------------------------------------------------------------------------
00095 ;; TIA_LEDMTR Led Pattern orange to green
00096 ;; --------------------------------------------------------------------------
34E2 00097 TIA_LEDMTR_PlayFormat
34E2 D82D 00098 rcall TIA_LEDMTR_Player_Init
00099
34E4 00100 TIA_LEDMTR_PlayFormat_R
34E4 D82C 00101 rcall TIA_LEDMTR_Player_Init
34E6 0E11 00102 movlw 0x11
34E8 D83D 00103 rcall TIA_LEDMTR_Player_On_Wait01
34EA 0E03 00104 movlw 0x03
34EC D83E 00105 rcall TIA_LEDMTR_Wait
00106 rgoto TIA_LEDMTR_End
34EE D026 M bra label
00107
34F0 00108 TIA_LEDMTR_PlayFormat_O
34F0 D826 00109 rcall TIA_LEDMTR_Player_Init
34F2 0E33 00110 movlw 0x33
34F4 D837 00111 rcall TIA_LEDMTR_Player_On_Wait01
34F6 0E01 00112 movlw 0x01
34F8 D838 00113 rcall TIA_LEDMTR_Wait
00114 rgoto TIA_LEDMTR_End
34FA D020 M bra label
00115
34FC 00116 TIA_LEDMTR_PlayFormat_G1
34FC D820 00117 rcall TIA_LEDMTR_Player_Init
34FE 0E77 00118 movlw 0x77
3500 D831 00119 rcall TIA_LEDMTR_Player_On_Wait01
3502 0E03 00120 movlw 0x03
3504 D832 00121 rcall TIA_LEDMTR_Wait
00122 rgoto TIA_LEDMTR_End
3506 D01A M bra label
00123
3508 00124 TIA_LEDMTR_PlayFormat_G2
3508 D81A 00125 rcall TIA_LEDMTR_Player_Init
350A 0EFF 00126 movlw 0xff
350C D82B 00127 rcall TIA_LEDMTR_Player_On_Wait01
350E 0E03 00128 movlw 0x03
3510 D82C 00129 rcall TIA_LEDMTR_Wait
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 49
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00130 rgoto TIA_LEDMTR_End
3512 D014 M bra label
00131
00132 ;; --------------------------------------------------------------------------
00133 ;; TIA_LEDMTR Led Pattern orange to green
00134 ;; --------------------------------------------------------------------------
3514 00135 TIA_LEDMTR_PlayOtoG
3514 D814 00136 rcall TIA_LEDMTR_Player_Init
00137
3516 0E22 00138 movlw 0x22
3518 D825 00139 rcall TIA_LEDMTR_Player_On_Wait01
351A 0E03 00140 movlw 0x03
351C D826 00141 rcall TIA_LEDMTR_Wait
351E 0E44 00142 movlw 0x44
3520 D821 00143 rcall TIA_LEDMTR_Player_On_Wait01
3522 0E03 00144 movlw 0x03
3524 D822 00145 rcall TIA_LEDMTR_Wait
3526 0E88 00146 movlw 0x88
3528 D81D 00147 rcall TIA_LEDMTR_Player_On_Wait01
00148
00149 rgoto TIA_LEDMTR_End
352A D008 M bra label
00150
00151 ;; --------------------------------------------------------------------------
00152 ;; TIA_LEDMTR Led Pattern orange to red
00153 ;; --------------------------------------------------------------------------
352C 00154 TIA_LEDMTR_PlayOtoR
352C D808 00155 rcall TIA_LEDMTR_Player_Init
00156
352E 0E22 00157 movlw 0x22
3530 D819 00158 rcall TIA_LEDMTR_Player_On_Wait01
3532 0E03 00159 movlw 0x03
3534 D81A 00160 rcall TIA_LEDMTR_Wait
3536 0E11 00161 movlw 0x11
3538 D815 00162 rcall TIA_LEDMTR_Player_On_Wait01
00163
00164 rgoto TIA_LEDMTR_End
353A D000 M bra label
00165
00166
00167
00168 ;; --------------------------------------------------------------------------
00169 ;; TIA_LEDMTR End
00170 ;; --------------------------------------------------------------------------
353C 00171 TIA_LEDMTR_End
00172 ;bcf TIA_STAT, TIA_STAT_ENGINE_DISABLE; turn on TIA software synth part again
00173 ;goto TIA_PATCH_Init ; init patch and exit
353C 0012 00174 return
00175
00176
00177 ;; --------------------------------------------------------------------------
00178 ;; TIA_LEDMTR Initialization routine
00179 ;; --------------------------------------------------------------------------
353E 00180 TIA_LEDMTR_Player_Init
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 50
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
353E 8010 00181 bsf TIA_STAT, TIA_STAT_ENGINE_DISABLE; turn off TIA software synth part
00182
00183 SET_BSR TIA_BASE
3540 0101 M movlb HIGH(reg)
3542 6A03 00184 clrf MIOS_PARAMETER1
3544 0E00 00185 movlw TIA_LEDMTR_REG
3546 EC68 F016 00186 call MIOS_DOUT_SRSet
354A 0012 00187 return
00188 ;; --------------------------------------------------------------------------
00189 ;; TIA_LEDMTR a note (in: Note Number)
00190 ;; --------------------------------------------------------------------------
354C 00191 TIA_LEDMTR_Player_On
00192 SET_BSR TIA_BASE
354C 0101 M movlb HIGH(reg)
354E 6E03 00193 movwf MIOS_PARAMETER1
3550 0E00 00194 movlw TIA_LEDMTR_REG
3552 EC68 F016 00195 call MIOS_DOUT_SRSet
3556 0012 00196 return
00197
3558 00198 TIA_LEDMTR_Player_Off
00199 SET_BSR TIA_BASE
3558 0101 M movlb HIGH(reg)
355A 6A03 00200 clrf MIOS_PARAMETER1
355C 0E00 00201 movlw TIA_LEDMTR_REG
355E EC68 F016 00202 call MIOS_DOUT_SRSet
3562 0012 00203 return
00204
3564 00205 TIA_LEDMTR_Player_On_Wait01
3564 DFF3 00206 rcall TIA_LEDMTR_Player_On
3566 0E01 00207 movlw 0x01
00208 rgoto TIA_LEDMTR_Wait
3568 D000 M bra label
00209
00210
00211 ;; --------------------------------------------------------------------------
00212 ;; TIA_LEDMTR wait for a certain time and poll TIA_SR Handler
00213 ;; --------------------------------------------------------------------------
356A 00214 TIA_LEDMTR_Wait
356A 6E06 00215 movwf TMP1
356C 0004 00216 clrwdt
356E 00217 TIA_LEDMTR_WaitLoop
356E 0E0A 00218 movlw 10
3570 ECCE F016 00219 call MIOS_Delay
3574 2E06 00220 decfsz TMP1, F
00221 rgoto TIA_LEDMTR_WaitLoop
3576 D7FB M bra label
3578 0012 00222 return
00223
00368 #include "tia_patch.inc"
00001 ; $Id: tia_patch.inc bdupeyron.tech@gmail.com(Antichambre)
00002 ;
00003 ; TIA Patch routines
00004 ;
00005 ; ==========================================================================
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 51
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00006 ;
00007 ; Copyright 1998-2006 Thorsten Klose (tk@midibox.org)
00008 ; Licensed for personal non-commercial use only.
00009 ; All other rights reserved.
00010 ;
00011 ; ==========================================================================
00012
00013
00014 ;; --------------------------------------------------------------------------
00015 ;; Init Routine for patch parameters
00016 ;; Note that the MIDI events are initialized separately, this routine will
00017 ;; be called on power-on and after a new MIDI dump has been loaded
00018 ;; --------------------------------------------------------------------------
357A 00019 TIA_PATCH_Init
00020 ;; disable TIA engine
357A 8010 00021 bsf TIA_STAT, TIA_STAT_ENGINE_DISABLE
00022
00023 ;; clear the whole TIA SFR memory space
357C 0E00 00024 movlw ((TIA_SW_CLEAR_END-TIA_SW_CLEAR_BEGIN)+1) & 0xff
357E 6E06 00025 movwf TMP1
3580 EE01 F000 00026 lfsr FSR0, TIA_SW_CLEAR_BEGIN
3584 00027 TIA_PATCH_Init_ClearLoop
3584 6AEE 00028 clrf POSTINC0
3586 2E06 00029 decfsz TMP1, F
00030 rgoto TIA_PATCH_Init_ClearLoop
3588 D7FD M bra label
00031
00032 ;; fetch 128 TIA parameters from EEPROM
358A 6A06 00033 clrf TMP1
358C 0E00 00034 movlw EEPROM_PATCH & 0xff
358E 6EA9 00035 movwf EEADR
3590 0E00 00036 movlw (EEPROM_PATCH >> 8) & 0xff
3592 6EAA 00037 movwf EEADRH
3594 C014 F011 00038 movff TIA_PBANK, TIA_BANK
3598 C013 F012 00039 movff TIA_PATCH, TIA_PRESET
359C 00040 TIA_PATCH_InitEELoop
359C 5006 00041 movf TMP1, W
359E ECF5 F02C 00042 call TIA_SYSEX_TABLE_Get; get CC number
35A2 6E07 00043 movwf TMP2 ; temporary store number in TMP2
00044
35A4 C006 FFA9 00045 movff TMP1, EEADR ; read parameter from current TIA bank
35A8 EC51 F01B 00046 call TIA_BANK_Read
35AC 6E03 00047 movwf MIOS_PARAMETER1 ; store value in MIOS_PARAMETER1
00048
00049 ;; branch depending on TMP2[7..4]
00050 BRA_IFSET TMP2, 7, ACCESS, TIA_PATCH_InitEELoopS
35AE BE07 M btfsc reg, bit, reg_a
35B0 D004 M bra label
35B2 00051 TIA_PATCH_InitEELoopN
00052 ;; if TMP2[7] == 0, then set CC parameter
35B2 5007 00053 movf TMP2, W
35B4 EC67 F02A 00054 call TIA_CCIN_Set
00055 rgoto TIA_PATCH_InitEELoopC
35B8 D008 M bra label
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 52
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
35BA 00056 TIA_PATCH_InitEELoopS
00057 ;; if TMP2[7..4] == 9, then set split point
35BA 5007 00058 movf TMP2, W
35BC 0BF0 00059 andlw 0xf0
35BE 0A90 00060 xorlw 0x90
35C0 E104 00061 bnz TIA_PATCH_InitEELoopC
35C2 5007 00062 movf TMP2, W
35C4 D817 00063 rcall TIA_PATCH_GetSplitPointer
35C6 C003 FFE7 00064 movff MIOS_PARAMETER1, INDF1
35CA 00065 TIA_PATCH_InitEELoopC
00066
35CA 2A06 00067 incf TMP1, F ; increment CC counter, loop until 0x80
00068 BRA_IFCLR TMP1, 7, ACCESS, TIA_PATCH_InitEELoop
35CC AE06 M btfss reg, bit, reg_a
35CE D7E6 M bra label
00069
00070 ;; get and store the MIDI channels
35D0 0E7C 00071 movlw EEPROM_CFG_BASE & 0xff
35D2 6EA9 00072 movwf EEADR
35D4 ECB0 F016 00073 call MIOS_EEPROM_Read
35D8 CFE8 F160 00074 movff WREG, TIA_V2_BASE + TIA_Vx_MIDI_CHANNEL
35DC ECB0 F016 00075 call MIOS_EEPROM_Read
35E0 CFE8 F120 00076 movff WREG, TIA_V1_BASE + TIA_Vx_MIDI_CHANNEL
00077 ;; get and store the device ID
35E4 ECB0 F016 00078 call MIOS_EEPROM_Read
00079 #if AUTO_DEVICE_ID
00080 ;; if AUTO_ID enabled, derive the TIA device ID from the MIOS device ID instead
00081 call MIOS_MIDI_DeviceIDGet
00082 #endif
35E8 6E20 00083 movwf TIA_MIDI_DEVICE
00084
35EA ECB0 F016 00085 call MIOS_EEPROM_Read
00086 ;; Empty
00087
00088 ;; force a refresh of all registers
35EE 8210 00089 bsf TIA_STAT, TIA_STAT_FORCE_REFRESH
00090
00091 ;; enable TIA engine again
35F0 9010 00092 bcf TIA_STAT, TIA_STAT_ENGINE_DISABLE
00093
35F2 0012 00094 return
00095
00096
00097
00098 ;; --------------------------------------------------------------------------
00099 ;; This help routine returns the pointer to TIA_Vx_SPLIT_xxx depending
00100 ;; on WREG
00101 ;; OUT: pointer in FSR1
00102 ;; --------------------------------------------------------------------------
35F4 00103 TIA_PATCH_GetSplitPointer
35F4 EE11 F021 00104 lfsr FSR1, TIA_V1_BASE + TIA_Vx_SPLIT_LOWER
35F8 B0E8 00105 btfsc WREG, 0
35FA EE11 F022 00106 lfsr FSR1, TIA_V1_BASE + TIA_Vx_SPLIT_UPPER
00107
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 53
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
35FE 30E8 00108 rrf WREG, W
3600 0B01 00109 andlw 0x01
3602 0D40 00110 mullw TIA_Vx_RECORD_LEN
3604 50F3 00111 movf PRODL, W
3606 26E1 00112 addwf FSR1L, F
3608 0012 00113 return
00369 #include "tia_bank.inc"
00001 ; $Id: tia_bank.inc bdupeyron.tech@gmail.com(Antichambre)
00002 ;
00003 ; MIDIbox SID
00004 ; BankStick Handler
00005 ;
00006 ; (Bank Load/Store routines located in tia_pbank.inc and tia_ebank.inc)
00007 ;
00008 ; ==========================================================================
00009 ;
00010 ; Copyright 1998-2007 Thorsten Klose (tk@midibox.org)
00011 ; Licensed for personal non-commercial use only.
00012 ; All other rights reserved.
00013 ;
00014 ; ==========================================================================
00015
00016 ;; --------------------------------------------------------------------------
00017 ;; Writes data to EEPROM or BankStick
00018 ;; IN: Value in WREG, address offset in EEADR
00019 ;; OUT: increments address
00020 ;; --------------------------------------------------------------------------
360A 00021 TIA_BANK_Write
360A 6E11 00022 movwf TIA_BANK ; temporary save word in TIA_BANK
00023 ;; branch to internal patch if bankstick is not available or Patch is 0
360C D87F 00024 rcall TIA_BANK_GetBankStickAvailable
360E E00B 00025 bz TIA_BANK_WriteInternal
3610 5012 00026 movf TIA_PRESET, W
3612 E009 00027 bz TIA_BANK_WriteInternal
00028
00029 ;; test BS Size 64/128 Patchs,
00030 ;rcall TIA_BANK_GetBankStickSize
00031 ;bnz TIA_BANK_WriteBankStick
00032 ;; exit if patch exceeds 63
00033 ;btfsc TIA_PRESET, 6
00034 ;rgoto TIA_BANK_WriteInternal
00035
3614 00036 TIA_BANK_WriteBankStick ; BankStick write:
3614 0E00 00037 movlw 0x00
3616 0F00 00038 addlw DEFAULT_BS_READONLY ; exit if BS_READONLY
3618 E104 00039 bnz TIA_BANK_WriteBankStick_NOk
361A 00040 TIA_BANK_WriteBankStick_Ok
361A D859 00041 rcall TIA_BANK_SetBankStickAddress
361C 5005 00042 movf MIOS_PARAMETER3, W ; get byte from temp. register
361E ECBA F016 00043 call MIOS_BANKSTICK_Write ; write content
00044 ;; here we could add an error exception handler
3622 00045 TIA_BANK_WriteBankStick_NOk
3622 2AA9 00046 incf EEADR, F ; increment EEPROM address
00047 rgoto TIA_BANK_Write_End
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 54
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
3624 D00F M bra label
00048
3626 00049 TIA_BANK_WriteInternal
3626 0E00 00050 movlw 0x00
3628 0F01 00051 addlw DEFAULT_EE_READONLY ; exit if EE_READONLY
362A E009 00052 bz TIA_BANK_WriteInternal_Ok
362C 2AA9 00053 incf EEADR, F ; increment EEADR
00054 rgoto TIA_BANK_Write_End ; and goto end
362E D00A M bra label
00055 ;; don't write if address in range between 0x7c and 0x7f (used to save channel and device number)
00056 BRA_IFSET EEADR, 7, ACCESS, TIA_BANK_WriteInternal_Ok
3630 BEA9 M btfsc reg, bit, reg_a
3632 D005 M bra label
3634 0E7B 00057 movlw 0x7c-1
3636 64A9 00058 cpfsgt EEADR, ACCESS
00059 rgoto TIA_BANK_WriteInternal_Ok
3638 D002 M bra label
363A 2AA9 00060 incf EEADR, F ; increment EEADR
00061 rgoto TIA_BANK_Write_End ; and goto end
363C D003 M bra label
363E 00062 TIA_BANK_WriteInternal_Ok
363E 5005 00063 movf MIOS_PARAMETER3, W ; get byte from temp. register
3640 ECB2 F016 00064 call MIOS_EEPROM_Write ; write to EEPROM
00065 ;; here we could add an error exception handler
3644 00066 TIA_BANK_Write_End
00067 SET_BSR TIA_BASE ; fix BSR after a MIOS routine has been called
3644 0101 M movlb HIGH(reg)
3646 0012 00068 return
00069
00070 ;; --------------------------------------------------------------------------
00071 ;; Writes a page of 64 bytes to EEPROM or BankStick
00072 ;; IN: Value in FSR1 buffer, address offset in EEADR
00073 ;; OUT: increments address
00074 ;; --------------------------------------------------------------------------
3648 00075 TIA_BANK_WritePage
00076
00077 ;; align EEADR if necessary
3648 0EC0 00078 movlw 0xc0
364A 16A9 00079 andwf EEADR, F
00080
00081 ;; branch to internal patch if bankstick is not available or Patch is 0
364C 5012 00082 movf TIA_PRESET, W
364E E00F 00083 bz TIA_BANK_WritePageInternal
00084
3650 00085 TIA_BANK_WritePageBankStick ; BankStick write:
3650 0E00 00086 movlw 0x00
3652 0F00 00087 addlw DEFAULT_BS_READONLY ; exit if BS_READONLY
3654 E003 00088 bz TIA_BANK_WritePageBankStick_Ok
3656 00089 TIA_BANK_WritePageBankStick_ReadOnly
00090 ;; BS Read Only Error #0x02
3656 0E02 00091 movlw 0x02
3658 6E26 00092 movwf TIA_SYSEX_ERROR
00093 rgoto TIA_BANK_WritePageBankStick_End
365A D006 M bra label
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 55
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00094
365C 00095 TIA_BANK_WritePageBankStick_Ok
365C D838 00096 rcall TIA_BANK_SetBankStickAddress
00097 ;; buffer already prepared in FSR1
365E ECF2 F016 00098 call MIOS_BANKSTICK_WritePage ; write page
00099 ;; here we could add an error exception handler
3662 E002 00100 bz TIA_BANK_WritePageBankStick_End
00101 ;; BS WritePage Error #0x07
3664 0E07 00102 movlw 0x07
3666 6E26 00103 movwf TIA_SYSEX_ERROR
3668 00104 TIA_BANK_WritePageBankStick_End
3668 0E40 00105 movlw 0x40 ; increment EEPROM address by 0x40
366A 26A9 00106 addwf EEADR, F
00107 rgoto TIA_BANK_WritePage_End
366C D018 M bra label
00108
366E 00109 TIA_BANK_WritePageInternal
366E 6A12 00110 clrf TIA_PRESET
3670 0E00 00111 movlw 0x00
3672 0F01 00112 addlw DEFAULT_EE_READONLY ; exit if EE_READONLY
3674 E005 00113 bz TIA_BANK_WritePageInternalLoop
00114 ;; Internal EE Readonly Error #1
3676 0E01 00115 movlw 0x01
3678 6E26 00116 movwf TIA_SYSEX_ERROR
367A 0E40 00117 movlw 0x40
367C 26A9 00118 addwf EEADR, F ; increment EEADR
00119 rgoto TIA_BANK_WritePage_End ; and goto next
367E D00F M bra label
00120 ;; write 64 bytes
3680 00121 TIA_BANK_WritePageInternalLoop
00122 ;; don't write if address in range between 0x7c and 0x7f (used to save channel and device number)
00123 BRA_IFSET EEADR, 7, ACCESS, TIA_BANK_WritePageInternal_Ok
3680 BEA9 M btfsc reg, bit, reg_a
3682 D005 M bra label
3684 0E7B 00124 movlw 0x7c-1
3686 64A9 00125 cpfsgt EEADR, ACCESS
00126 rgoto TIA_BANK_WritePageInternal_Ok
3688 D002 M bra label
368A 2AA9 00127 incf EEADR, F ; increment EEADR
00128 rgoto TIA_BANK_WritePage_Next ; and goto next
368C D005 M bra label
368E 00129 TIA_BANK_WritePageInternal_Ok
368E 50A9 00130 movf EEADR, W
3690 0B3F 00131 andlw 0x3f
3692 50E3 00132 movf PLUSW1, W ; get byte from buffer
3694 ECB2 F016 00133 call MIOS_EEPROM_Write ; write to EEPROM
00134 ;; here we could add an error exception handler
3698 00135 TIA_BANK_WritePage_Next
3698 50A9 00136 movf EEADR, W
369A 0B3F 00137 andlw 0x3f
369C E1F1 00138 bnz TIA_BANK_WritePageInternalLoop
00139
369E 00140 TIA_BANK_WritePage_End
00141 SET_BSR TIA_BASE ; fix BSR after a MIOS routine has been called
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 56
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
369E 0101 M movlb HIGH(reg)
36A0 0012 00142 return
00143
00144
00145 ;; --------------------------------------------------------------------------
00146 ;; Read data from EEPROM or BankStick
00147 ;; IN: address offset in EEADR,
00148 ;; internal perset in EEADRH,
00149 ;; Patch number in MIOS_PARAMETER2,
00150 ;; Bank number in TIA_BANK.
00151 ;; OUT: 7-bit result in WREG, increments address
00152 ;; --------------------------------------------------------------------------
00153
36A2 00154 TIA_BANK_Read
00155 ;; branch to internal patch if bankstick is not available or Patch is 0
36A2 5011 00156 movf TIA_BANK, W
36A4 D82B 00157 rcall TIA_BANK_GetBankStickReady
36A6 E00B 00158 bz TIA_BANK_ReadInternal
36A8 5012 00159 movf TIA_PRESET, W
36AA E009 00160 bz TIA_BANK_ReadInternal
00161
36AC D834 00162 rcall TIA_BANK_GetBankStickSize
36AE E102 00163 bnz TIA_BANK_ReadBankStick
00164
36B0 BC12 00165 btfsc TIA_PRESET, 6
00166 rgoto TIA_BANK_Read_End
36B2 D008 M bra label
00167
36B4 00168 TIA_BANK_ReadBankStick ; BankStick read:
36B4 D80C 00169 rcall TIA_BANK_SetBankStickAddress
36B6 ECB8 F016 00170 call MIOS_BANKSTICK_Read ; read content
36BA 2AA9 00171 incf EEADR, F ; increment EEPROM address
00172 rgoto TIA_BANK_Read_End
36BC D003 M bra label
00173
36BE 00174 TIA_BANK_ReadInternal
36BE 6A12 00175 clrf TIA_PRESET
36C0 ECB0 F016 00176 call MIOS_EEPROM_Read
00177
36C4 00178 TIA_BANK_Read_End
00179 SET_BSR TIA_BASE ; fix BSR after a MIOS routine has been called
36C4 0101 M movlb HIGH(reg)
36C6 0012 00180 return
00181
00182
00183 ;; --------------------------------------------------------------------------
00184 ;; This function sets a BankStick address
00185 ;; IN: patch offset in EEADR
00186 ;; patch number in MIOS_PARAMETER2
00187 ;; BankStick number in TIA_BANK
00188 ;; OUT: address in MIOS_PARAMETER[12]
00189 ;; BankStick selected via MIOS_BANKSTICK_CtrlSet
00190 ;; --------------------------------------------------------------------------
36C8 00191 TIA_BANK_SetBankStickAddressMagic
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 57
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
36C8 6A03 00192 clrf MIOS_PARAMETER1
36CA 6A04 00193 clrf MIOS_PARAMETER2
00194 rgoto TIA_BANK_SetBankStickAddress_Cont
36CC D006 M bra label
00195
36CE 00196 TIA_BANK_SetBankStickAddress
00197
36CE CFA9 F003 00198 movff EEADR, MIOS_PARAMETER1 ; copy address to low-byte
36D2 B012 00199 btfsc TIA_PRESET, 0
36D4 8E03 00200 bsf MIOS_PARAMETER1, 7 ; select upper address range on odd bank number
36D6 4012 00201 rrncf TIA_PRESET, W ; high-byte
36D8 6E04 00202 movwf MIOS_PARAMETER2
00203
36DA 00204 TIA_BANK_SetBankStickAddress_Cont
36DA 501A 00205 movf TIA_BANKSTICK_ID, W
36DC ECEE F016 00206 call MIOS_BANKSTICK_CtrlSet
00207
36E0 D81A 00208 rcall TIA_BANK_GetBankStickSize
36E2 B4D8 00209 skpnz
00210 rgoto TIA_BANK_SetBankStickAddress_32k
36E4 D005 M bra label
00211
36E6 00212 TIA_BANK_SetBankStickAddress_64k
36E6 B011 00213 btfsc TIA_BANK, 0
36E8 8C04 00214 bsf MIOS_PARAMETER2, 6
36EA B211 00215 btfsc TIA_BANK, 1
36EC 8E04 00216 bsf MIOS_PARAMETER2, 7
00217 rgoto TIA_BANK_SetBankStickAddress_End
36EE D005 M bra label
00218
36F0 00219 TIA_BANK_SetBankStickAddress_32k
36F0 9A04 00220 bcf MIOS_PARAMETER2, 5
36F2 B011 00221 btfsc TIA_BANK, 0
36F4 8A04 00222 bsf MIOS_PARAMETER2, 5
36F6 B211 00223 btfsc TIA_BANK, 1
36F8 8C04 00224 bsf MIOS_PARAMETER2, 6
00225
36FA 00226 TIA_BANK_SetBankStickAddress_End
36FA 0012 00227 return
00228
00229
00230 ;; --------------------------------------------------------------------------
00231 ;; This function returns the bankstick available status for the current bank
00232 ;; IN: Bank number WREG
00233 ;; OUT: WREG != 0 when bankstick available
00234 ;; --------------------------------------------------------------------------
36FC 00235 TIA_BANK_GetBankStickReady
36FC 40E8 00236 rrncf WREG, W
36FE 40E8 00237 rrncf WREG, W
3700 0B07 00238 andlw 0x07
3702 6E1A 00239 movwf TIA_BANKSTICK_ID
3704 ECC6 F016 00240 call MIOS_HLP_GetBitORMask
3708 141B 00241 andwf TIA_BANKSTICK_RDY, W
370A 0012 00242 return
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 58
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00243
00244 ;; --------------------------------------------------------------------------
00245 ;; This function returns the bankstick available status for the current bank
00246 ;; IN: BankStick number in TIA_PBANK
00247 ;; OUT: WREG != 0 when bankstick available
00248 ;; --------------------------------------------------------------------------
370C 00249 TIA_BANK_GetBankStickAvailable
370C 501A 00250 movf TIA_BANKSTICK_ID, W
370E ECC6 F016 00251 call MIOS_HLP_GetBitORMask
3712 141C 00252 andwf TIA_BANKSTICK_STAT, W
3714 0012 00253 return
00254 ;; --------------------------------------------------------------------------
00255 ;; This function returns the bankstick available status for the current bank
00256 ;; IN: BankStick number in TIA_BANKSTICK_ID
00257 ;; OUT: BankStick size in WREG and TIA_BANKSTICK_SIZE
00258 ;; --------------------------------------------------------------------------
3716 00259 TIA_BANK_GetBankStickSize
3716 501A 00260 movf TIA_BANKSTICK_ID, W
3718 ECC6 F016 00261 call MIOS_HLP_GetBitORMask
371C 141D 00262 andwf TIA_BANKSTICK_SIZE, W
371E 0012 00263 return
00264
00265
00266
00267 ;; --------------------------------------------------------------------------
00268 ;; selects address of magic number depending on TIA_BANKSTICK_CHK_CTR
00269 ;; TIA_BANKSTICK_CHK_CTR or TIA_PBANK
00270 ;; --------------------------------------------------------------------------
3720 00271 TIA_BANK_CheckStick_SelectMagic
00272 ;; select BankStick depending on TIA_BANKSTICK_CHK_CTR
3720 6E05 00273 movwf MIOS_PARAMETER3
3722 40E8 00274 rrncf WREG, W
3724 40E8 00275 rrncf WREG, W
3726 0B07 00276 andlw 0x07
3728 0F80 00277 addlw 0x80 ; (Enable verify slower write accesses)
372A ECEE F016 00278 call MIOS_BANKSTICK_CtrlSet
00279
00280 ;; determine if this is a 64k BankStick:
00281 ;; read from address 0x8000, store value in PRODL
372E 0E0F 00282 movlw 0x0f ;; between 0x03 - 0x7f
3730 6E03 00283 movwf MIOS_PARAMETER1
3732 0E80 00284 movlw 0x80
3734 6E04 00285 movwf MIOS_PARAMETER2
3736 ECB8 F016 00286 call MIOS_BANKSTICK_Read
373A 6EF3 00287 movwf PRODL
00288
00289 ;; add 0x42 and write number to 0x0000
373C 0E0F 00290 movlw 0x0f ;; between 0x03 - 0x7f
373E 6E03 00291 movwf MIOS_PARAMETER1
3740 6A04 00292 clrf MIOS_PARAMETER2
3742 50F3 00293 movf PRODL, W
3744 0F42 00294 addlw 0x42
3746 ECBA F016 00295 call MIOS_BANKSTICK_Write
00296
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 59
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00297 ;; read again number from 0x8000, check if we still see the old value
374A 0E0F 00298 movlw 0x0f ;; between 0x03 - 0x7f
374C 6E03 00299 movwf MIOS_PARAMETER1
374E 0E80 00300 movlw 0x80
3750 6E04 00301 movwf MIOS_PARAMETER2
3752 ECB8 F016 00302 call MIOS_BANKSTICK_Read
3756 18F3 00303 xorwf PRODL, W
3758 E107 00304 bnz TIA_BANK_CheckStick_SelectMagic_32k
375A 00305 TIA_BANK_CheckStick_SelectMagic_64k ; (64k device)
00306 ;; try to read from BankStick (address 0x0000, 0x4000, 0x8000 or 0xc000)
375A 6A03 00307 clrf MIOS_PARAMETER1
375C 6A04 00308 clrf MIOS_PARAMETER2
375E B005 00309 btfsc MIOS_PARAMETER3, 0
3760 8C04 00310 bsf MIOS_PARAMETER2, 6
3762 B205 00311 btfsc MIOS_PARAMETER3, 1
3764 8E04 00312 bsf MIOS_PARAMETER2, 7
00313 rgoto TIA_BANK_CheckStick_SelectMagic_End
3766 D006 M bra label
00314
3768 00315 TIA_BANK_CheckStick_SelectMagic_32k ; (32k device)
00316 ;; try to read from BankStick (address 0x0000, 0x2000, 0x4000 or 0x0600)
3768 6A03 00317 clrf MIOS_PARAMETER1
376A 6A04 00318 clrf MIOS_PARAMETER2
376C B005 00319 btfsc MIOS_PARAMETER3, 0
376E 8A04 00320 bsf MIOS_PARAMETER2, 5
3770 B205 00321 btfsc MIOS_PARAMETER3, 1
3772 8C04 00322 bsf MIOS_PARAMETER2, 6
00323 ;; rgoto TIA_BANK_CheckStick_SelectMagic_End
3774 00324 TIA_BANK_CheckStick_SelectMagic_End
3774 0012 00325 return
00326
00327
00328
00329
00330
00331 ;; --------------------------------------------------------------------------
00332 ;; Check Stick: try to read from BankStick, clear the appr. flag in
00333 ;; TIA_BANKSTICK_STAT if BankStick not available
00334 ;; --------------------------------------------------------------------------
3776 00335 TIA_BANK_CheckStick
00336
00337 ;; increment check counter, wrap at 32
3776 2819 00338 incf TIA_BANKSTICK_CHK_CTR, W
3778 0B1F 00339 andlw 0x1f
377A 6E19 00340 movwf TIA_BANKSTICK_CHK_CTR
00341
377C 90D8 00342 clrc
377E 4019 00343 rrncf TIA_BANKSTICK_CHK_CTR, W
3780 40E8 00344 rrncf WREG, W
3782 0B07 00345 andlw 0x07
3784 6E1A 00346 movwf TIA_BANKSTICK_ID
00347
00348 ;; select "magic number" and try to read from BankStick
3786 5019 00349 movf TIA_BANKSTICK_CHK_CTR, W
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 60
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
3788 DFCB 00350 rcall TIA_BANK_CheckStick_SelectMagic
378A ECB8 F016 00351 call MIOS_BANKSTICK_Read
00352 ;; this sets the MIOS_BOX_STAT_BS_AVAILABLE flag
00353
00354 ;; save old BankStick status in TMP1
378E C01C F006 00355 movff TIA_BANKSTICK_STAT, TMP1
00356
00357 ;; modify the available flag of current bankstick
00358 BRA_IFSET MIOS_BOX_STAT, MIOS_BOX_STAT_BS_AVAILABLE, ACCESS, TIA_BANK_CheckStick_AccPassed
3792 B002 M btfsc reg, bit, reg_a
3794 D005 M bra label
3796 00359 TIA_BANK_CheckStick_AccFailed
3796 501A 00360 movf TIA_BANKSTICK_ID, W
3798 ECC4 F016 00361 call MIOS_HLP_GetBitANDMask
379C 141C 00362 andwf TIA_BANKSTICK_STAT, W
00363 rgoto TIA_BANK_CheckStick_AccCont
379E D004 M bra label
37A0 00364 TIA_BANK_CheckStick_AccPassed
37A0 501A 00365 movf TIA_BANKSTICK_ID, W
37A2 ECC6 F016 00366 call MIOS_HLP_GetBitORMask
37A6 101C 00367 iorwf TIA_BANKSTICK_STAT, W
37A8 00368 TIA_BANK_CheckStick_AccCont
37A8 6E07 00369 movwf TMP2
00370
00371 ;; check if flag has been changed
37AA 5007 00372 movf TMP2, W
37AC 1806 00373 xorwf TMP1, W
37AE E008 00374 bz TIA_BANK_CheckStick_End
37B0 8010 00375 bsf TIA_STAT, TIA_STAT_ENGINE_DISABLE, ACCESS
00376
00377 ;; flag changed - branch depending on available status
37B2 501A 00378 movf TIA_BANKSTICK_ID, W
37B4 ECC6 F016 00379 call MIOS_HLP_GetBitORMask
37B8 1407 00380 andwf TMP2, W
37BA E14A 00381 bnz TIA_BANK_CheckStick_Ext
00382 rgoto TIA_BANK_CheckStick_Int
37BC D002 M bra label
37BE 9010 00383 bcf TIA_STAT, TIA_STAT_ENGINE_DISABLE
37C0 00384 TIA_BANK_CheckStick_End
37C0 0012 00385 return
00386
00387
00388
00389
00390 ;; ------------------------------------------------------------------
00391 ;; --> Internal Patch
37C2 00392 TIA_BANK_CheckStick_Int
00393
00394 ;; reset size
37C2 5007 00395 movf TMP2, W
37C4 161D 00396 andwf TIA_BANKSTICK_SIZE, F
00397
37C6 00398 TIA_BANK_CheckStick_Int_StatOk
37C6 C007 F01C 00399 movff TMP2, TIA_BANKSTICK_STAT
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 61
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
37CA EC96 F01A 00400 call TIA_LEDMTR_PlayOtoR ;; play mled orange to red pattern
37CE ECC7 F01D 00401 call TIA_TUNE_PlayDisconnect ;; play tune 5
37D2 ECAC F01A 00402 call TIA_LEDMTR_Player_Off
00403
00404 ;; branch depending on patch/kit BankStick
00405 #if DEFAULT_BS_KBANK_ID >= 0 && DEFAULT_BS_KBANK_ID <= 7
37D6 0E04 00406 movlw DEFAULT_BS_KBANK_ID-1
37D8 641A 00407 cpfsgt TIA_BANKSTICK_ID, ACCESS
00408 rgoto TIA_BANK_CheckStick_Int_P
37DA D026 M bra label
37DC B219 00409 btfsc TIA_BANKSTICK_CHK_CTR, 1
00410 rgoto TIA_BANK_CheckStick_Int_WT
37DE D012 M bra label
00411
37E0 00412 TIA_BANK_CheckStick_Int_K
37E0 501A 00413 movf TIA_BANKSTICK_ID, W ;; clear flag
37E2 ECC4 F016 00414 call MIOS_HLP_GetBitANDMask
37E6 161B 00415 andwf TIA_BANKSTICK_RDY, F
37E8 0E05 00416 movlw 0x05 ;;send CFG_BSInfo ;; send sysex CFG BS infos
37EA 6E25 00417 movwf TIA_SYSEX_ADDRESS
37EC EC27 F029 00418 call _TIA_SYSEX_End_CFG_Read
37F0 5019 00419 movf TIA_BANKSTICK_CHK_CTR, W
37F2 1816 00420 xorwf TIA_KBANK, W
37F4 E12C 00421 bnz TIA_BANK_CheckStick_Int_End
37F6 6A16 00422 clrf TIA_KBANK ;; Reinit to...
37F8 6A15 00423 clrf TIA_KIT
37FA 0E0F 00424 movlw 0x0f ;; send sysex CFG All
37FC 6E25 00425 movwf TIA_SYSEX_ADDRESS
37FE EC27 F029 00426 call _TIA_SYSEX_End_CFG_Read ;; ...internal patch
00427 rgoto TIA_BANK_CheckStick_Int_End
3802 D025 M bra label
00428
3804 00429 TIA_BANK_CheckStick_Int_WT
3804 501A 00430 movf TIA_BANKSTICK_ID, W ;; clear flag
3806 ECC4 F016 00431 call MIOS_HLP_GetBitANDMask
380A 161B 00432 andwf TIA_BANKSTICK_RDY, F
380C 0E05 00433 movlw 0x05 ;;send CFG_BSInfo ;; send sysex CFG BS infos
380E 6E25 00434 movwf TIA_SYSEX_ADDRESS
3810 EC27 F029 00435 call _TIA_SYSEX_End_CFG_Read
3814 5019 00436 movf TIA_BANKSTICK_CHK_CTR, W
3816 1818 00437 xorwf TIA_WBANK, W
3818 E11A 00438 bnz TIA_BANK_CheckStick_Int_End
381A 6A18 00439 clrf TIA_WBANK ;; Reinit to...
381C 6A17 00440 clrf TIA_WT
381E 0E0F 00441 movlw 0x0f ;; send sysex CFG All
3820 6E25 00442 movwf TIA_SYSEX_ADDRESS
3822 EC27 F029 00443 call _TIA_SYSEX_End_CFG_Read ;; ...internal patch
00444 rgoto TIA_BANK_CheckStick_Int_End
3826 D013 M bra label
00445 #endif ;; DEFAULT_BS_KBANK_ID >= 0 && DEFAULT_BS_KBANK_ID <= 7
00446
3828 00447 TIA_BANK_CheckStick_Int_P
3828 501A 00448 movf TIA_BANKSTICK_ID, W ;; clear flag
382A ECC4 F016 00449 call MIOS_HLP_GetBitANDMask
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 62
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
382E 161B 00450 andwf TIA_BANKSTICK_RDY, F
3830 0E05 00451 movlw 0x05 ;;send CFG_BSInfo ;; send sysex CFG BS infos
3832 6E25 00452 movwf TIA_SYSEX_ADDRESS
3834 EC27 F029 00453 call _TIA_SYSEX_End_CFG_Read
3838 5019 00454 movf TIA_BANKSTICK_CHK_CTR, W
383A 1814 00455 xorwf TIA_PBANK, W
383C E108 00456 bnz TIA_BANK_CheckStick_Int_End
383E 6A14 00457 clrf TIA_PBANK ;; Reinit to...
3840 6A13 00458 clrf TIA_PATCH
3842 0E0F 00459 movlw 0x0f ;; send sysex CFG All
3844 6E25 00460 movwf TIA_SYSEX_ADDRESS
3846 EC27 F029 00461 call _TIA_SYSEX_End_CFG_Read ;; ...internal patch
384A ECBD F01A 00462 call TIA_PATCH_Init
00463 ;;rgoto TIA_BANK_CheckStick_Int_End
00464
384E 00465 TIA_BANK_CheckStick_Int_End
384E 0012 00466 return
00467
00468
00469 ;; ------------------------------------------------------------------
00470 ;; --> External Patch
3850 00471 TIA_BANK_CheckStick_Ext
00472 ;; TABLE_ADDR TEXT_EXTBANK_0 ; print message
00473 ;; call MIOS_LCD_PrintMessage
00474 ;; call MIOS_LCD_PrintMessage
00475
00476 ;; new setup will be reloaded automatically
00477 ;; set reinit counter - CS configuration will be restored after one second
00478 ;movlw 10
00479 ;movwf CS_MENU_REINIT_CFG_CTR
00480
00481 ;; now check if the magic numbers exist in bankstick bank - if not, format bank automatically
3850 0E32 00482 movlw 50 ; wait some ms to get a stable status
3852 ECCE F016 00483 call MIOS_Delay
00484
3856 5019 00485 movf TIA_BANKSTICK_CHK_CTR, W
3858 DF63 00486 rcall TIA_BANK_CheckStick_SelectMagic
385A ECB8 F016 00487 call MIOS_BANKSTICK_Read
385E 0A83 00488 xorlw BANKSTICK_MAGIC0 ; branch to unformatted message if number not equal
3860 A4D8 00489 skpz
00490 rgoto TIA_BANK_CheckStick_Unformatted
3862 D064 M bra label
00491
00492 ;; magic numbers are different between Patch/Kit-WT bankstick
00493 #if DEFAULT_BS_KBANK_ID >= 0 && DEFAULT_BS_KBANK_ID <= 7
3864 0E04 00494 movlw DEFAULT_BS_KBANK_ID-1
3866 641A 00495 cpfsgt TIA_BANKSTICK_ID, ACCESS
00496 rgoto TIA_BANK_CheckStick_Ext_P
3868 D011 M bra label
00497
00498 ;; Kit / Wavetable
386A 00499 TIA_BANK_CheckStick_Ext_K
00500 ;; Magic ( Kit suite)
00501 ;; set bankstick type depending on second byte (BANKSTICK_MAGICK/P)
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 63
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
386A ECB8 F016 00502 call MIOS_BANKSTICK_Read
386E 6E06 00503 movwf TMP1
3870 0A13 00504 xorlw BANKSTICK_MAGICK
3872 E009 00505 bz TIA_BANK_CheckStrick_Ext_Type_K
3874 00506 TIA_BANK_CheckStrick_Ext_Type_NotK
3874 5006 00507 movf TMP1, W
3876 0A12 00508 xorlw BANKSTICK_MAGICP
3878 A4D8 00509 skpz
00510 rgoto TIA_BANK_CheckStick_Unformatted ;; format
387A D058 M bra label
387C 0E01 00511 movlw DEFAULT_BS_FPROTECT ;; type format protection
387E 0A01 00512 xorlw 0x01
3880 B4D8 00513 skpnz
00514 rgoto TIA_BANK_CheckStick_Unformatted_TProtect ;; exit
3882 D060 M bra label
00515 rgoto TIA_BANK_CheckStick_Unformatted ;; format
3884 D053 M bra label
3886 00516 TIA_BANK_CheckStrick_Ext_Type_K
3886 0E13 00517 movlw BANKSTICK_MAGICK ;; valid type
3888 6E06 00518 movwf TMP1
00519 rgoto TIA_BANK_CheckStick_Ext_Size
388A D010 M bra label
00520 #endif ;; DEFAULT_BS_KBANK_ID >= 0 && DEFAULT_BS_KBANK_ID <= 7
00521
00522 ;; Patch
388C 00523 TIA_BANK_CheckStick_Ext_P
00524 ;; Magic (Patch suite)
00525 ;; set bankstick type depending on second byte (BANKSTICK_MAGICK/P)
388C ECB8 F016 00526 call MIOS_BANKSTICK_Read
3890 6E06 00527 movwf TMP1
3892 0A12 00528 xorlw BANKSTICK_MAGICP
3894 E009 00529 bz TIA_BANK_CheckStrick_Ext_Type_P
3896 00530 TIA_BANK_CheckStrick_Ext_Type_NotP
3896 5006 00531 movf TMP1, W
3898 0A13 00532 xorlw BANKSTICK_MAGICK
389A A4D8 00533 skpz
00534 rgoto TIA_BANK_CheckStick_Unformatted ;; format
389C D047 M bra label
389E 0E01 00535 movlw DEFAULT_BS_FPROTECT ;; type format protection
38A0 0A01 00536 xorlw 0x01
38A2 B4D8 00537 skpnz
00538 rgoto TIA_BANK_CheckStick_Unformatted_TProtect ;; exit
38A4 D04F M bra label
00539 rgoto TIA_BANK_CheckStick_Unformatted ;; format
38A6 D042 M bra label
38A8 00540 TIA_BANK_CheckStrick_Ext_Type_P ;; valid type
38A8 0E12 00541 movlw BANKSTICK_MAGICP
38AA 6E06 00542 movwf TMP1
00543 ;;rgoto TIA_BANK_CheckStick_Ext_Size
00544
38AC 00545 TIA_BANK_CheckStick_Ext_Size
00546 ;; set bankstick size depending on third byte (32=32k, 64=64k)
38AC 501A 00547 movf TIA_BANKSTICK_ID, W
38AE ECC4 F016 00548 call MIOS_HLP_GetBitANDMask
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 64
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
38B2 161D 00549 andwf TIA_BANKSTICK_SIZE, F ;; clear size
38B4 ECB8 F016 00550 call MIOS_BANKSTICK_Read
38B8 0A40 00551 xorlw 64
38BA E104 00552 bnz TIA_BANK_CheckStrick_Ext_Not64k
38BC 00553 TIA_BANK_CheckStrick_Ext_64k
38BC 501A 00554 movf TIA_BANKSTICK_ID, W
38BE ECC6 F016 00555 call MIOS_HLP_GetBitORMask
38C2 121D 00556 iorwf TIA_BANKSTICK_SIZE, F ;; set size
38C4 00557 TIA_BANK_CheckStrick_Ext_Not64k
00558
38C4 00559 TIA_BANK_CheckStick_Ext_Fix ; to do if necessary...
00560 ;; fix patches if required (and enabled via ENABLE_PATCH_FIXING)
00561 ;movff TIA_BANKSTICK_CHK_CTR, TIA_PBANK
00562 ;rcall TIA_BANK_FixPatches
00563 ;; ok
00564
38C4 00565 TIA_BANK_CheckStick_Ext_Stat
00566
38C4 5019 00567 movf TIA_BANKSTICK_CHK_CTR, W
00568
38C6 5019 00569 movf TIA_BANKSTICK_CHK_CTR, W ;; test 1st bank of current BS
38C8 0B1C 00570 andlw 0x1c
38CA DF2A 00571 rcall TIA_BANK_CheckStick_SelectMagic
38CC ECB8 F016 00572 call MIOS_BANKSTICK_Read ;; read first byte from BankStick (magic0)
38D0 0A83 00573 xorlw BANKSTICK_MAGIC0 ;; branch to unformatted message if number not equal
38D2 E12B 00574 bnz TIA_BANK_CheckStick_Ext_Stat_NotOk
38D4 ECB8 F016 00575 call MIOS_BANKSTICK_Read ;; read second byte from BankStick (magicPK)
38D8 1806 00576 xorwf TMP1, W ;; branch to unformatted message if number not equal
38DA E127 00577 bnz TIA_BANK_CheckStick_Ext_Stat_NotOk
00578
38DC 5019 00579 movf TIA_BANKSTICK_CHK_CTR, W ;; test 2nd bank of current BS
38DE 0B1C 00580 andlw 0x1c
38E0 0F01 00581 addlw 0x01
38E2 DF1E 00582 rcall TIA_BANK_CheckStick_SelectMagic
38E4 ECB8 F016 00583 call MIOS_BANKSTICK_Read ;; read first byte from BankStick (magic0)
38E8 0A83 00584 xorlw BANKSTICK_MAGIC0 ;; branch to unformatted message if number not equal
38EA E11F 00585 bnz TIA_BANK_CheckStick_Ext_Stat_NotOk
38EC ECB8 F016 00586 call MIOS_BANKSTICK_Read ;; read second byte from BankStick (magicPK)
38F0 1806 00587 xorwf TMP1, W ;; branch to unformatted message if number not equal
38F2 E11B 00588 bnz TIA_BANK_CheckStick_Ext_Stat_NotOk
00589
38F4 5019 00590 movf TIA_BANKSTICK_CHK_CTR, W ;; test 3rd bank of current BS
38F6 0B1C 00591 andlw 0x1c
38F8 0F02 00592 addlw 0x02
38FA DF12 00593 rcall TIA_BANK_CheckStick_SelectMagic
38FC ECB8 F016 00594 call MIOS_BANKSTICK_Read ;; read first byte from BankStick (magic0)
3900 0A83 00595 xorlw BANKSTICK_MAGIC0 ;; branch to unformatted message if number not equal
3902 E113 00596 bnz TIA_BANK_CheckStick_Ext_Stat_NotOk
3904 ECB8 F016 00597 call MIOS_BANKSTICK_Read ;; read second byte from BankStick (magicPK)
3908 1806 00598 xorwf TMP1, W ;; branch to unformatted message if number not equal
390A E10F 00599 bnz TIA_BANK_CheckStick_Ext_Stat_NotOk
00600
390C 5019 00601 movf TIA_BANKSTICK_CHK_CTR, W ;; test 4th bank of current BS
390E 0B1C 00602 andlw 0x1c
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 65
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
3910 0F03 00603 addlw 0x03
3912 DF06 00604 rcall TIA_BANK_CheckStick_SelectMagic
3914 ECB8 F016 00605 call MIOS_BANKSTICK_Read ;; read first byte from BankStick (magic0)
3918 0A83 00606 xorlw BANKSTICK_MAGIC0 ;; branch to unformatted message if number not equal
391A E107 00607 bnz TIA_BANK_CheckStick_Ext_Stat_NotOk
391C ECB8 F016 00608 call MIOS_BANKSTICK_Read ;; read second byte from BankStick (magicPK)
3920 1806 00609 xorwf TMP1, W ;; branch to unformatted message if number not equal
3922 E103 00610 bnz TIA_BANK_CheckStick_Ext_Stat_NotOk
00611
3924 00612 TIA_BANK_CheckStick_Ext_Stat_Ok
3924 C007 F01C 00613 movff TMP2, TIA_BANKSTICK_STAT ;; status is set
00614 rgoto TIA_BANK_CheckStick_Ext_ReadySet
3928 D02A M bra label
392A 00615 TIA_BANK_CheckStick_Ext_Stat_NotOk ;; status not ready
00616 rgoto TIA_BANK_CheckStick_Ext_End ;; end
392A D038 M bra label
00617
392C 00618 TIA_BANK_CheckStick_Unformatted
392C 0E01 00619 movlw DEFAULT_BS_FPROTECT ;; BS format inhibit
392E 0A02 00620 xorlw 0x02
3930 E006 00621 bz TIA_BANK_CheckStick_Unformatted_FProtect
00622
3932 C019 F011 00623 movff TIA_BANKSTICK_CHK_CTR, TIA_BANK
3936 D854 00624 rcall TIA_BANK_FormatStick ;; --> format bankstick
3938 C011 F019 00625 movff TIA_BANK, TIA_BANKSTICK_CHK_CTR
00626 rgoto TIA_BANK_CheckStick_Ext_End ;; end
393C D02F M bra label
00627
393E 00628 TIA_BANK_CheckStick_Unformatted_FProtect
393E C007 F01C 00629 movff TMP2, TIA_BANKSTICK_STAT ;; status is set
00630 rgoto TIA_BANK_CheckStick_Ext_ReadyClr
3942 D003 M bra label
00631
3944 00632 TIA_BANK_CheckStick_Unformatted_TProtect
3944 C007 F01C 00633 movff TMP2, TIA_BANKSTICK_STAT ;; status is set
00634 rgoto TIA_BANK_CheckStick_Ext_ReadyClr
3948 D000 M bra label
00635
394A 00636 TIA_BANK_CheckStick_Ext_ReadyClr
394A 501A 00637 movf TIA_BANKSTICK_ID, W ;; clear flag
394C ECC4 F016 00638 call MIOS_HLP_GetBitANDMask
3950 161B 00639 andwf TIA_BANKSTICK_RDY, F
3952 EC96 F01A 00640 call TIA_LEDMTR_PlayOtoR ;; play mled orange to red pattern
3956 ECF3 F01D 00641 call TIA_TUNE_PlayWrong ;; play wrong tune
395A ECAC F01A 00642 call TIA_LEDMTR_Player_Off
395E 0E05 00643 movlw 0x05 ;;send CFG_BSInfo ;; send sysex CFG BS infos
3960 6E25 00644 movwf TIA_SYSEX_ADDRESS
3962 EC27 F029 00645 call _TIA_SYSEX_End_CFG_Read
3966 5019 00646 movf TIA_BANKSTICK_CHK_CTR, W
3968 1814 00647 xorwf TIA_PBANK, W
396A E118 00648 bnz TIA_BANK_CheckStick_Ext_End
396C 6A14 00649 clrf TIA_PBANK ;; Reinit to...
396E 6A12 00650 clrf TIA_PRESET
3970 0E0F 00651 movlw 0x0f ;; send sysex CFG All
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 66
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
3972 6E25 00652 movwf TIA_SYSEX_ADDRESS
3974 EC27 F029 00653 call _TIA_SYSEX_End_CFG_Read ;; ...internal patch
3978 9010 00654 bcf TIA_STAT, TIA_STAT_ENGINE_DISABLE
397A EFBD F01A 00655 goto TIA_PATCH_Init
00656 ;;rgoto TIA_BANK_CheckStick_Ext_End
00657
397E 00658 TIA_BANK_CheckStick_Ext_ReadySet
397E 501A 00659 movf TIA_BANKSTICK_ID, W ;; set flag
3980 ECC6 F016 00660 call MIOS_HLP_GetBitORMask
3984 121B 00661 iorwf TIA_BANKSTICK_RDY, F
3986 EC8A F01A 00662 call TIA_LEDMTR_PlayOtoG ;; play mled orange to green pattern
398A ECDD F01D 00663 call TIA_TUNE_PlayOk ;; play ready tune
398E ECAC F01A 00664 call TIA_LEDMTR_Player_Off
3992 0E05 00665 movlw 0x05 ;;send CFG_BSInfo ;; send sysex CFG BS infos
3994 6E25 00666 movwf TIA_SYSEX_ADDRESS
3996 EC27 F029 00667 call _TIA_SYSEX_End_CFG_Read
399A 9010 00668 bcf TIA_STAT, TIA_STAT_ENGINE_DISABLE
00669 ;;rgoto TIA_BANK_CheckStick_Ext_End
00670
399C 00671 TIA_BANK_CheckStick_Ext_End
399C 0012 00672 return
00673
00674
00675
00676 ;; --------------------------------------------------------------------------
00677 ;; Format Stick: copy the lead default patch into the currently selected BankStick Bank
00678 ;; IN: bank number in TIA_PBANK
00679 ;; --------------------------------------------------------------------------
399E 00680 TEXT_FORMATBANK_0 STRING 20, 0x00, "* Formatting xxk * "
399E 1400 202A M da ((length) << 8) | (pos), str
6F46 6D72
7461 6974
676E 7820
6B78 2A20
2020
39B4 00681 TEXT_FORMATBANK_1 STRING 20, 0x40, "* Patch x 0 * "
39B4 1440 202A M da ((length) << 8) | (pos), str
6150 6374
2068 2078
3020 2020
2020 2A20
2020
39CA 00682 TEXT_FORMATBANK_K STRING 20, 0x40, "* Ensemble 000 * "
39CA 1440 202A M da ((length) << 8) | (pos), str
6E45 6573
626D 656C
3020 3030
2020 2A20
2020
00683
39E0 00684 TIA_BANK_FormatStick
00685 ;; select BankStick depending on TIA_BANKSTICK_CHK_CTR
39E0 4011 00686 rrncf TIA_BANK, W
39E2 40E8 00687 rrncf WREG, W
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 67
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
39E4 0B07 00688 andlw 0x07
39E6 6E1A 00689 movwf TIA_BANKSTICK_ID
39E8 ECEE F016 00690 call MIOS_BANKSTICK_CtrlSet
00691
39EC EC72 F01A 00692 call TIA_LEDMTR_PlayFormat_R
00693
00694 ;; determine if this is a 64k BankStick:
00695 ;; read from address 0x8000, store value in PRODL
39F0 0E0F 00696 movlw 0x0f ;; between 0x03 - 0x7f
39F2 6E03 00697 movwf MIOS_PARAMETER1
39F4 0E80 00698 movlw 0x80
39F6 6E04 00699 movwf MIOS_PARAMETER2
39F8 ECB8 F016 00700 call MIOS_BANKSTICK_Read
39FC 6EF3 00701 movwf PRODL
00702
00703 ;; add 0x42 and write number to 0x0000
39FE 0E0F 00704 movlw 0x0f ;; between 0x03 - 0x7f
3A00 6E03 00705 movwf MIOS_PARAMETER1
3A02 6A04 00706 clrf MIOS_PARAMETER2
3A04 50F3 00707 movf PRODL, W
3A06 0F42 00708 addlw 0x42
3A08 ECBA F016 00709 call MIOS_BANKSTICK_Write
3A0C A4D8 00710 skpz
00711 rgoto TIA_BANK_FormatStick_Err_Handler
3A0E D0B5 M bra label
00712
00713 ;; read again number from 0x8000, check if we still see the old value
3A10 0E0F 00714 movlw 0x0f ;; between 0x03 - 0x7f
3A12 6E03 00715 movwf MIOS_PARAMETER1
3A14 0E80 00716 movlw 0x80
3A16 6E04 00717 movwf MIOS_PARAMETER2
3A18 ECB8 F016 00718 call MIOS_BANKSTICK_Read
3A1C 18F3 00719 xorwf PRODL, W
3A1E E106 00720 bnz TIA_BANK_FormatStick_32k
3A20 00721 TIA_BANK_FormatStick_64k
00722 ;; set flag in size register
3A20 501A 00723 movf TIA_BANKSTICK_ID, W
3A22 ECC6 F016 00724 call MIOS_HLP_GetBitORMask
3A26 121D 00725 iorwf TIA_BANKSTICK_SIZE, F
00726 ;; write 64 to address 0x0002
3A28 0E40 00727 movlw 64
00728 rgoto TIA_BANK_FormatStick_SizeIDCont
3A2A D005 M bra label
3A2C 00729 TIA_BANK_FormatStick_32k
00730 ;; clear flag in size register
3A2C 501A 00731 movf TIA_BANKSTICK_ID, W
3A2E ECC4 F016 00732 call MIOS_HLP_GetBitANDMask
3A32 161D 00733 andwf TIA_BANKSTICK_SIZE, F
00734 ;; write 32 to address 0x0002
3A34 0E20 00735 movlw 32
00736 ;;rgoto TIA_BANK_FormatStick_SizeIDCont
3A36 00737 TIA_BANK_FormatStick_SizeIDCont
3A36 6E06 00738 movwf TMP1
3A38 5019 00739 movf TIA_BANKSTICK_CHK_CTR, W
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 68
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
3A3A DE72 00740 rcall TIA_BANK_CheckStick_SelectMagic
3A3C 0E02 00741 movlw 0x02
3A3E 6E03 00742 movwf MIOS_PARAMETER1
3A40 5006 00743 movf TMP1, W
3A42 ECBA F016 00744 call MIOS_BANKSTICK_Write
3A46 A4D8 00745 skpz
00746 rgoto TIA_BANK_FormatStick_Err_Handler
3A48 D098 M bra label
00747
3A4A 0E32 00748 movlw 50 ; wait some ms to get a stable status
3A4C ECCE F016 00749 call MIOS_Delay
00750
00751 ;; now branch depending on Ensemble/Patch
00752 #if DEFAULT_BS_KBANK_ID >= 0 && DEFAULT_BS_KBANK_ID <= 7
3A50 0E04 00753 movlw DEFAULT_BS_KBANK_ID-1
3A52 641A 00754 cpfsgt TIA_BANKSTICK_ID, ACCESS
00755 rgoto TIA_BANK_FormatStick_P
3A54 D022 M bra label
3A56 B211 00756 btfsc TIA_BANK, 1
00757 rgoto TIA_BANK_FormatStick_WT
3A58 D010 M bra label
00758
3A5A 00759 TIA_BANK_FormatStick_K
00760 ;; copy Patch 0 (internal kit) to upload buffer
3A5A 6AA9 00761 clrf EEADR
3A5C 0E01 00762 movlw (EEPROM_KIT >> 8) & 0xff
3A5E 6EAA 00763 movwf EEADRH
3A60 EE07 F000 00764 lfsr FSR0, BANKSTICK_FORMAT_BEGIN
3A64 00765 TIA_BANK_FormatStick_K_CIntLoop
3A64 ECB0 F016 00766 call MIOS_EEPROM_Read
3A68 6EEE 00767 movwf POSTINC0
3A6A AEA9 00768 btfss EEADR, 7
00769 rgoto TIA_BANK_FormatStick_K_CIntLoop
3A6C D7FB M bra label
00770 ;; clear name
3A6E EE07 F000 00771 lfsr FSR0, BANKSTICK_FORMAT_BEGIN
3A72 00772 TIA_BANK_FormatStick_K_ClearLoop
3A72 6AEE 00773 clrf POSTINC0
00774 BRA_IFCLR FSR0L, 4, ACCESS, TIA_BANK_FormatStick_K_ClearLoop
3A74 A8E9 M btfss reg, bit, reg_a
3A76 D7FD M bra label
00775 rgoto TIA_BANK_FormatStick_Data
3A78 D01F M bra label
00776
3A7A 00777 TIA_BANK_FormatStick_WT
00778 ;; copy Patch 0 (internal patch) to upload buffer
3A7A 6AA9 00779 clrf EEADR
3A7C 0E02 00780 movlw (EEPROM_WAVETABLE >> 8) & 0xff
3A7E 6EAA 00781 movwf EEADRH
3A80 EE07 F000 00782 lfsr FSR0, BANKSTICK_FORMAT_BEGIN
3A84 00783 TIA_BANK_FormatStick_WT_CIntLoop
3A84 ECB0 F016 00784 call MIOS_EEPROM_Read
3A88 6EEE 00785 movwf POSTINC0
3A8A AEA9 00786 btfss EEADR, 7
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 69
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00787 rgoto TIA_BANK_FormatStick_WT_CIntLoop
3A8C D7FB M bra label
00788 ;; clear name
3A8E EE07 F000 00789 lfsr FSR0, BANKSTICK_FORMAT_BEGIN
3A92 00790 TIA_BANK_FormatStick_WT_ClearLoop
3A92 6AEE 00791 clrf POSTINC0
00792 BRA_IFCLR FSR0L, 4, ACCESS, TIA_BANK_FormatStick_WT_ClearLoop
3A94 A8E9 M btfss reg, bit, reg_a
3A96 D7FD M bra label
00793 rgoto TIA_BANK_FormatStick_Data
3A98 D00F M bra label
00794
00795 #endif ;; DEFAULT_BS_KBANK_ID >= 0 && DEFAULT_BS_KBANK_ID <= 7
00796
3A9A 00797 TIA_BANK_FormatStick_P
00798 ;; copy Patch 0 (internal patch) to upload buffer
3A9A 6AA9 00799 clrf EEADR
3A9C 0E00 00800 movlw (EEPROM_PATCH >> 8) & 0xff
3A9E 6EAA 00801 movwf EEADRH
3AA0 EE07 F000 00802 lfsr FSR0, BANKSTICK_FORMAT_BEGIN
3AA4 00803 TIA_BANK_FormatStick_P_CIntLoop
3AA4 ECB0 F016 00804 call MIOS_EEPROM_Read
3AA8 6EEE 00805 movwf POSTINC0
3AAA AEA9 00806 btfss EEADR, 7
00807 rgoto TIA_BANK_FormatStick_P_CIntLoop
3AAC D7FB M bra label
00808 ;; clear name
3AAE EE07 F000 00809 lfsr FSR0, BANKSTICK_FORMAT_BEGIN
3AB2 00810 TIA_BANK_FormatStick_P_ClearLoop
3AB2 6AEE 00811 clrf POSTINC0
00812 BRA_IFCLR FSR0L, 4, ACCESS, TIA_BANK_FormatStick_P_ClearLoop
3AB4 A8E9 M btfss reg, bit, reg_a
3AB6 D7FD M bra label
00813 ;;rgoto TIA_BANK_FormatStick_Data
00814
00815
00816
00817
3AB8 00818 TIA_BANK_FormatStick_Data
3AB8 EC78 F01A 00819 call TIA_LEDMTR_PlayFormat_O
00820 ;; now format patch 1 to 127 (64k) or 63 (32k)
3ABC 0E01 00821 movlw 0x01
3ABE 6EA9 00822 movwf EEADR ; use EEADR as patch ctr
00823 ;; Select BS Adress
3AC0 6A03 00824 clrf MIOS_PARAMETER1
3AC2 B0A9 00825 btfsc EEADR, 0
3AC4 8E03 00826 bsf MIOS_PARAMETER1, 7 ; select upper address range on odd bank number
3AC6 30A9 00827 rrf EEADR, W
3AC8 6E04 00828 movwf MIOS_PARAMETER2 ; copy patch to high-byte
3ACA DE25 00829 rcall TIA_BANK_GetBankStickSize
3ACC B4D8 00830 skpnz
00831 rgoto TIA_BANK_FormatStick_Data_32k
3ACE D005 M bra label
3AD0 00832 TIA_BANK_FormatStick_Data_64k
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 70
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
3AD0 B011 00833 btfsc TIA_BANK, 0
3AD2 8C04 00834 bsf MIOS_PARAMETER2, 6
3AD4 B211 00835 btfsc TIA_BANK, 1
3AD6 8E04 00836 bsf MIOS_PARAMETER2, 7
00837 rgoto TIA_BANK_FormatStick_Data_OuterLoop
3AD8 D005 M bra label
3ADA 00838 TIA_BANK_FormatStick_Data_32k
3ADA 9A04 00839 bcf MIOS_PARAMETER2, 5
3ADC B011 00840 btfsc TIA_BANK, 0
3ADE 8A04 00841 bsf MIOS_PARAMETER2, 5
3AE0 B211 00842 btfsc TIA_BANK, 1
3AE2 8C04 00843 bsf MIOS_PARAMETER2, 6
00844
3AE4 00845 TIA_BANK_FormatStick_Data_OuterLoop
00846 ;; copy 0x80 words
3AE4 EE17 F000 00847 lfsr FSR1, BANKSTICK_FORMAT_BEGIN
3AE8 0004 00848 clrwdt ; feed watchdog
00849 ;; buffer already prepared in FSR1
3AEA ECF2 F016 00850 call MIOS_BANKSTICK_WritePage ; write page
3AEE A4D8 00851 skpz
00852 rgoto TIA_BANK_FormatStick_Err_Handler
3AF0 D044 M bra label
3AF2 0E40 00853 movlw 0x40 ; increment FSR1 by 0x40
3AF4 26E1 00854 addwf FSR1L, F
3AF6 0004 00855 clrwdt ; feed watchdog
3AF8 ECF2 F016 00856 call MIOS_BANKSTICK_WritePage ; write page
3AFC A4D8 00857 skpz
00858 rgoto TIA_BANK_FormatStick_Err_Handler
3AFE D03D M bra label
00859 ;; continue until last patch is reached
3B00 2AA9 00860 incf EEADR, F
3B02 501A 00861 movf TIA_BANKSTICK_ID, W
3B04 ECC6 F016 00862 call MIOS_HLP_GetBitORMask
3B08 141D 00863 andwf TIA_BANKSTICK_SIZE, W
3B0A 0E7F 00864 movlw 128-1
3B0C B4D8 00865 skpnz
3B0E 0E3F 00866 movlw 64-1
3B10 64A9 00867 cpfsgt EEADR, ACCESS
00868 rgoto TIA_BANK_FormatStick_Data_OuterLoop
3B12 D7E8 M bra label
3B14 00869 TIA_BANK_FormatStick_Data_End
00870
3B14 EC7E F01A 00871 call TIA_LEDMTR_PlayFormat_G1
00872
00873 ;; write bank new name
00874 ;; add name offset to MP1 start @0x10
3B18 0E10 00875 movlw NEW_BANK_NAME & 0xff
3B1A 6EA9 00876 movwf EEADR
3B1C 0E03 00877 movlw (NEW_BANK_NAME >> 8) & 0xff
3B1E 6EAA 00878 movwf EEADRH
3B20 5019 00879 movf TIA_BANKSTICK_CHK_CTR, W
3B22 DDFE 00880 rcall TIA_BANK_CheckStick_SelectMagic
3B24 0E10 00881 movlw 0x10
3B26 6E03 00882 movwf MIOS_PARAMETER1
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 71
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
3B28 00883 TIA_BANK_FormatStick_Name_Loop
3B28 ECB0 F016 00884 call MIOS_EEPROM_Read
3B2C ECBA F016 00885 call MIOS_BANKSTICK_Write
3B30 A4D8 00886 skpz
00887 rgoto TIA_BANK_FormatStick_Err_Handler
3B32 D023 M bra label
3B34 AA03 00888 btfss MIOS_PARAMETER1, 5 ; until == 0x20
00889 rgoto TIA_BANK_FormatStick_Name_Loop
3B36 D7F8 M bra label
00890
00891 ;;; write magic byte 0 to confirm valid content
3B38 6A03 00892 clrf MIOS_PARAMETER1
3B3A 0E83 00893 movlw BANKSTICK_MAGIC0
3B3C ECBA F016 00894 call MIOS_BANKSTICK_Write
3B40 A4D8 00895 skpz
00896 rgoto TIA_BANK_FormatStick_Err_Handler
3B42 D01B M bra label
00897
00898 #if DEFAULT_BS_KBANK_ID >= 0 && DEFAULT_BS_KBANK_ID <= 7
00899 ;; now branch depending on Kit/Patch
3B44 0E04 00900 movlw DEFAULT_BS_KBANK_ID-1
3B46 641A 00901 cpfsgt TIA_BANKSTICK_ID, ACCESS
00902 rgoto TIA_BANK_FormatStick_P_Cont
3B48 D00E M bra label
3B4A B211 00903 btfsc TIA_BANK, 1
00904 rgoto TIA_BANK_FormatStick_WT_Cont
3B4C D006 M bra label
00905
3B4E 00906 TIA_BANK_FormatStick_K_Cont
00907 ;; select first external kit
00908 ;movlw 1
00909 ;movwf TIA_KIT
00910 ;; store number in EEPROM
00911 ;call TIA_KIT_StoreDefaultNum
00912 ;; write magic byte K(kit/wavetable), valid content and type
3B4E 0E13 00913 movlw BANKSTICK_MAGICK
3B50 ECBA F016 00914 call MIOS_BANKSTICK_Write
3B54 A4D8 00915 skpz
00916 rgoto TIA_BANK_FormatStick_Err_Handler
3B56 D011 M bra label
00917 rgoto TIA_BANK_FormatStick_Cont
3B58 D00B M bra label
00918
3B5A 00919 TIA_BANK_FormatStick_WT_Cont
00920 ;; select first external wavetable
00921 ;movlw 1
00922 ;movwf TIA_WT
00923 ;; store number in EEPROM
00924 ;call TIA_KIT_StoreDefaultNum
00925 ;; write magic byte K(kit/wavetable), valid content and type
3B5A 0E13 00926 movlw BANKSTICK_MAGICK
3B5C ECBA F016 00927 call MIOS_BANKSTICK_Write
3B60 A4D8 00928 skpz
00929 rgoto TIA_BANK_FormatStick_Err_Handler
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 72
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
3B62 D00B M bra label
00930 rgoto TIA_BANK_FormatStick_Cont
3B64 D005 M bra label
00931 #endif ;; DEFAULT_BS_KBANK_ID >= 0 && DEFAULT_BS_KBANK_ID <= 7
00932
3B66 00933 TIA_BANK_FormatStick_P_Cont
00934 ;; select first external patch
00935 ;movlw 1
00936 ;movwf TIA_PRESET
00937 ;; store number in EEPROM
00938 ;call TIA_KIT_StoreDefaultNum
00939 ;; and branch to end
00940 ;;rgoto TIA_BANK_FormatStick_Cont
00941 ;; write magic byte P(patch), valid content and type
3B66 0E12 00942 movlw BANKSTICK_MAGICP
3B68 ECBA F016 00943 call MIOS_BANKSTICK_Write
3B6C A4D8 00944 skpz
00945 rgoto TIA_BANK_FormatStick_Err_Handler
3B6E D005 M bra label
00946 ;;rgoto TIA_BANK_FormatStick_Cont
00947
3B70 00948 TIA_BANK_FormatStick_Cont
00949 ;; play tune, new setup will be reloaded automatically
00950 ;movf TIA_PBANK, W
3B70 EC2D F01E 00951 call TIA_TUNE_Play1
3B74 EC84 F01A 00952 call TIA_LEDMTR_PlayFormat_G2
00953 rgoto TIA_BANK_CheckStick_End
3B78 D623 M bra label
00954
00955
3B7A 00956 TIA_BANK_FormatStick_Err_Handler
00957 ;; realign on first bank of current BankStick
3B7A 5211 00958 movf TIA_BANK, F
3B7C 0B1C 00959 andlw 0x1c
3B7E 28E8 00960 incf WREG, W ;; next will be first
3B80 6E11 00961 movwf TIA_BANK
00962 ;; reinit STAT registers
3B82 501A 00963 movf TIA_BANKSTICK_ID, W
3B84 ECC4 F016 00964 call MIOS_HLP_GetBitANDMask
3B88 161C 00965 andwf TIA_BANKSTICK_STAT, F
3B8A 161D 00966 andwf TIA_BANKSTICK_SIZE, F
00967
3B8C 00968 TIA_BANK_FormatStickEnd
3B8C 0012 00969 return
00970
00971 ;; --------------------------------------------------------------------------
00972
00370 #include "tia_tune.inc"
00001 ; $Id: tia_tune.inc bdupeyron.tech@gmail.com(Antichambre)
00002 ;
00003 ; MIDIbox TIA
00004 ; Routines to play short tunes (when a BankStick is attached/deattached)
00005 ;
00006 ; ==========================================================================
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 73
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00007 ;
00008 ; Copyright 1998-2006 Thorsten Klose (tk@midibox.org)
00009 ; Licensed for personal non-commercial use only.
00010 ; All other rights reserved.
00011 ;
00012 ; ==========================================================================
00013
00014 ;; --------------------------------------------------------------------------
00015 ;; TIA_PLAY Disconnected Tune
00016 ;; --------------------------------------------------------------------------
3B8E 00017 TIA_TUNE_PlayDisconnect
3B8E 0E0D 00018 movlw 0x0d
3B90 6E06 00019 movwf TMP1
3B92 0E06 00020 movlw 0x06
3B94 D878 00021 rcall TIA_TUNE_Note_Init
00022
3B96 0E0B 00023 movlw 0x0b
3B98 D888 00024 rcall TIA_TUNE_Note_On_Wait01
3B9A 0E01 00025 movlw 0x01
3B9C D886 00026 rcall TIA_TUNE_Note_On_Wait01
3B9E 0E01 00027 movlw 0x01
3BA0 D887 00028 rcall TIA_TUNE_Wait
3BA2 0E18 00029 movlw 0x18
3BA4 D882 00030 rcall TIA_TUNE_Note_On_Wait01
3BA6 0E10 00031 movlw 0x10
3BA8 D880 00032 rcall TIA_TUNE_Note_On_Wait01
3BAA 0E04 00033 movlw 0x04
3BAC D875 00034 rcall TIA_TUNE_Note_On
3BAE 0E02 00035 movlw 0x02
3BB0 D87F 00036 rcall TIA_TUNE_Wait
3BB2 D876 00037 rcall TIA_TUNE_Note_Off
3BB4 0E02 00038 movlw 0x02
3BB6 D87C 00039 rcall TIA_TUNE_Wait
00040
00041 rgoto TIA_TUNE_End
3BB8 D064 M bra label
00042
00043 ;; --------------------------------------------------------------------------
00044 ;; TIA_PLAY Ok Tune
00045 ;; --------------------------------------------------------------------------
3BBA 00046 TIA_TUNE_PlayOk
3BBA 0E0D 00047 movlw 0x0d
3BBC 6E06 00048 movwf TMP1
3BBE 0E06 00049 movlw 0x06
3BC0 D862 00050 rcall TIA_TUNE_Note_Init
00051
3BC2 0E0B 00052 movlw 0x0b
3BC4 D872 00053 rcall TIA_TUNE_Note_On_Wait01
3BC6 0E04 00054 movlw 0x04
3BC8 D870 00055 rcall TIA_TUNE_Note_On_Wait01
3BCA 0E01 00056 movlw 0x01
3BCC D871 00057 rcall TIA_TUNE_Wait
3BCE 0E18 00058 movlw 0x18
3BD0 D86C 00059 rcall TIA_TUNE_Note_On_Wait01
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 74
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
3BD2 0E10 00060 movlw 0x10
3BD4 D86A 00061 rcall TIA_TUNE_Note_On_Wait01
3BD6 0E01 00062 movlw 0x01
3BD8 D85F 00063 rcall TIA_TUNE_Note_On
3BDA 0E02 00064 movlw 0x02
3BDC D869 00065 rcall TIA_TUNE_Wait
3BDE D860 00066 rcall TIA_TUNE_Note_Off
3BE0 0E02 00067 movlw 0x02
3BE2 D866 00068 rcall TIA_TUNE_Wait
00069
00070 rgoto TIA_TUNE_End
3BE4 D04E M bra label
00071
00072 ;; --------------------------------------------------------------------------
00073 ;; TIA_PLAY Wrong Tune
00074 ;; --------------------------------------------------------------------------
3BE6 00075 TIA_TUNE_PlayWrong
3BE6 0E0D 00076 movlw 0x0d
3BE8 6E06 00077 movwf TMP1
3BEA 0E06 00078 movlw 0x06
3BEC D84C 00079 rcall TIA_TUNE_Note_Init
00080
3BEE 0E0B 00081 movlw 0x0b
3BF0 D85C 00082 rcall TIA_TUNE_Note_On_Wait01
3BF2 0E04 00083 movlw 0x04
3BF4 D85A 00084 rcall TIA_TUNE_Note_On_Wait01
3BF6 0E05 00085 movlw 0x05
3BF8 D85B 00086 rcall TIA_TUNE_Wait
3BFA 0E18 00087 movlw 0x18
3BFC D856 00088 rcall TIA_TUNE_Note_On_Wait01
3BFE 0E10 00089 movlw 0x10
3C00 D854 00090 rcall TIA_TUNE_Note_On_Wait01
3C02 0E1D 00091 movlw 0x1d
3C04 D849 00092 rcall TIA_TUNE_Note_On
3C06 0E0F 00093 movlw 0x0f
3C08 D853 00094 rcall TIA_TUNE_Wait
3C0A D84A 00095 rcall TIA_TUNE_Note_Off
3C0C 0E04 00096 movlw 0x04
3C0E D850 00097 rcall TIA_TUNE_Wait
00098
00099 rgoto TIA_TUNE_End
3C10 D038 M bra label
00100
00101 ;; --------------------------------------------------------------------------
00102 ;; TIA_PLAY Fanfare Tune
00103 ;; --------------------------------------------------------------------------
3C12 00104 TIA_TUNE_Play_Fanfare
3C12 0E02 00105 movlw 0x02
3C14 D838 00106 rcall TIA_TUNE_Note_Init
00107
3C16 0E0F 00108 movlw 0x0f
3C18 6E06 00109 movwf TMP1
3C1A 0E0B 00110 movlw 0x0b
3C1C D846 00111 rcall TIA_TUNE_Note_On_Wait01
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 75
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
3C1E 0E08 00112 movlw 0x08
3C20 6E06 00113 movwf TMP1
3C22 0E08 00114 movlw 0x08
3C24 D842 00115 rcall TIA_TUNE_Note_On_Wait01
3C26 0E04 00116 movlw 0x04
3C28 6E06 00117 movwf TMP1
3C2A 0E06 00118 movlw 0x06
3C2C D83E 00119 rcall TIA_TUNE_Note_On_Wait01
3C2E 0E0B 00120 movlw 0x0b
3C30 6E06 00121 movwf TMP1
3C32 0E05 00122 movlw 0x05
3C34 D83A 00123 rcall TIA_TUNE_Note_On_Wait01
00124
00125
3C36 0E0F 00126 movlw 0x0f
3C38 D83B 00127 rcall TIA_TUNE_Wait
3C3A 0E08 00128 movlw 0x08
3C3C 6E06 00129 movwf TMP1
3C3E 0E06 00130 movlw 0x06
3C40 D834 00131 rcall TIA_TUNE_Note_On_Wait01
3C42 0E04 00132 movlw 0x04
3C44 D835 00133 rcall TIA_TUNE_Wait
3C46 0E0C 00134 movlw 0x0c
3C48 6E06 00135 movwf TMP1
3C4A 0E05 00136 movlw 0x05
3C4C D82E 00137 rcall TIA_TUNE_Note_On_Wait01
00138
00139
3C4E 0E1A 00140 movlw 0x1a
3C50 D82F 00141 rcall TIA_TUNE_Wait
3C52 D826 00142 rcall TIA_TUNE_Note_Off
3C54 0E06 00143 movlw 0x06
3C56 D82C 00144 rcall TIA_TUNE_Wait
00145
00146 rgoto TIA_TUNE_End
3C58 D014 M bra label
00147
00148 ;; --------------------------------------------------------------------------
00149 ;; TIA_PLAY Tune #1
00150 ;; --------------------------------------------------------------------------
3C5A 00151 TIA_TUNE_Play1
3C5A 0E0D 00152 movlw 0x0d
3C5C 6E06 00153 movwf TMP1
3C5E 0E08 00154 movlw 0x08
3C60 D812 00155 rcall TIA_TUNE_Note_Init
00156
3C62 0E0B 00157 movlw 0x0b
3C64 D822 00158 rcall TIA_TUNE_Note_On_Wait01
3C66 0E02 00159 movlw 0x02
3C68 D820 00160 rcall TIA_TUNE_Note_On_Wait01
3C6A 0E03 00161 movlw 0x03
3C6C D821 00162 rcall TIA_TUNE_Wait
3C6E 0E10 00163 movlw 0x10
3C70 D81C 00164 rcall TIA_TUNE_Note_On_Wait01
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 76
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
3C72 0E1C 00165 movlw 0x1c
00166 ;movf TMP2,W
3C74 D811 00167 rcall TIA_TUNE_Note_On
3C76 0E30 00168 movlw 0x30
3C78 D81B 00169 rcall TIA_TUNE_Wait
3C7A D812 00170 rcall TIA_TUNE_Note_Off
3C7C 0E04 00171 movlw 0x04
3C7E D818 00172 rcall TIA_TUNE_Wait
00173
00174 rgoto TIA_TUNE_End
3C80 D000 M bra label
00175
00176 ;; --------------------------------------------------------------------------
00177 ;; TIA_PLAY End
00178 ;; --------------------------------------------------------------------------
3C82 00179 TIA_TUNE_End
3C82 9010 00180 bcf TIA_STAT, TIA_STAT_ENGINE_DISABLE; turn on TIA software synth part again
00181 ;goto TIA_PATCH_Init ; init patch and exit
3C84 0012 00182 return
00183
00184
00185 ;; --------------------------------------------------------------------------
00186 ;; TIA_PLAY Initialization routine
00187 ;; --------------------------------------------------------------------------
3C86 00188 TIA_TUNE_Note_Init
3C86 8010 00189 bsf TIA_STAT, TIA_STAT_ENGINE_DISABLE; turn off TIA software synth part
00190
00191 SET_BSR TIA_BASE
3C88 0101 M movlb HIGH(reg)
3C8A 0B0F 00192 andlw 0x0f
3C8C 6F00 00193 movwf TIA_AUDC0, BANKED
3C8E 5006 00194 movf TMP1, W
3C90 0B0F 00195 andlw 0x0f
3C92 6F04 00196 movwf TIA_AUDV0, BANKED
3C94 EF66 F01E 00197 goto _TIA_SR_Handler
00198 ;; --------------------------------------------------------------------------
00199 ;; TIA_PLAY a note (in: Note Number)
00200 ;; --------------------------------------------------------------------------
3C98 00201 TIA_TUNE_Note_On
00202 SET_BSR TIA_BASE
3C98 0101 M movlb HIGH(reg)
3C9A 6F02 00203 movwf TIA_AUDF0, BANKED
00204
3C9C EF66 F01E 00205 goto _TIA_SR_Handler
00206
3CA0 00207 TIA_TUNE_Note_Off
00208 SET_BSR TIA_BASE
3CA0 0101 M movlb HIGH(reg)
3CA2 6B04 00209 clrf TIA_AUDV0, BANKED
3CA4 6B05 00210 clrf TIA_AUDV1, BANKED
3CA6 EF66 F01E 00211 goto _TIA_SR_Handler
00212
3CAA 00213 TIA_TUNE_Note_On_Wait01
3CAA DFF6 00214 rcall TIA_TUNE_Note_On
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 77
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
3CAC 0E01 00215 movlw 0x01
00216 rgoto TIA_TUNE_Wait
3CAE D000 M bra label
00217
00218
00219 ;; --------------------------------------------------------------------------
00220 ;; TIA_PLAY wait for a certain time and poll TIA_SR Handler
00221 ;; --------------------------------------------------------------------------
3CB0 00222 TIA_TUNE_Wait
3CB0 6E06 00223 movwf TMP1
3CB2 0004 00224 clrwdt
3CB4 00225 TIA_TUNE_WaitLoop
3CB4 0E0A 00226 movlw 10
3CB6 ECCE F016 00227 call MIOS_Delay
3CBA 2E06 00228 decfsz TMP1, F
00229 rgoto TIA_TUNE_WaitLoop
3CBC D7FB M bra label
3CBE 0012 00230 return
00371 #include "tia_sr.inc"
00001 ; $Id: tia_sr.inc bdupeyron.tech@gmail.com(Antichambre)
00002 ;
00003 ; MIDIbox TIA
00004 ; TIA Shift Register Service Routine
00005 ;
00006 ; ==========================================================================
00007 ;
00008 ; Copyright 1998-2006 Thorsten Klose (tk@midibox.org)
00009 ; Licensed for personal non-commercial use only.
00010 ; All other rights reserved.
00011 ;
00012 ; ==========================================================================
00013 ;
00014 ; define the pins to which the MBHPS_TIA module is connected
00015 ;
00016 #if DEFAULT_IS_CARTRIDGE==1
00000F8B 00017 TIA_SR_LAT_SCLK EQU LATC
00000000 00018 TIA_SR_PIN_SCLK EQU 0 ; Pin C.0
00000F8B 00019 TIA_SR_LAT_RCLK EQU LATC
00000002 00020 TIA_SR_PIN_RCLK EQU 2 ; Pin C.2
00000F8B 00021 TIA_SR_LAT_OUT EQU LATC
00000003 00022 TIA_SR_PIN_OUT EQU 3 ; Pin C.3
00023
00000F8B 00024 TIA_SR_LAT_WR EQU LATC
00000001 00025 TIA_SR_PIN_WR EQU 1 ; Pin C.1
00026 #else
00027 TIA_SR_LAT_SCLK EQU LATD
00028 TIA_SR_PIN_SCLK EQU 5 ; Pin D.5
00029 TIA_SR_LAT_RCLK EQU LATC
00030 TIA_SR_PIN_RCLK EQU 4 ; Pin C.4
00031 TIA_SR_LAT_OUT EQU LATD
00032 TIA_SR_PIN_OUT EQU 6 ; Pin D.6
00033
00034 TIA_SR_LAT_WR EQU LATC
00035 TIA_SR_PIN_WR EQU 5 ; Pin C.5
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 78
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00036 #endif
00037
00038 ;; --------------------------------------------------------------------------
00039 ;; Initialize the MBHP_TIA module
00040 ;; --------------------------------------------------------------------------
3CC0 00041 TIA_SR_Init
00042 ;; reset the TIA
3CC0 6A03 00043 clrf MIOS_PARAMETER1
3CC2 6A04 00044 clrf MIOS_PARAMETER2
3CC4 D827 00045 rcall TIA_SR_Write
3CC6 0012 00046 return
00047 ;; reset will be released with first call of TIA_SR_Handler
00048
00049 ;; --------------------------------------------------------------------------
00050 ;; Check for changes in TIA registers, transfer values to TIA
00051 ;; and handle Wavetable
00052 ;; --------------------------------------------------------------------------
3CC8 00053 TIA_SR_Handler
3CC8 B010 00054 btfsc TIA_STAT, TIA_STAT_ENGINE_DISABLE
3CCA 0012 00055 return
00056
00057 ;call TIA_WT_Handler ; call wavetable handler before continue
3CCC 00058 _TIA_SR_Handler
3CCC 00059 TIA_SR_Start
00060
00061 TABLE_ADDR TIA_SR_REGWRITE_TABLE ; contains order of register accesses
3CCC 0ECE M movlw LOW(addr) ; store Lo Byte
3CCE 6EF6 M movwf TBLPTRL
3CD0 0E3D M movlw HIGH(addr) ; store Hi Byte
3CD2 6EF7 M movwf TBLPTRH
M #if PIC_DERIVATIVE_CODE_SIZE > 0x10000
3CD4 0E00 M movlw UPPER(addr) ; store Upper Byte
3CD6 6EF8 M movwf TBLPTRU
M #endif
3CD8 0E06 00062 movlw 6 ; number of registers (0x06)
3CDA 6E06 00063 movwf TMP1 ; TMP1 is the loop counter
3CDC EE01 F000 00064 lfsr FSR0, TIA_BASE ; store base address of TIA registers in FSR0
3CE0 EE11 F010 00065 lfsr FSR1, TIA_SHADOW_BASE ; store base address of shadow registers in FSR1
00066
00067 IRQ_DISABLE ; disable interrupts
3CE4 9EF2 M bcf INTCON, GIE
00068
3CE6 00069 TIA_SR_Loop
3CE6 0009 00070 tblrd*+
3CE8 50F5 00071 movf TABLAT, W
3CEA CFEB F004 00072 movff PLUSW0, MIOS_PARAMETER2 ; store value of TIA in MIOS_PARAMETER1 and increment FSR0
00073 BRA_IFSET TIA_STAT, TIA_STAT_FORCE_REFRESH, ACCESS, TIA_SR_Transfer; don't skip if refresh has been forced
3CEE B210 M btfsc reg, bit, reg_a
3CF0 D004 M bra label
3CF2 50E3 00074 movf PLUSW1, W ; get content of appr. shadow register
3CF4 6204 00075 cpfseq MIOS_PARAMETER2, ACCESS; transfer to TIA if not equal
00076 rgoto TIA_SR_Transfer
3CF6 D001 M bra label
00077 rgoto TIA_SR_Next ; skip following code if equal
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 79
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
3CF8 D008 M bra label
00078
3CFA 00079 TIA_SR_Transfer
00080 ;; register change: write value into shadow register and transfer it to TIA
3CFA 50F5 00081 movf TABLAT, W
3CFC C004 FFE3 00082 movff MIOS_PARAMETER2, PLUSW1 ; store value in shadow register
00083
3D00 50F5 00084 movf TABLAT, W ; extract address, add offset
3D02 0F05 00085 addlw 0x05
3D04 6E03 00086 movwf MIOS_PARAMETER1 ; store in address register
00087
3D06 D806 00088 rcall TIA_SR_Write ; transfer to TIA
3D08 816A 00089 bsf TIA_LEDMTR_STAT, TIA_LEDMTR_AUDX_REQ
00090
3D0A 00091 TIA_SR_Next
3D0A 2E06 00092 decfsz TMP1, F ; decrement loop counter until it is zero
00093 rgoto TIA_SR_Loop
3D0C D7EC M bra label
00094
00095 IRQ_ENABLE ; enable interrupts again
3D0E 8EF2 M bsf INTCON, GIE
00096
3D10 9210 00097 bcf TIA_STAT, TIA_STAT_FORCE_REFRESH; clear refresh request (if it has been set before)
00098
3D12 0012 00099 return
00100
00101 ;; --------------------------------------------------------------------------
00102 ;; TIA Write: write to TIA register
00103 ;; --------------------------------------------------------------------------
3D14 00104 TIA_SR_Write
00105 ;; TIA signals:
00106 ;; MIOS_PARAMETER2[4..0]: Data
00107 ;; MIOS_PARAMETER1[3..0]: Address
00108 ;; temporary used as counter: MIOS_PARAMETER3
00109
3D14 908B 00110 bcf TIA_SR_LAT_SCLK, TIA_SR_PIN_SCLK ; clear clock
00111
00112 ;; superfast transfer with unrolled loop (takes some memory, but guarantees the
00113 ;; lowest system load :)
00114 TIA_SR_WRITE_BIT MACRO reg, bit
00115 bcf TIA_SR_LAT_OUT, TIA_SR_PIN_OUT ; set out pin depending on register content (reg.bit)
00116 btfsc reg, bit
00117 bsf TIA_SR_LAT_OUT, TIA_SR_PIN_OUT
00118 bsf TIA_SR_LAT_SCLK, TIA_SR_PIN_SCLK ; rising clock edge
00119 bcf TIA_SR_LAT_SCLK, TIA_SR_PIN_SCLK ; falling clock edge
00120 ENDM
00121 #if DEFAULT_IS_CARTRIDGE==1
00122 TIA_SR_WRITE_BIT MIOS_PARAMETER2, 4 ; IC8.O0
3D16 968B M bcf TIA_SR_LAT_OUT, TIA_SR_PIN_OUT ; set out pin depending on register content (reg.bit)
3D18 B804 M btfsc reg, bit
3D1A 868B M bsf TIA_SR_LAT_OUT, TIA_SR_PIN_OUT
3D1C 808B M bsf TIA_SR_LAT_SCLK, TIA_SR_PIN_SCLK ; rising clock edge
3D1E 908B M bcf TIA_SR_LAT_SCLK, TIA_SR_PIN_SCLK ; falling clock edge
00123 TIA_SR_WRITE_BIT MIOS_PARAMETER2, 3 ; IC8.O1
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 80
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
3D20 968B M bcf TIA_SR_LAT_OUT, TIA_SR_PIN_OUT ; set out pin depending on register content (reg.bit)
3D22 B604 M btfsc reg, bit
3D24 868B M bsf TIA_SR_LAT_OUT, TIA_SR_PIN_OUT
3D26 808B M bsf TIA_SR_LAT_SCLK, TIA_SR_PIN_SCLK ; rising clock edge
3D28 908B M bcf TIA_SR_LAT_SCLK, TIA_SR_PIN_SCLK ; falling clock edge
00124 TIA_SR_WRITE_BIT MIOS_PARAMETER2, 2 ; IC8.O2
3D2A 968B M bcf TIA_SR_LAT_OUT, TIA_SR_PIN_OUT ; set out pin depending on register content (reg.bit)
3D2C B404 M btfsc reg, bit
3D2E 868B M bsf TIA_SR_LAT_OUT, TIA_SR_PIN_OUT
3D30 808B M bsf TIA_SR_LAT_SCLK, TIA_SR_PIN_SCLK ; rising clock edge
3D32 908B M bcf TIA_SR_LAT_SCLK, TIA_SR_PIN_SCLK ; falling clock edge
00125 TIA_SR_WRITE_BIT MIOS_PARAMETER2, 1 ; IC8.O3
3D34 968B M bcf TIA_SR_LAT_OUT, TIA_SR_PIN_OUT ; set out pin depending on register content (reg.bit)
3D36 B204 M btfsc reg, bit
3D38 868B M bsf TIA_SR_LAT_OUT, TIA_SR_PIN_OUT
3D3A 808B M bsf TIA_SR_LAT_SCLK, TIA_SR_PIN_SCLK ; rising clock edge
3D3C 908B M bcf TIA_SR_LAT_SCLK, TIA_SR_PIN_SCLK ; falling clock edge
00126 TIA_SR_WRITE_BIT MIOS_PARAMETER2, 0 ; IC8.O4
3D3E 968B M bcf TIA_SR_LAT_OUT, TIA_SR_PIN_OUT ; set out pin depending on register content (reg.bit)
3D40 B004 M btfsc reg, bit
3D42 868B M bsf TIA_SR_LAT_OUT, TIA_SR_PIN_OUT
3D44 808B M bsf TIA_SR_LAT_SCLK, TIA_SR_PIN_SCLK ; rising clock edge
3D46 908B M bcf TIA_SR_LAT_SCLK, TIA_SR_PIN_SCLK ; falling clock edge
00127 TIA_SR_WRITE_BIT MIOS_PARAMETER2, 7 ; IC8.O5
3D48 968B M bcf TIA_SR_LAT_OUT, TIA_SR_PIN_OUT ; set out pin depending on register content (reg.bit)
3D4A BE04 M btfsc reg, bit
3D4C 868B M bsf TIA_SR_LAT_OUT, TIA_SR_PIN_OUT
3D4E 808B M bsf TIA_SR_LAT_SCLK, TIA_SR_PIN_SCLK ; rising clock edge
3D50 908B M bcf TIA_SR_LAT_SCLK, TIA_SR_PIN_SCLK ; falling clock edge
00128 TIA_SR_WRITE_BIT MIOS_PARAMETER2, 7 ; IC8.O6
3D52 968B M bcf TIA_SR_LAT_OUT, TIA_SR_PIN_OUT ; set out pin depending on register content (reg.bit)
3D54 BE04 M btfsc reg, bit
3D56 868B M bsf TIA_SR_LAT_OUT, TIA_SR_PIN_OUT
3D58 808B M bsf TIA_SR_LAT_SCLK, TIA_SR_PIN_SCLK ; rising clock edge
3D5A 908B M bcf TIA_SR_LAT_SCLK, TIA_SR_PIN_SCLK ; falling clock edge
00129 TIA_SR_WRITE_BIT MIOS_PARAMETER2, 7 ; IC8.O7
3D5C 968B M bcf TIA_SR_LAT_OUT, TIA_SR_PIN_OUT ; set out pin depending on register content (reg.bit)
3D5E BE04 M btfsc reg, bit
3D60 868B M bsf TIA_SR_LAT_OUT, TIA_SR_PIN_OUT
3D62 808B M bsf TIA_SR_LAT_SCLK, TIA_SR_PIN_SCLK ; rising clock edge
3D64 908B M bcf TIA_SR_LAT_SCLK, TIA_SR_PIN_SCLK ; falling clock edge
00130
00131 TIA_SR_WRITE_BIT MIOS_PARAMETER1, 3 ; IC7.O0
3D66 968B M bcf TIA_SR_LAT_OUT, TIA_SR_PIN_OUT ; set out pin depending on register content (reg.bit)
3D68 B603 M btfsc reg, bit
3D6A 868B M bsf TIA_SR_LAT_OUT, TIA_SR_PIN_OUT
3D6C 808B M bsf TIA_SR_LAT_SCLK, TIA_SR_PIN_SCLK ; rising clock edge
3D6E 908B M bcf TIA_SR_LAT_SCLK, TIA_SR_PIN_SCLK ; falling clock edge
00132 TIA_SR_WRITE_BIT MIOS_PARAMETER1, 2 ; IC7.O1
3D70 968B M bcf TIA_SR_LAT_OUT, TIA_SR_PIN_OUT ; set out pin depending on register content (reg.bit)
3D72 B403 M btfsc reg, bit
3D74 868B M bsf TIA_SR_LAT_OUT, TIA_SR_PIN_OUT
3D76 808B M bsf TIA_SR_LAT_SCLK, TIA_SR_PIN_SCLK ; rising clock edge
3D78 908B M bcf TIA_SR_LAT_SCLK, TIA_SR_PIN_SCLK ; falling clock edge
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 81
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00133 TIA_SR_WRITE_BIT MIOS_PARAMETER1, 1 ; IC7.O2
3D7A 968B M bcf TIA_SR_LAT_OUT, TIA_SR_PIN_OUT ; set out pin depending on register content (reg.bit)
3D7C B203 M btfsc reg, bit
3D7E 868B M bsf TIA_SR_LAT_OUT, TIA_SR_PIN_OUT
3D80 808B M bsf TIA_SR_LAT_SCLK, TIA_SR_PIN_SCLK ; rising clock edge
3D82 908B M bcf TIA_SR_LAT_SCLK, TIA_SR_PIN_SCLK ; falling clock edge
00134 TIA_SR_WRITE_BIT MIOS_PARAMETER1, 0 ; IC7.O3
3D84 968B M bcf TIA_SR_LAT_OUT, TIA_SR_PIN_OUT ; set out pin depending on register content (reg.bit)
3D86 B003 M btfsc reg, bit
3D88 868B M bsf TIA_SR_LAT_OUT, TIA_SR_PIN_OUT
3D8A 808B M bsf TIA_SR_LAT_SCLK, TIA_SR_PIN_SCLK ; rising clock edge
3D8C 908B M bcf TIA_SR_LAT_SCLK, TIA_SR_PIN_SCLK ; falling clock edge
00135 TIA_SR_WRITE_BIT MIOS_PARAMETER1, 7 ; IC7.O4
3D8E 968B M bcf TIA_SR_LAT_OUT, TIA_SR_PIN_OUT ; set out pin depending on register content (reg.bit)
3D90 BE03 M btfsc reg, bit
3D92 868B M bsf TIA_SR_LAT_OUT, TIA_SR_PIN_OUT
3D94 808B M bsf TIA_SR_LAT_SCLK, TIA_SR_PIN_SCLK ; rising clock edge
3D96 908B M bcf TIA_SR_LAT_SCLK, TIA_SR_PIN_SCLK ; falling clock edge
00136 TIA_SR_WRITE_BIT MIOS_PARAMETER1, 7 ; IC7.O5
3D98 968B M bcf TIA_SR_LAT_OUT, TIA_SR_PIN_OUT ; set out pin depending on register content (reg.bit)
3D9A BE03 M btfsc reg, bit
3D9C 868B M bsf TIA_SR_LAT_OUT, TIA_SR_PIN_OUT
3D9E 808B M bsf TIA_SR_LAT_SCLK, TIA_SR_PIN_SCLK ; rising clock edge
3DA0 908B M bcf TIA_SR_LAT_SCLK, TIA_SR_PIN_SCLK ; falling clock edge
00137 TIA_SR_WRITE_BIT MIOS_PARAMETER1, 7 ; IC7.O6
3DA2 968B M bcf TIA_SR_LAT_OUT, TIA_SR_PIN_OUT ; set out pin depending on register content (reg.bit)
3DA4 BE03 M btfsc reg, bit
3DA6 868B M bsf TIA_SR_LAT_OUT, TIA_SR_PIN_OUT
3DA8 808B M bsf TIA_SR_LAT_SCLK, TIA_SR_PIN_SCLK ; rising clock edge
3DAA 908B M bcf TIA_SR_LAT_SCLK, TIA_SR_PIN_SCLK ; falling clock edge
00138 TIA_SR_WRITE_BIT MIOS_PARAMETER1, 7 ; IC7.O7
3DAC 968B M bcf TIA_SR_LAT_OUT, TIA_SR_PIN_OUT ; set out pin depending on register content (reg.bit)
3DAE BE03 M btfsc reg, bit
3DB0 868B M bsf TIA_SR_LAT_OUT, TIA_SR_PIN_OUT
3DB2 808B M bsf TIA_SR_LAT_SCLK, TIA_SR_PIN_SCLK ; rising clock edge
3DB4 908B M bcf TIA_SR_LAT_SCLK, TIA_SR_PIN_SCLK ; falling clock edge
00139
00140 #else
00141 TIA_SR_WRITE_BIT MIOS_PARAMETER2, 0 ; IC2.O0
00142 TIA_SR_WRITE_BIT MIOS_PARAMETER2, 1 ; IC2.O1
00143 TIA_SR_WRITE_BIT MIOS_PARAMETER2, 2 ; IC2.O2
00144 TIA_SR_WRITE_BIT MIOS_PARAMETER2, 3 ; IC2.O3
00145 TIA_SR_WRITE_BIT MIOS_PARAMETER2, 4 ; IC2.O4
00146 TIA_SR_WRITE_BIT MIOS_PARAMETER2, 7 ; IC2.O5
00147 TIA_SR_WRITE_BIT MIOS_PARAMETER2, 7 ; IC2.O6
00148 TIA_SR_WRITE_BIT MIOS_PARAMETER2, 7 ; IC2.O7
00149
00150 TIA_SR_WRITE_BIT MIOS_PARAMETER1, 3 ; IC3.O0
00151 TIA_SR_WRITE_BIT MIOS_PARAMETER1, 2 ; IC3.O1
00152 TIA_SR_WRITE_BIT MIOS_PARAMETER1, 1 ; IC3.O2
00153 TIA_SR_WRITE_BIT MIOS_PARAMETER1, 0 ; IC3.O3
00154 TIA_SR_WRITE_BIT MIOS_PARAMETER1, 7 ; IC3.O4
00155 TIA_SR_WRITE_BIT MIOS_PARAMETER1, 7 ; IC3.O5
00156 TIA_SR_WRITE_BIT MIOS_PARAMETER1, 7 ; IC3.O6
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 82
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00157 TIA_SR_WRITE_BIT MIOS_PARAMETER1, 7 ; IC3.O7
00158 #endif
3DB6 848B 00159 bsf TIA_SR_LAT_RCLK, TIA_SR_PIN_RCLK ; latch TIA values
00160
3DB8 928B 00161 bcf TIA_SR_LAT_WR, TIA_SR_PIN_WR ; enable write
3DBA 968B 00162 bcf TIA_SR_LAT_OUT, TIA_SR_PIN_OUT ; clear out pin (standby)
3DBC 948B 00163 bcf TIA_SR_LAT_RCLK, TIA_SR_PIN_RCLK ; release latch
00164
3DBE 928B 00165 bcf TIA_SR_LAT_WR, TIA_SR_PIN_WR ; enable write
3DC0 D000 00166 bra $+2 ; to ensure compatibility with on-board oscillator,
3DC2 D000 00167 bra $+2 ; wait for 0.840 uS (1 us) (> one TIA clock cycle)
3DC4 D000 00168 bra $+2
3DC6 D000 00169 bra $+2
3DC8 D000 00170 bra $+2
3DCA 828B 00171 bsf TIA_SR_LAT_WR, TIA_SR_PIN_WR ; disable write (MBHP_TIA: chip select)
00172
3DCC 0012 00173 return
00174
00175 ;; --------------------------------------------------------------------------
3DCE 00176 TIA_SR_REGWRITE_TABLE
00177 ;; order in which the TIA registers are written
3DCE 0100 0302 00178 db 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06
0504 0006
00179
00180
00181
00182
00372 #include "tia_sw.inc"
00001 ; $Id: tia_sw.inc bdupeyron.tech@gmail.com(Antichambre)
00002 ;
00003 ; MIDIbox TIA
00004 ; Software Synthesizer Engine
00005 ; mostly optimized for PIC16F - special adaption for PIC18F to be done
00006 ;
00007 ; Activate this #define to measure the performance with a scope
00008 ; (connect the probe to J14)
3DD6 00009 #define TIA_SW_MEASURE_PERFORMANCE 0
00010 ;
00011 ; ==========================================================================
00012 ;
00013 ; Copyright 1998-2006 Thorsten Klose (tk@midibox.org)
00014 ; Idea for ENV Curve Parameter and OSC synchronization by Jess D. Skov-Nielsen
00015 ; Licensed for personal non-commercial use only.
00016 ; All other rights reserved.
00017 ;
00018 ; ==========================================================================
00019
00020 ;; ==========================================================================
00021 ;; TIA Flags
00022 ;; ==========================================================================
00023
00024
00025
00026
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 83
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00000000 00027 Vx_STAT_VOICE_ACTIVE EQU 0
00000001 00028 Vx_STAT_GATE_SET_REQ EQU 1
00000002 00029 Vx_STAT_GATE_CLR_REQ EQU 2
00000003 00030 Vx_STAT_GATE_ACTIVE EQU 3
00000004 00031 Vx_STAT_PORTA_ENABLE EQU 4
00000005 00032 Vx_STAT_GATE_NOTE_ON EQU 5
00000006 00033 Vx_STAT_ENV_ACTIVE EQU 6
00034
00000000 00035 Vx_MODE_GSA_ACTIVE EQU 0
00000001 00036 Vx_MODE_PORTA_CONST EQU 1
00000002 00037 Vx_MODE_KEY_EXTENDED EQU 2
00000003 00038 Vx_MODE_VEL2AMP_ON EQU 3
00000004 00039 Vx_MODE_ENV2AMP_ON EQU 4
00000005 00040 Vx_MODE_ENV2PITCH_ON EQU 5
00000006 00041 Vx_MODE_ARP_SYNC_ON EQU 6
00042
00000000 00043 ENVAUDx_MODTYP_AB EQU 0
00000001 00044 ENVAUDx_MODTYP_AxB EQU 1
00000003 00045 Vx_ENV_SYNC_ON EQU 3
00046
00000000 00047 Vx_OPTION_WT_ON EQU 0
00000001 00048 Vx_OPTION_WTSYNC_ON EQU 1
00000002 00049 Vx_OPTION_KIT_ON EQU 2
00000003 00050 Vx_OPTION_SAMPLER_ON EQU 3
00051 ;; A ajouter dans MAX
00000004 00052 Vx_OPTION_ONLY_WT_OFF EQU 4
00000005 00053 Vx_OPTION_TB303 EQU 5
00000006 00054 Vx_OPTION_ENV2PORTA EQU 6
00055
00000000 00056 LFOx_MODE_ENABLE EQU 0
00000001 00057 LFOx_MODE_SYNC EQU 1
00000002 00058 LFOx_MODE_SYNC_ALL EQU 2
00000003 00059 LFOx_MODE_RESERVED EQU 3
00000004 00060 LFOx_MODE_WAVEFORM0 EQU 4
00000005 00061 LFOx_MODE_WAVEFORM1 EQU 5
00000006 00062 LFOx_MODE_WAVEFORM2 EQU 6
00000007 00063 LFOx_MODE_DECINC EQU 7
00064
00000000 00065 ENVx_MODE_ATTACK EQU 0
00000001 00066 ENVx_MODE_DECAY EQU 1
00000002 00067 ENVx_MODE_SUSTAIN EQU 2
00000003 00068 ENVx_MODE_RELEASE EQU 3
00000004 00069 ENVx_MODE_FREE EQU 4
00070 ;ENVx_MODE_RESERVED EQU 5
00071 ;ENVx_MODE_RESERVED EQU 6
00072 ;ENVx_MODE_RESERVED EQU 7
00073
00000000 00074 ASSIGNED_LFOS_1 EQU 0
00000001 00075 ASSIGNED_LFOS_2 EQU 1
00000002 00076 ASSIGNED_LFOS_3 EQU 2
00000003 00077 ASSIGNED_LFOS_4 EQU 3
00000004 00078 ASSIGNED_ENVS_1 EQU 4
00000005 00079 ASSIGNED_ENVS_2 EQU 5
00000006 00080 ASSIGNED_ENVS_A0 EQU 6
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 84
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00000007 00081 ASSIGNED_ENVS_A1 EQU 7
00082
00000000 00083 WT_STATE_STOP EQU 0
00000001 00084 WT_STATE_RESET EQU 1
00000004 00085 WT_STATE_GATE EQU 4 ; for TB303 option
00000005 00086 WT_STATE_SLIDE EQU 5
00000006 00087 WT_STATE_SLIDE_PREV EQU 6
00000007 00088 WT_STATE_PLAY_2ND EQU 7
00089
00090 ;; ==========================================================================
00091
00092
00093 ;; --------------------------------------------------------------------------
00094 ;; TIA Software Handler: Software Synthesizer part for the TIA
00095 ;; called by User Timer every 800 us
00096 ;; --------------------------------------------------------------------------
3DD6 00097 TIA_SW_Handler
00098 #if TIA_SW_MEASURE_PERFORMANCE
00099 bsf PORTD, 4
00100 #endif
00101
00102 SET_BSR TIA_BASE ; prepare BSR for TIA register access
3DD6 0101 M movlb HIGH(reg)
00103
00104 ;; return immediately if engine has been disabled
3DD8 B010 00105 btfsc TIA_STAT, TIA_STAT_ENGINE_DISABLE
3DDA 0012 00106 return
00107
00108 ;; handle with MIDI clock
3DDC 00109 TIA_SW_Clk
3DDC 2BF1 00110 incf TIA_MIDI_SYNC_CTR, F, BANKED
00111
00112 ;; register last counter value on 0xf8 or if TIA_MIDI_SYNC_CTR == 0xff (no clock received)
3DDE 9DF0 00113 bcf TIA_MIDI_SYNC, TIA_MIDI_SYNC_TICK_1, BANKED
3DE0 29F1 00114 incf TIA_MIDI_SYNC_CTR, W, BANKED
3DE2 E003 00115 bz TIA_SW_Clk_F8
00116 BRA_IFCLR TIA_MIDI_SYNC, TIA_MIDI_SYNC_F8, BANKED, TIA_SW_Clk_NoF8
3DE4 A9F0 M btfss reg, bit, reg_a
3DE6 D005 M bra label
3DE8 99F0 00117 bcf TIA_MIDI_SYNC, TIA_MIDI_SYNC_F8, BANKED
3DEA 00118 TIA_SW_Clk_F8
3DEA 8DF0 00119 bsf TIA_MIDI_SYNC, TIA_MIDI_SYNC_TICK_1, BANKED
3DEC C1F1 F1F2 00120 movff TIA_MIDI_SYNC_CTR, TIA_MIDI_SYNC_CTR_REG
3DF0 6BF1 00121 clrf TIA_MIDI_SYNC_CTR, BANKED
3DF2 00122 TIA_SW_Clk_NoF8
00123
00124 ;; handle with double resolution of TIA_SW clock
3DF2 9FF0 00125 bcf TIA_MIDI_SYNC, TIA_MIDI_SYNC_TICK_2, BANKED
00126
00127 ;; if MIDI sync enabled: clock LFOs/ENVs two times on every MIDI clock event
3DF4 51F1 00128 movf TIA_MIDI_SYNC_CTR, W, BANKED
3DF6 B4D8 00129 skpnz
3DF8 8FF0 00130 bsf TIA_MIDI_SYNC, TIA_MIDI_SYNC_TICK_2, BANKED
00131
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 85
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
3DFA 90D8 00132 clrc
3DFC 31F2 00133 rrf TIA_MIDI_SYNC_CTR_REG, W, BANKED
3DFE 19F1 00134 xorwf TIA_MIDI_SYNC_CTR, W, BANKED
3E00 B4D8 00135 skpnz
3E02 8FF0 00136 bsf TIA_MIDI_SYNC, TIA_MIDI_SYNC_TICK_2, BANKED
00137
00138 ;; A MIDI clock start event restarts all LFOs
00139 BRA_IFCLR TIA_MIDI_SYNC, TIA_MIDI_SYNC_FA, BANKED, TIA_SW_Clk_NoFA
3E04 ABF0 M btfss reg, bit, reg_a
3E06 D003 M bra label
3E08 9BF0 00140 bcf TIA_MIDI_SYNC, TIA_MIDI_SYNC_FA, BANKED
3E0A 00141 TIA_SW_Clk_FA
3E0A EC1C F024 00142 call TIA_SW_Hlp_SyncAllLFOs
00143
00144 ;btfsc TIA_SE_OPTION, SE_OPTION_TB303, BANKED
00145 ;bsf TIA_WT_STATE, WT_STATE_RESET, BANKED
00146
3E0E 00147 TIA_SW_Clk_NoFA
00148
3E0E CFF3 F1F6 00149 movff PRODL, SAVED_PRODL ; save PROD[LH] - we are in an interrupt routine
3E12 CFF4 F1F7 00150 movff PRODH, SAVED_PRODH
00151
00152 ;; generate new pseudo-random number
3E16 511C 00153 movf TIA_LFO_RANDOM_SEED_L, W, BANKED
3E18 031D 00154 mulwf TIA_LFO_RANDOM_SEED_H, BANKED
3E1A 50D6 00155 movf TMR0L, W
3E1C 24F3 00156 addwf PRODL, W
3E1E 6F1C 00157 movwf TIA_LFO_RANDOM_SEED_L, BANKED
3E20 0E69 00158 movlw 0x69
3E22 20F4 00159 addwfc PRODH, W
3E24 6F1D 00160 movwf TIA_LFO_RANDOM_SEED_H, BANKED
00161
00162 #if 0
00163 ;; wavetable handler: check for MIDI Sync
00164 BRA_IFCLR TIA_MIDI_SYNC, TIA_MIDI_SYNC_WT_ARP, BANKED, TIA_SW_Wt
00165 BRA_IFCLR TIA_MIDI_SYNC, TIA_MIDI_SYNC_TICK_1, BANKED, TIA_SW_Wt_End
00166 TIA_SW_Wt
00167 movf TIA_WT_RATE, W, BANKED
00168 bz TIA_SW_Wt_End
00169
00170 movf TIA_WT_CTR, W, BANKED
00171 bnz TIA_SW_Wt_Next
00172
00173 comf TIA_WT_RATE, W, BANKED
00174 andlw 0x7f
00175 BRA_IFCLR TIA_MIDI_SYNC, TIA_MIDI_SYNC_WT_ARP, BANKED, TIA_SW_Wt_IntClk
00176 TIA_SW_Wt_ExtClk
00177 btfss TIA_SE_OPTION, SE_OPTION_TB303, BANKED
00178 addlw 1
00179 movwf TIA_WT_CTR, BANKED
00180 rgoto TIA_SW_Wt_PlayNext
00181 TIA_SW_Wt_IntClk
00182 skpnz ; never use 0x00 (avoid wdt reset on overloaded engine)
00183 addlw 1
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 86
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00184 movwf TIA_WT_CTR, BANKED
00185 clrc
00186 rlf TIA_WT_CTR, F, BANKED
00187 ;; rgoto TIA_SW_Wt_PlayNext
00188
00189 TIA_SW_Wt_PlayNext
00190 incf TIA_WT_CLK_REQ_CTR, F, BANKED
00191 rgoto TIA_SW_Wt_End
00192
00193 TIA_SW_Wt_Next
00194 decf TIA_WT_CTR, F, BANKED
00195 TIA_SW_Wt_End
00196 #endif
00197
00198 ;; ARPs: check for MIDI Sync
3E26 00199 TIA_SW_ARPs
3E26 EE11 F020 00200 lfsr FSR1, TIA_V1_BASE
3E2A 0E04 00201 movlw TIA_Vx_MODE
3E2C BCE3 00202 btfsc PLUSW1, Vx_MODE_ARP_SYNC_ON
3E2E BFF0 00203 btfsc TIA_MIDI_SYNC, TIA_MIDI_SYNC_TICK_2, BANKED
3E30 D858 00204 rcall TIA_SW_Arp
3E32 EE11 F060 00205 lfsr FSR1, TIA_V2_BASE
3E36 0E04 00206 movlw TIA_Vx_MODE
3E38 BCE3 00207 btfsc PLUSW1, Vx_MODE_ARP_SYNC_ON
3E3A BFF0 00208 btfsc TIA_MIDI_SYNC, TIA_MIDI_SYNC_TICK_2, BANKED
3E3C D852 00209 rcall TIA_SW_Arp
3E3E 00210 TIA_SW_ARPs_End
00211
00212 ;; LFOs: check for MIDI Sync
3E3E 00213 TIA_SW_LFOs
3E3E 6B0F 00214 clrf TIA_SW_LFO_NUMBER, BANKED
3E40 EE11 F0A0 00215 lfsr FSR1, TIA_LFO1_BASE
3E44 B11F 00216 btfsc TIA_MOD_SYNC, ASSIGNED_LFOS_1, BANKED
3E46 BFF0 00217 btfsc TIA_MIDI_SYNC, TIA_MIDI_SYNC_TICK_2, BANKED
3E48 DB3F 00218 rcall TIA_SW_LFO
3E4A 2B0F 00219 incf TIA_SW_LFO_NUMBER, F, BANKED
3E4C EE11 F0A7 00220 lfsr FSR1, TIA_LFO2_BASE
3E50 B31F 00221 btfsc TIA_MOD_SYNC, ASSIGNED_LFOS_2, BANKED
3E52 BFF0 00222 btfsc TIA_MIDI_SYNC, TIA_MIDI_SYNC_TICK_2, BANKED
3E54 DB39 00223 rcall TIA_SW_LFO
3E56 2B0F 00224 incf TIA_SW_LFO_NUMBER, F, BANKED
3E58 EE11 F0AE 00225 lfsr FSR1, TIA_LFO3_BASE
3E5C B51F 00226 btfsc TIA_MOD_SYNC, ASSIGNED_LFOS_3, BANKED
3E5E BFF0 00227 btfsc TIA_MIDI_SYNC, TIA_MIDI_SYNC_TICK_2, BANKED
3E60 DB33 00228 rcall TIA_SW_LFO
3E62 2B0F 00229 incf TIA_SW_LFO_NUMBER, F, BANKED
3E64 EE11 F0B5 00230 lfsr FSR1, TIA_LFO4_BASE
3E68 B71F 00231 btfsc TIA_MOD_SYNC, ASSIGNED_LFOS_4, BANKED
3E6A BFF0 00232 btfsc TIA_MIDI_SYNC, TIA_MIDI_SYNC_TICK_2, BANKED
3E6C DB2D 00233 rcall TIA_SW_LFO
3E6E 00234 TIA_SW_LFOs_End
00235
00236 ;; ENVs: check for MIDI Sync
3E6E 00237 TIA_SW_ENVs
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 87
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00238 ;; Enveloppe for AUD0(voice 1)
3E6E 6B0F 00239 clrf TIA_SW_ENV_NUMBER, BANKED
3E70 EE11 F0BC 00240 lfsr FSR1, TIA_ENVAUD0_BASE
3E74 EE21 F020 00241 lfsr FSR2, TIA_V1_BASE
3E78 0E2A 00242 movlw TIA_Vx_ENV_OPTION
00243 BRA_IFCLR PLUSW2, Vx_ENV_SYNC_ON, ACCESS, TIA_SW_ENVs_v1_Ok
3E7A A6DB M btfss reg, bit, reg_a
3E7C D002 M bra label
00244 BRA_IFCLR TIA_MIDI_SYNC, TIA_MIDI_SYNC_TICK_2, BANKED, TIA_SW_ENVs_v1_Nok
3E7E AFF0 M btfss reg, bit, reg_a
3E80 D003 M bra label
3E82 00245 TIA_SW_ENVs_v1_Ok
3E82 38DB 00246 swapf PLUSW2, W
3E84 0B07 00247 andlw 0x07
3E86 DB66 00248 rcall TIA_SW_ENV
3E88 00249 TIA_SW_ENVs_v1_Nok
00250 ;; Enveloppe for AUD1(voice 2)
3E88 2B0F 00251 incf TIA_SW_ENV_NUMBER, BANKED
3E8A EE11 F0C7 00252 lfsr FSR1, TIA_ENVAUD1_BASE
3E8E EE21 F060 00253 lfsr FSR2, TIA_V2_BASE
3E92 0E2A 00254 movlw TIA_Vx_ENV_OPTION
00255 BRA_IFCLR PLUSW2, Vx_ENV_SYNC_ON, ACCESS, TIA_SW_ENVs_v2_Ok
3E94 A6DB M btfss reg, bit, reg_a
3E96 D002 M bra label
00256 BRA_IFCLR TIA_MIDI_SYNC, TIA_MIDI_SYNC_TICK_2, BANKED, TIA_SW_ENVs_v2_Nok
3E98 AFF0 M btfss reg, bit, reg_a
3E9A D003 M bra label
3E9C 00257 TIA_SW_ENVs_v2_Ok
3E9C 38DB 00258 swapf PLUSW2, W
3E9E 0B07 00259 andlw 0x07
3EA0 DB59 00260 rcall TIA_SW_ENV
3EA2 00261 TIA_SW_ENVs_v2_Nok
00262 ;; Enveloppe 1
3EA2 2B0F 00263 incf TIA_SW_ENV_NUMBER, BANKED
3EA4 EE11 F0D2 00264 lfsr FSR1, TIA_ENV1_BASE
3EA8 511E 00265 movf TIA_ENVx_CURVES, W, BANKED
3EAA B91F 00266 btfsc TIA_MOD_SYNC, ASSIGNED_ENVS_1, BANKED
3EAC BFF0 00267 btfsc TIA_MIDI_SYNC, TIA_MIDI_SYNC_TICK_2, BANKED
3EAE DB52 00268 rcall TIA_SW_ENV
00269 ;; Enveloppe 2
3EB0 2B0F 00270 incf TIA_SW_ENV_NUMBER, BANKED
3EB2 EE11 F0DD 00271 lfsr FSR1, TIA_ENV2_BASE
3EB6 391E 00272 swapf TIA_ENVx_CURVES, W, BANKED
3EB8 BB1F 00273 btfsc TIA_MOD_SYNC, ASSIGNED_ENVS_2, BANKED
3EBA BFF0 00274 btfsc TIA_MIDI_SYNC, TIA_MIDI_SYNC_TICK_2, BANKED
3EBC DB4B 00275 rcall TIA_SW_ENV
3EBE 00276 TIA_SW_ENVs_End
00277
00278 SET_BSR TIA_BASE
3EBE 0101 M movlb HIGH(reg)
3EC0 6B0E 00279 clrf TIA_SW_VOICE, BANKED ; loop counter
3EC2 EE11 F020 00280 lfsr FSR1, TIA_V1_BASE
3EC6 00281 TIA_SW_VoiceLoop
3EC6 0E10 00282 movlw TIA_Vx_NOTE
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 88
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
3EC8 50E3 00283 movf PLUSW1, W
3ECA E002 00284 bz TIA_SW_VoiceLoop_NoPitchChange
3ECC 00285 TIA_SW_VoiceLoop_PitchChange
3ECC D85C 00286 rcall TIA_SW_Note
3ECE D8D0 00287 rcall TIA_SW_Pitch
00288
3ED0 00289 TIA_SW_VoiceLoop_NoPitchChange
3ED0 D992 00290 rcall TIA_SW_Porta
3ED2 DA3C 00291 rcall TIA_SW_Amp
00292
3ED4 00293 TIA_SW_VoiceLoop_Next
3ED4 0E40 00294 movlw TIA_Vx_RECORD_LEN
3ED6 26E1 00295 addwf FSR1L, F
3ED8 2B0E 00296 incf TIA_SW_VOICE, F, BANKED
3EDA 0E01 00297 movlw 2-1
3EDC 650E 00298 cpfsgt TIA_SW_VOICE, BANKED
00299 rgoto TIA_SW_VoiceLoop
3EDE D7F3 M bra label
00300
3EE0 00301 TIA_SW_Handler_End
00302
00303 #if TIA_SW_MEASURE_PERFORMANCE
00304 bcf PORTD, 4
00305 #endif
00306
3EE0 0012 00307 return
00308
00309
00310
00311
00312
00313 ;; --------------------------------------------------------------------------
00314 ;; This function handles the arpeggiator
00315 ;; --------------------------------------------------------------------------
3EE2 00316 TIA_SW_Arp
00317 ;; skip if arpeggiator rate == 0
3EE2 0E13 00318 movlw TIA_Vx_ARP_RATE
3EE4 50E3 00319 movf PLUSW1, W
3EE6 E04E 00320 bz TIA_SW_Arp_End
00321
00322 ;; a counter is incremented on each function call
00323 ;; arpeggiator is stepped forward once the counter has reached the
00324 ;; compare value: rate^0x7f + 1, multiply by 2 if MIDI sync not enabled
3EE8 0A7F 00325 xorlw 0x7f
3EEA 0F01 00326 addlw 1
3EEC 6E0B 00327 movwf IRQ_TMP1 ; compare value => IRQ_TMP1
3EEE 90D8 00328 clrc
3EF0 0E04 00329 movlw TIA_Vx_MODE
3EF2 ACE3 00330 btfss PLUSW1, Vx_MODE_ARP_SYNC_ON, ACCESS ; (*2 reduce the rate a little if no MIDI sync)
3EF4 360B 00331 rlf IRQ_TMP1, F
00332
3EF6 0E01 00333 movlw 1
3EF8 6E0C 00334 movwf IRQ_TMP2 ; incrementer => IRQ_TMP2
00335
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 89
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00336 ;; special option: constant time arp cycle
00337 ;; if 1 key is pressed, use the original incrementer
00338 ;; if 2 keys are pressed, increment by 2
00339 ;; if 3 keys are pressed, increment by 3
00340 ;; if 4 keys are pressed, increment by 4
3EFA 0E23 00341 movlw TIA_Vx_NOTE_STACK_1
3EFC 50E3 00342 movf PLUSW1, W
3EFE A4D8 00343 skpz
3F00 2A0C 00344 incf IRQ_TMP2, F
00345
3F02 0E24 00346 movlw TIA_Vx_NOTE_STACK_2
3F04 50E3 00347 movf PLUSW1, W
3F06 A4D8 00348 skpz
3F08 2A0C 00349 incf IRQ_TMP2, F
00350
3F0A 0E25 00351 movlw TIA_Vx_NOTE_STACK_3
3F0C 50E3 00352 movf PLUSW1, W
3F0E A4D8 00353 skpz
3F10 2A0C 00354 incf IRQ_TMP2, F
00355
00356 ;; increment counter
3F12 0E15 00357 movlw TIA_Vx_ARP_CTR
3F14 50E3 00358 movf PLUSW1, W
3F16 260C 00359 addwf IRQ_TMP2, F
3F18 E206 00360 bc TIA_SW_Arp_Overrun
3F1A 0E15 00361 movlw TIA_Vx_ARP_CTR
3F1C C00C FFE3 00362 movff IRQ_TMP2, PLUSW1
00363
00364 ;; branch to the end so long the counter is less than the compare value
3F20 500C 00365 movf IRQ_TMP2, W
3F22 5C0B 00366 subwf IRQ_TMP1, W
3F24 E22F 00367 bc TIA_SW_Arp_End
00368
3F26 00369 TIA_SW_Arp_Overrun
00370 ;; clear counter
3F26 0E15 00371 movlw TIA_Vx_ARP_CTR
3F28 6AE3 00372 clrf PLUSW1
00373
00374 ;; increment note number (1 of 4)
3F2A 0E14 00375 movlw TIA_Vx_ARP_NOTE_NUMBER
3F2C 28E3 00376 incf PLUSW1, W
3F2E 0B03 00377 andlw 0x03
3F30 6E0B 00378 movwf IRQ_TMP1
00379
00380 ;; reset note number if last one reached (TIA_Vx_NOTE_STACK_x is zero)
3F32 0E22 00381 movlw TIA_Vx_NOTE_STACK_0
3F34 240B 00382 addwf IRQ_TMP1, W
3F36 50E3 00383 movf PLUSW1, W
3F38 B4D8 00384 skpnz
3F3A 6A0B 00385 clrf IRQ_TMP1
00386
00387 ;; save new note number
3F3C 0E14 00388 movlw TIA_Vx_ARP_NOTE_NUMBER
3F3E C00B FFE3 00389 movff IRQ_TMP1, PLUSW1
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 90
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00390
00391 ;; select note
3F42 0E1E 00392 movlw TIA_Vx_ARP_NOTE_0
3F44 240B 00393 addwf IRQ_TMP1, W
00394
00395 ;; save new note number if != zero and != last note
3F46 50E3 00396 movf PLUSW1, W
3F48 E01D 00397 bz TIA_SW_Arp_NoNewNote
3F4A 6E0B 00398 movwf IRQ_TMP1
3F4C 0E10 00399 movlw TIA_Vx_NOTE
3F4E 50E3 00400 movf PLUSW1, W
3F50 180B 00401 xorwf IRQ_TMP1, W
3F52 E018 00402 bz TIA_SW_Arp_NoNewNote
3F54 00403 TIA_SW_Arp_NewNote
3F54 0E10 00404 movlw TIA_Vx_NOTE
3F56 C00B FFE3 00405 movff IRQ_TMP1, PLUSW1
00406
00407
3F5A 0E0E 00408 movlw TIA_Vx_PORTA_RATE
3F5C 50E3 00409 movf PLUSW1, W
3F5E E012 00410 bz TIA_SW_Arp_NoPorta
3F60 00411 TIA_SW_Arp_Porta
3F60 0E03 00412 movlw TIA_Vx_STAT
3F62 88E3 00413 bsf PLUSW1, Vx_STAT_PORTA_ENABLE
00414
00415 ;; store current frequency in TIA_Vx_PORTA_FRQ_L
00416
00417
3F64 0E09 00418 movlw TIA_Vx_FRQ_L
3F66 CFE3 F00B 00419 movff PLUSW1, IRQ_TMP1
3F6A 0E0A 00420 movlw TIA_Vx_FRQ_H
3F6C CFE3 F00C 00421 movff PLUSW1, IRQ_TMP2
00422
3F70 0E1C 00423 movlw TIA_Vx_PORTA_FRQ_L
3F72 C00B FFE3 00424 movff IRQ_TMP1, PLUSW1
3F76 0E1D 00425 movlw TIA_Vx_PORTA_FRQ_H
3F78 C00C FFE3 00426 movff IRQ_TMP2, PLUSW1
00427
3F7C 0E1A 00428 movlw TIA_Vx_PORTA_CTR_L
3F7E 6AE3 00429 clrf PLUSW1
3F80 0E1B 00430 movlw TIA_Vx_PORTA_CTR_H
3F82 6AE3 00431 clrf PLUSW1
00432
00433
3F84 00434 TIA_SW_Arp_NoV1
00435
3F84 00436 TIA_SW_Arp_NoPorta
00437
3F84 00438 TIA_SW_Arp_NoNewNote
00439
3F84 00440 TIA_SW_Arp_End
3F84 0012 00441 return
00442
00443
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 91
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00444 ;; --------------------------------------------------------------------------
00445 ;; This function handles the gates and initial note frequency
00446 ;; --------------------------------------------------------------------------
3F86 00447 TIA_SW_Note
00448
00449
00450
00451 ;; check note delay counter, set/clear gate bit
3F86 0E12 00452 movlw TIA_Vx_NOTE_DELAY_CTR
3F88 50E3 00453 movf PLUSW1, W
3F8A E003 00454 bz TIA_SW_Note_NoDelay
3F8C 0E12 00455 movlw TIA_Vx_NOTE_DELAY_CTR
3F8E 06E3 00456 decf PLUSW1, F
00457 rgoto TIA_SW_Note_DelayCont
3F90 D03F M bra label
3F92 00458 TIA_SW_Note_NoDelay
3F92 0E03 00459 movlw TIA_Vx_STAT
00460 BRA_IFSET PLUSW1, Vx_STAT_GATE_CLR_REQ, ACCESS, TIA_SW_Note_NoteOffReq
3F94 B4E3 M btfsc reg, bit, reg_a
3F96 D003 M bra label
00461 BRA_IFSET PLUSW1, Vx_STAT_GATE_SET_REQ, ACCESS, TIA_SW_Note_NoteOnReq
3F98 B2E3 M btfsc reg, bit, reg_a
3F9A D01A M bra label
00462 rgoto TIA_SW_Note_DelayCont
3F9C D039 M bra label
00463
3F9E 00464 TIA_SW_Note_NoteOffReq
3F9E 94E3 00465 bcf PLUSW1, Vx_STAT_GATE_CLR_REQ
3FA0 9AE3 00466 bcf PLUSW1, Vx_STAT_GATE_NOTE_ON
3FA2 0E04 00467 movlw TIA_Vx_MODE
00468 ; (don't clear gate bit if GSA (gate stays active)
00469 BRA_IFSET PLUSW1, Vx_MODE_GSA_ACTIVE, ACCESS, TIA_SW_Note_NoteOffReqSkp
3FA4 B0E3 M btfsc reg, bit, reg_a
3FA6 D002 M bra label
3FA8 0E03 00470 movlw TIA_Vx_STAT
3FAA 96E3 00471 bcf PLUSW1, Vx_STAT_GATE_ACTIVE
3FAC 00472 TIA_SW_Note_NoteOffReqSkp
00473 ;; sync voice ENVs
3FAC 0E04 00474 movlw TIA_Vx_MODE
3FAE 30E3 00475 rrf PLUSW1, W
3FB0 40E8 00476 rrncf WREG, W
3FB2 0B0C 00477 andlw 0x0c
3FB4 B10E 00478 btfsc TIA_SW_VOICE, 0, BANKED
3FB6 38E8 00479 swapf WREG, W
3FB8 6E0B 00480 movwf IRQ_TMP1
00481 ;; sync assigned ENVs
3FBA 0E17 00482 movlw TIA_Vx_AMP_MOD
3FBC 50E3 00483 movf PLUSW1, W
3FBE 0B30 00484 andlw 0x30
3FC0 120B 00485 iorwf IRQ_TMP1, F
00486
3FC2 0E16 00487 movlw TIA_Vx_PITCH_MOD
3FC4 38E3 00488 swapf PLUSW1, W
3FC6 0B03 00489 andlw 0x03
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 92
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
3FC8 100B 00490 iorwf IRQ_TMP1, W
3FCA EC57 F024 00491 call TIA_SW_Hlp_ENVRelease
00492 rgoto TIA_SW_Note_DelayCont
3FCE D020 M bra label
00493
3FD0 00494 TIA_SW_Note_NoteOnReq
3FD0 0E03 00495 movlw TIA_Vx_STAT
3FD2 92E3 00496 bcf PLUSW1, Vx_STAT_GATE_SET_REQ
3FD4 8AE3 00497 bsf PLUSW1, Vx_STAT_GATE_NOTE_ON
3FD6 00498 TIA_SW_Note_NoteOnReqSkp
3FD6 0E03 00499 movlw TIA_Vx_STAT
3FD8 86E3 00500 bsf PLUSW1, Vx_STAT_GATE_ACTIVE
00501
00502 ;; sync assigned LFOs
3FDA 0E17 00503 movlw TIA_Vx_AMP_MOD
3FDC 50E3 00504 movf PLUSW1, W
3FDE 0B07 00505 andlw 0x07
3FE0 6E0B 00506 movwf IRQ_TMP1
00507
3FE2 0E16 00508 movlw TIA_Vx_PITCH_MOD
3FE4 50E3 00509 movf PLUSW1, W
3FE6 0B07 00510 andlw 0x07
3FE8 100B 00511 iorwf IRQ_TMP1, W
3FEA EC25 F024 00512 call TIA_SW_Hlp_SyncLFOs
00513
00514 ;; sync voice ENVs
3FEE 0E04 00515 movlw TIA_Vx_MODE
3FF0 30E3 00516 rrf PLUSW1, W
3FF2 40E8 00517 rrncf WREG, W
3FF4 0B0C 00518 andlw 0x0c
3FF6 B10E 00519 btfsc TIA_SW_VOICE, 0, BANKED
3FF8 38E8 00520 swapf WREG, W
3FFA 6E0B 00521 movwf IRQ_TMP1
00522
00523 ;; sync assigned ENVs
3FFC 0E17 00524 movlw TIA_Vx_AMP_MOD
3FFE 50E3 00525 movf PLUSW1, W
4000 0B30 00526 andlw 0x30
4002 120B 00527 iorwf IRQ_TMP1, F
00528
4004 0E16 00529 movlw TIA_Vx_PITCH_MOD
4006 38E3 00530 swapf PLUSW1, W
4008 0B03 00531 andlw 0x03
400A 100B 00532 iorwf IRQ_TMP1, W
400C EC42 F024 00533 call TIA_SW_Hlp_ENVAttack
00534
00535
00536
4010 00537 TIA_SW_Note_DelayCont
00538
4010 0E0C 00539 movlw TIA_Vx_TRANSPOSE
4012 50E3 00540 movf PLUSW1, W
4014 0840 00541 sublw 0x40
4016 0AFF 00542 xorlw 0xff
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 93
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
4018 6E0B 00543 movwf IRQ_TMP1
401A 0E10 00544 movlw TIA_Vx_NOTE
401C 50E3 00545 movf PLUSW1, W
401E 240B 00546 addwf IRQ_TMP1, W
4020 0F01 00547 addlw 1
4022 6E0C 00548 movwf IRQ_TMP2
4024 087F 00549 sublw 0x7f
4026 E207 00550 bc TIA_SW_Note_NoOverflow
4028 0E0C 00551 movlw TIA_Vx_TRANSPOSE
00552 BRA_IFSET PLUSW1, 6, ACCESS, TIA_SW_Note_PosSaturation
402A BCE3 M btfsc reg, bit, reg_a
402C D002 M bra label
402E 00553 TIA_SW_Note_NegSaturation
402E 6A0C 00554 clrf IRQ_TMP2
00555 rgoto TIA_SW_Note_NoOverflow
4030 D002 M bra label
4032 00556 TIA_SW_Note_PosSaturation
4032 0E7F 00557 movlw 0x7f
4034 6E0C 00558 movwf IRQ_TMP2
4036 00559 TIA_SW_Note_NoOverflow
00560 ;; set target frequency depending on note number
4036 500C 00561 movf IRQ_TMP2, W
4038 BEE8 00562 btfsc WREG, 7; the note value
403A 0E7F 00563 movlw 0x7f
403C 6E0C 00564 movwf IRQ_TMP2
00565
403E 0E04 00566 movlw TIA_Vx_MODE
00567 BRA_IFSET PLUSW1, Vx_MODE_KEY_EXTENDED, ACCESS, TIA_SW_Note_KeyMode_Extended
4040 B4E3 M btfsc reg, bit, reg_a
4042 D00D M bra label
4044 00568 TIA_SW_Note_KeyMode_NonExtended
4044 90D8 00569 clrc
4046 0E05 00570 movlw TIA_Vx_KEY_OFFSET
4048 50E3 00571 movf PLUSW1, W
404A 5E0C 00572 subwf IRQ_TMP2, F
404C 0E00 00573 movlw 0x00
404E B0D8 00574 skpnc
4050 0E1F 00575 movlw 0x1f
4052 640C 00576 cpfsgt IRQ_TMP2, ACCESS
4054 500C 00577 movf IRQ_TMP2, W
4056 36E8 00578 rlf WREG, F
4058 36E8 00579 rlf WREG, F
405A 34E8 00580 rlf WREG, W
00581 rgoto TIA_SW_Note_TargetCopy
405C D002 M bra label
00582
405E 00583 TIA_SW_Note_KeyMode_Extended
00584 ;;etendu (7bit note to 8bit pitch)
405E 90D8 00585 clrc
4060 340C 00586 rlf IRQ_TMP2, W
00587
4062 00588 TIA_SW_Note_TargetCopy
4062 6E03 00589 movwf MIOS_PARAMETER1
00590
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 94
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
4064 0E08 00591 movlw TIA_Vx_TARGET_FRQ_H
4066 C003 FFE3 00592 movff MIOS_PARAMETER1, PLUSW1
406A 0E07 00593 movlw TIA_Vx_TARGET_FRQ_L
406C 6AE3 00594 clrf PLUSW1
406E 00595 TIA_SW_Note_End
406E 0012 00596 return
00597
00598
00599 ;; --------------------------------------------------------------------------
00600 ;; This function handles the Note Pitch
00601 ;; --------------------------------------------------------------------------
4070 00602 TIA_SW_Pitch
00603 ;; skip Pitchbender+Finetune processing if PITCHRANGE == zero
4070 0E0D 00604 movlw TIA_Vx_PITCHRANGE
4072 50E3 00605 movf PLUSW1, W
4074 E04D 00606 bz TIA_SW_Pitch_MOD
00607
00608
00609 ;; result stored in IRQ_TMP[12]
4076 6A0B 00610 clrf IRQ_TMP1
4078 6A0C 00611 clrf IRQ_TMP2
407A 6A0D 00612 clrf IRQ_TMP3
00613
00614 ;; calc IRQ_TMP[12] = pitchbender (9-bit signed)
407C 0E0B 00615 movlw TIA_Vx_PITCHBENDER
407E 50E3 00616 movf PLUSW1, W
4080 6E0B 00617 movwf IRQ_TMP1
4082 E007 00618 bz TIA_SW_Pitch_NoPitchBender
4084 00619 TIA_SW_Pitch_PitchBender
4084 90D8 00620 clrc ; multiply with 2
4086 BE0B 00621 btfsc IRQ_TMP1, 7
4088 80D8 00622 setc
408A 360B 00623 rlf IRQ_TMP1, F
408C 360D 00624 rlf IRQ_TMP3, F
408E B00D 00625 btfsc IRQ_TMP3, 0
4090 1E0B 00626 comf IRQ_TMP1, F
4092 00627 TIA_SW_Pitch_NoPitchBender
00628
4092 90D8 00629 clrc
00630 ;; skip tuning if IRQ_TMP[12] == zero
4094 500B 00631 movf IRQ_TMP1, W
4096 100C 00632 iorwf IRQ_TMP2, W
4098 E03B 00633 bz TIA_SW_Pitch_MOD
00634
409A 500B 00635 movf IRQ_TMP1, W
409C 6FFA 00636 movwf MUL_B_L, BANKED
409E 500C 00637 movf IRQ_TMP2, W
40A0 6FFB 00638 movwf MUL_B_H, BANKED
00639
00640 ;; get f_in[target], save it in IRQ_TMP[12]
40A2 90D8 00641 clrc
40A4 0E0C 00642 movlw TIA_Vx_TRANSPOSE
40A6 50E3 00643 movf PLUSW1, W
40A8 0840 00644 sublw 0x40
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 95
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
40AA 0AFF 00645 xorlw 0xff
40AC 6E0E 00646 movwf IRQ_TMP4
40AE 0E10 00647 movlw TIA_Vx_NOTE
40B0 50E3 00648 movf PLUSW1, W
40B2 240E 00649 addwf IRQ_TMP4, W
00650 ;; add pitchrange depending on direction with saturation
00651 BRA_IFSET IRQ_TMP3, 0, ACCESS, TIA_SW_Pitch_Decrease
40B4 B00D M btfsc reg, bit, reg_a
40B6 D009 M bra label
40B8 00652 TIA_SW_Pitch_Increase
00653
40B8 0F01 00654 addlw 1
40BA 6E0C 00655 movwf IRQ_TMP2
40BC 0E0D 00656 movlw TIA_Vx_PITCHRANGE
40BE 50E3 00657 movf PLUSW1, W
40C0 240C 00658 addwf IRQ_TMP2, W
40C2 BEE8 00659 btfsc WREG, 7
40C4 0E7F 00660 movlw 0x7f
40C6 6E0C 00661 movwf IRQ_TMP2
00662 rgoto TIA_SW_Pitch_Increase_Cont
40C8 D006 M bra label
40CA 00663 TIA_SW_Pitch_Decrease
40CA 6E0C 00664 movwf IRQ_TMP2
40CC 0E0D 00665 movlw TIA_Vx_PITCHRANGE
40CE 04E3 00666 decf PLUSW1, W
40D0 5E0C 00667 subwf IRQ_TMP2, F
40D2 BE0C 00668 btfsc IRQ_TMP2, 7
40D4 6A0C 00669 clrf IRQ_TMP2
40D6 00670 TIA_SW_Pitch_Increase_Cont
00671 ;; set target frequency depending on note number
40D6 500C 00672 movf IRQ_TMP2, W
40D8 BEE8 00673 btfsc WREG, 7; the note value
40DA 0E7F 00674 movlw 0x7f
40DC 6E0C 00675 movwf IRQ_TMP2
00676
40DE 0E04 00677 movlw TIA_Vx_MODE
00678 BRA_IFSET PLUSW1, Vx_MODE_KEY_EXTENDED, ACCESS, TIA_SW_Pitch_KeyMode_Extended
40E0 B4E3 M btfsc reg, bit, reg_a
40E2 D00B M bra label
40E4 00679 TIA_SW_Pitch_KeyMode_NonExtended
40E4 90D8 00680 clrc
40E6 0E05 00681 movlw TIA_Vx_KEY_OFFSET
40E8 50E3 00682 movf PLUSW1, W
40EA 5E0C 00683 subwf IRQ_TMP2, F
40EC 0E1F 00684 movlw 0x1f
40EE 640C 00685 cpfsgt IRQ_TMP2, ACCESS
40F0 500C 00686 movf IRQ_TMP2, W
40F2 36E8 00687 rlf WREG, F
40F4 36E8 00688 rlf WREG, F
40F6 34E8 00689 rlf WREG, W
00690 rgoto TIA_SW_Pitch_KeyMode_End
40F8 D002 M bra label
00691
40FA 00692 TIA_SW_Pitch_KeyMode_Extended
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 96
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00693 ;;etendu (7bits to 8bits note)
40FA 90D8 00694 clrc
40FC 340C 00695 rlf IRQ_TMP2, W
00696
40FE 00697 TIA_SW_Pitch_KeyMode_End
40FE 6E04 00698 movwf MIOS_PARAMETER2
4100 6A03 00699 clrf MIOS_PARAMETER1
00700
00701 ;; result: low-byte in WREG and MIOS_PARAMETER1, high-byte in MIOS_PARAMETER2
00702
00703 ;; add and multiply to target frequency
4102 CFE2 FFDA 00704 movff FSR1H, FSR2H
4106 50E1 00705 movf FSR1L, W
4108 0F07 00706 addlw TIA_Vx_TARGET_FRQ_L
410A 6ED9 00707 movwf FSR2L
410C EC6C F024 00708 call TIA_SW_Hlp_AddMul
00709
4110 00710 TIA_SW_Pitch_MOD
4110 0E04 00711 movlw TIA_Vx_MODE
00712 BRA_IFCLR PLUSW1, Vx_MODE_ENV2PITCH_ON, ACCESS, TIA_SW_Pitch_Mods
4112 AAE3 M btfss reg, bit, reg_a
4114 D045 M bra label
00713
00714 ;; store dedicated enveloppe value in MUL_A_[LH],sign in MIOS_PARAMETER3
4116 0E40 00715 movlw 0x40
4118 B10E 00716 btfsc TIA_SW_VOICE, 0
411A 0E80 00717 movlw 0x80
411C EC32 F023 00718 call TIA_SW_Hlp_GetMOD
00719 ;; result in IRQ_TMP[123]
4120 C00D F005 00720 movff IRQ_TMP3, MIOS_PARAMETER3
4124 500C 00721 movf IRQ_TMP2, W
00722 ;btfsc MIOS_PARAMETER3, 0
00723 ;comf IRQ_TMP2, W
4126 0B7F 00724 andlw 0x7f
4128 6FF9 00725 movwf MUL_A_H
412A 500B 00726 movf IRQ_TMP1, W
00727 ;btfsc MIOS_PARAMETER3, 0
00728 ;comf IRQ_TMP1, W
412C 6FF8 00729 movwf MUL_A_L
00730
00731 ;; modulate amplitude
00732 ;; assigned LFOs and ENVs in WREG
412E 0E16 00733 movlw TIA_Vx_PITCH_MOD
4130 50E3 00734 movf PLUSW1, W
4132 0B3F 00735 andlw 0x3f
4134 EC32 F023 00736 call TIA_SW_Hlp_GetMOD
00737 ;; result in IRQ_TMP[123]
00738
4138 00739 TIA_SW_Pitch_Mods_Env_AxB
00740 ;; Modulation mode
4138 0E2A 00741 movlw TIA_Vx_ENV_OPTION
413A 50E3 00742 movf PLUSW1, W
413C 0B03 00743 andlw 0x03
413E 28E8 00744 incf WREG, W
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 97
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00745 BRA_IFCLR WREG, ENVAUDx_MODTYP_AxB, ACCESS, TIA_SW_Pitch_Mods_Env_AB
4140 A2E8 M btfss reg, bit, reg_a
4142 D010 M bra label
00746 BRA_IFSET WREG, ENVAUDx_MODTYP_AB, ACCESS,TIA_SW_Pitch_Mods_Env_AxB_NotDoubled
4144 B0E8 M btfsc reg, bit, reg_a
4146 D002 M bra label
00747 ;; Double the Dedicated ENVAUDx for AxB only Mode
4148 37F8 00748 rlf MUL_A_L, F
414A 37F9 00749 rlf MUL_A_H, F
414C 00750 TIA_SW_Pitch_Mods_Env_AxB_NotDoubled
414C 500C 00751 movf IRQ_TMP2, W
414E 6FFB 00752 movwf MUL_B_H
4150 500B 00753 movf IRQ_TMP1, W
4152 6FFA 00754 movwf MUL_B_L
00755 ;; multiplication
4154 ECDC F019 00756 call MATH_MUL16_16
4158 51FE 00757 movf MUL_R_2, W, BANKED
415A 6E0B 00758 movwf IRQ_TMP1
415C 51FF 00759 movf MUL_R_3, W, BANKED
415E 6E0C 00760 movwf IRQ_TMP2
00761 ;; process sign
4160 5005 00762 movf MIOS_PARAMETER3, W
4162 1A0D 00763 xorwf IRQ_TMP3, F
00764
4164 00765 TIA_SW_Pitch_Mods_Env_AB
00766 ;; Modulation mode
4164 0E2A 00767 movlw TIA_Vx_ENV_OPTION
4166 50E3 00768 movf PLUSW1, W
4168 0B03 00769 andlw 0x03
416A 28E8 00770 incf WREG, W
00771 BRA_IFCLR WREG, ENVAUDx_MODTYP_AB, ACCESS,TIA_SW_Pitch_Mods_Cont
416C A0E8 M btfss reg, bit, reg_a
416E D01E M bra label
4170 5005 00772 movf MIOS_PARAMETER3, W
4172 180D 00773 xorwf IRQ_TMP3, W
4174 E00D 00774 bz TIA_SW_Pitch_Mods_Env_AB_Add
4176 00775 TIA_SW_Pitch_Mods_Env_AB_Sub
4176 500B 00776 movf IRQ_TMP1, W
4178 5DF8 00777 subwf MUL_A_L, W
417A 6E0B 00778 movwf IRQ_TMP1
417C 500C 00779 movf IRQ_TMP2, W
417E 59F9 00780 subwfb MUL_A_H, W
4180 6E0C 00781 movwf IRQ_TMP2
4182 E203 00782 bc TIA_SW_Pitch_Mods_Env_AB_Sub_NoCarry
4184 1E0B 00783 comf IRQ_TMP1, F ;;Sign already in IRQ_TMP3
4186 1E0C 00784 comf IRQ_TMP2, F
00785 rgoto TIA_SW_Pitch_Mods_Cont
4188 D011 M bra label
418A 00786 TIA_SW_Pitch_Mods_Env_AB_Sub_NoCarry
418A C005 F00D 00787 movff MIOS_PARAMETER3, IRQ_TMP3
00788 rgoto TIA_SW_Pitch_Mods_Cont
418E D00E M bra label
00789
4190 00790 TIA_SW_Pitch_Mods_Env_AB_Add
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 98
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
4190 51F8 00791 movf MUL_A_L, W
4192 260B 00792 addwf IRQ_TMP1, F
4194 51F9 00793 movf MUL_A_H, W
4196 220C 00794 addwfc IRQ_TMP2, F
00795 ;; saturate on overflow (set frequency to zero to avoid unwanted HF beeps)
4198 E309 00796 bnc TIA_SW_Pitch_Mods_Cont
419A 680B 00797 setf IRQ_TMP1
419C 680C 00798 setf IRQ_TMP2
00799 rgoto TIA_SW_Pitch_Mods_Cont
419E D006 M bra label
00800
41A0 00801 TIA_SW_Pitch_Mods
00802 ;; modulate pitch
00803 ;; assigned LFOs and ENVs in WREG
41A0 0E16 00804 movlw TIA_Vx_PITCH_MOD
41A2 50E3 00805 movf PLUSW1, W
41A4 0B3F 00806 andlw 0x3f
41A6 E00C 00807 bz TIA_SW_Pitch_CopyFrq
41A8 EC32 F023 00808 call TIA_SW_Hlp_GetMOD
00809 ;; unsigned result in IRQ_TMP[12]
00810 ;; sign in IRQ_TMP3[0]
00811
41AC 00812 TIA_SW_Pitch_Mods_Cont
00813 ;; skip tuning if IRQ_TMP[12] == zero
41AC 500B 00814 movf IRQ_TMP1, W
41AE 100C 00815 iorwf IRQ_TMP2, W
41B0 E007 00816 bz TIA_SW_Pitch_CopyFrq
00817
00818 ;; add to target frequency
41B2 CFE2 FFDA 00819 movff FSR1H, FSR2H
41B6 50E1 00820 movf FSR1L, W
41B8 0F07 00821 addlw TIA_Vx_TARGET_FRQ_L
41BA 6ED9 00822 movwf FSR2L
41BC EC88 F024 00823 call TIA_SW_Hlp_Add16
00824
41C0 00825 TIA_SW_Pitch_CopyFrq
41C0 0E03 00826 movlw TIA_Vx_STAT
00827 BRA_IFSET PLUSW1, Vx_STAT_PORTA_ENABLE, ACCESS, TIA_SW_Pitch_End
41C2 B8E3 M btfsc reg, bit, reg_a
41C4 D017 M bra label
00828
41C6 0E07 00829 movlw TIA_Vx_TARGET_FRQ_L
41C8 CFE3 F003 00830 movff PLUSW1, MIOS_PARAMETER1
41CC 0E08 00831 movlw TIA_Vx_TARGET_FRQ_H
41CE CFE3 F004 00832 movff PLUSW1, MIOS_PARAMETER2
00833
41D2 0E09 00834 movlw TIA_Vx_FRQ_L
41D4 C003 FFE3 00835 movff MIOS_PARAMETER1, PLUSW1
41D8 0E0A 00836 movlw TIA_Vx_FRQ_H
41DA C004 FFE3 00837 movff MIOS_PARAMETER2, PLUSW1
00838
41DE EE21 F002 00839 lfsr FSR2, TIA_AUDF0
41E2 B10E 00840 btfsc TIA_SW_VOICE, 0
41E4 EE21 F003 00841 lfsr FSR2, TIA_AUDF1
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 99
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00842
41E8 1C04 00843 comf MIOS_PARAMETER2, W
41EA 30E8 00844 rrf WREG, W
41EC 30E8 00845 rrf WREG, W
41EE 30E8 00846 rrf WREG, W
41F0 0B1F 00847 andlw 0x1f
41F2 6EDF 00848 movwf INDF2
00849
41F4 00850 TIA_SW_Pitch_End
41F4 0012 00851 return
00852
00853
00854 ;; --------------------------------------------------------------------------
00855 ;; This function handles the Portamento
00856 ;; --------------------------------------------------------------------------
41F6 00857 TIA_SW_Porta
41F6 0E03 00858 movlw TIA_Vx_STAT
00859 BRA_IFCLR PLUSW1, Vx_STAT_PORTA_ENABLE, ACCESS, TIA_SW_Porta_End
41F8 A8E3 M btfss reg, bit, reg_a
41FA D0A0 M bra label
00860
41FC EE21 F002 00861 lfsr FSR2, TIA_AUDF0
4200 B10E 00862 btfsc TIA_SW_VOICE, 0
4202 EE21 F003 00863 lfsr FSR2, TIA_AUDF1
00864
00865 ;; branch depending on portamento option
4206 0E04 00866 movlw TIA_Vx_MODE
00867 BRA_IFCLR PLUSW1, Vx_MODE_PORTA_CONST, ACCESS, TIA_SW_Porta_NORM
4208 A2E3 M btfss reg, bit, reg_a
420A D04C M bra label
00868 ;; ------------------------------------------------------------------
00869 ;; "constant" portamento mode (constant glide time)
420C 00870 TIA_SW_Porta_CONST
00871
00872 ;; counter -> MUL_A_[LH]
420C 0E1A 00873 movlw TIA_Vx_PORTA_CTR_L
420E CFE3 F1F8 00874 movff PLUSW1, MUL_A_L
4212 0E1B 00875 movlw TIA_Vx_PORTA_CTR_H
4214 CFE3 F1F9 00876 movff PLUSW1, MUL_A_H
00877 ;; Add delay to portamento counter -> MUL_A_[LH]
00878 ;; get portamento delay from envelope table
4218 0E0E 00879 movlw TIA_Vx_PORTA_RATE
421A 50E3 00880 movf PLUSW1, W
421C EC3F F02D 00881 call TIA_ENV_TABLE_Get
00882 ;; add result to counter
4220 90D8 00883 clrc
4222 5003 00884 movf MIOS_PARAMETER1, W
4224 27F8 00885 addwf MUL_A_L, F
4226 5004 00886 movf MIOS_PARAMETER2, W
4228 23F9 00887 addwfc MUL_A_H, F
422A E23B 00888 bc TIA_SW_Porta_CONST_Cont_Reached
00889
422C 0E1A 00890 movlw TIA_Vx_PORTA_CTR_L
422E C1F8 FFE3 00891 movff MUL_A_L, PLUSW1
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 100
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
4232 0E1B 00892 movlw TIA_Vx_PORTA_CTR_H
4234 C1F9 FFE3 00893 movff MUL_A_H, PLUSW1
00894
00895 ;; target frequency -> MIOS_PARAMETER[12]
4238 0E07 00896 movlw TIA_Vx_TARGET_FRQ_L
423A CFE3 F003 00897 movff PLUSW1, MIOS_PARAMETER1
423E 0E08 00898 movlw TIA_Vx_TARGET_FRQ_H
4240 CFE3 F004 00899 movff PLUSW1, MIOS_PARAMETER2
00900
00901 ;; get difference between target and previous frequency -> IRQ_TMP[12]
4244 0E1C 00902 movlw TIA_Vx_PORTA_FRQ_L
4246 50E3 00903 movf PLUSW1, W
4248 5C03 00904 subwf MIOS_PARAMETER1, W
424A 6E0B 00905 movwf IRQ_TMP1
424C 0E1D 00906 movlw TIA_Vx_PORTA_FRQ_H
424E 50E3 00907 movf PLUSW1, W
4250 5804 00908 subwfb MIOS_PARAMETER2, W
4252 6E0C 00909 movwf IRQ_TMP2
00910 ;; convert IRQ_TMP[12] to absolute value
4254 900D 00911 bcf IRQ_TMP3, 0
4256 A0D8 00912 btfss STATUS, C
4258 800D 00913 bsf IRQ_TMP3, 0
425A A0D8 00914 btfss STATUS, C
425C 1E0B 00915 comf IRQ_TMP1, F
425E A0D8 00916 btfss STATUS, C
4260 1E0C 00917 comf IRQ_TMP2, F
00918 ;; result in IRQ_TMP[12], sign in IRQ_TMP3[0]
00919
00920 ;; increment four to ensure that target will be reached
4262 0E01 00921 movlw 1
4264 260B 00922 addwf IRQ_TMP1, F
4266 0E00 00923 movlw 0
4268 220C 00924 addwfc IRQ_TMP2, F
426A C00B F1FA 00925 movff IRQ_TMP1, MUL_B_L
426E C00C F1FB 00926 movff IRQ_TMP2, MUL_B_H
00927
00928 ;; calc MUL_A_[LH] * MUL_B_[LH]
4272 ECDC F019 00929 call MATH_MUL16_16
00930 ;; result in MUL_R_2 (low-byte) and MUL_R_3 (high-byte)
00931
00932 ;; branch depending on direction
00933 BRA_IFSET IRQ_TMP3, 0, ACCESS, TIA_SW_Porta_CONST_Down
4276 B00D M btfsc reg, bit, reg_a
4278 D009 M bra label
427A 00934 TIA_SW_Porta_CONST_Up
00935 ;; add scaled value to starting frequency
427A 0E1C 00936 movlw TIA_Vx_PORTA_FRQ_L
427C 50E3 00937 movf PLUSW1, W
427E 25FE 00938 addwf MUL_R_2, W, BANKED
4280 6E0B 00939 movwf IRQ_TMP1
00940
4282 0E1D 00941 movlw TIA_Vx_PORTA_FRQ_H
4284 50E3 00942 movf PLUSW1, W
4286 21FF 00943 addwfc MUL_R_3, W, BANKED
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 101
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
4288 6E0C 00944 movwf IRQ_TMP2
00945
00946 ;; continue at normal portamento routine
00947 rgoto TIA_SW_Porta_CONST_Up_Cont
428A D033 M bra label
00948
428C 00949 TIA_SW_Porta_CONST_Down
00950 ;; subtract scaled value from starting frequency
428C 0E1C 00951 movlw TIA_Vx_PORTA_FRQ_L
428E CFE3 F00B 00952 movff PLUSW1, IRQ_TMP1
4292 0E1D 00953 movlw TIA_Vx_PORTA_FRQ_H
4294 CFE3 F00C 00954 movff PLUSW1, IRQ_TMP2
00955
4298 51FE 00956 movf MUL_R_2, W, BANKED
429A 5E0B 00957 subwf IRQ_TMP1, F
429C 51FF 00958 movf MUL_R_3, W, BANKED
429E 5A0C 00959 subwfb IRQ_TMP2, F
00960
00961 ;; continue at normal portamento routine
00962 rgoto TIA_SW_Porta_CONST_Down_Cont
42A0 D033 M bra label
00963
42A2 00964 TIA_SW_Porta_CONST_Cont_Reached
42A2 D038 00965 bra TIA_SW_Porta_Cont_Reached
00966
00967 ;; ------------------------------------------------------------------
00968 ;; "normal" portamento mode (non-constant glide time)
42A4 00969 TIA_SW_Porta_NORM
00970 ;; multiply rate with current frequency
00971 ;; get portamento multiplier from envelope table -> MUL_A
42A4 0E0E 00972 movlw TIA_Vx_PORTA_RATE
42A6 50E3 00973 movf PLUSW1, W
42A8 EC3F F02D 00974 call TIA_ENV_TABLE_Get
42AC C003 F1F8 00975 movff MIOS_PARAMETER1, MUL_A_L
42B0 C004 F1F9 00976 movff MIOS_PARAMETER2, MUL_A_H
00977
00978 ;; result: low byte in WREG and MIOS_PARAMETER1, high byte in MIOS_PARAMETER2
00979
00980 ;; get current frequency -> MUL_B
00981
42B4 0E09 00982 movlw TIA_Vx_FRQ_L
42B6 CFE3 F1FA 00983 movff PLUSW1, MUL_B_L
42BA CFE3 F00B 00984 movff PLUSW1, IRQ_TMP1
42BE 0E0A 00985 movlw TIA_Vx_FRQ_H
42C0 CFE3 F1FB 00986 movff PLUSW1, MUL_B_H
42C4 CFE3 F00C 00987 movff PLUSW1, IRQ_TMP2
00988
42C8 ECDC F019 00989 call MATH_MUL16_16
00990 ;; result in MUL_R_2 (low-byte) and MUL_R_3 (high-byte)
00991 ;; ensure that result is != 0
42CC 51FE 00992 movf MUL_R_2, W, BANKED
42CE 11FF 00993 iorwf MUL_R_3, W, BANKED
42D0 B4D8 00994 skpnz
42D2 2BFE 00995 incf MUL_R_2, F, BANKED
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 102
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00996
00997 ;; TIA_Vx_FRQ += result (depending on Portamento Direction)
00998 ;movff MUL_R_2, IRQ_TMP1
00999
01000 ;; store target frequency in MIOS_PARAMETER[12]
42D4 0E07 01001 movlw TIA_Vx_TARGET_FRQ_L
42D6 CFE3 F003 01002 movff PLUSW1, MIOS_PARAMETER1
42DA 0E08 01003 movlw TIA_Vx_TARGET_FRQ_H
42DC CFE3 F004 01004 movff PLUSW1, MIOS_PARAMETER2
01005
01006 ;; branch depending on portamento direction
01007 ;; check if value > current value
42E0 5003 01008 movf MIOS_PARAMETER1, W
42E2 5C0B 01009 subwf IRQ_TMP1, W
42E4 5004 01010 movf MIOS_PARAMETER2, W
42E6 580C 01011 subwfb IRQ_TMP2, W
42E8 E20B 01012 bc TIA_SW_Porta_Down
01013
42EA 01014 TIA_SW_Porta_Up ;; decrement FRQ
42EA 51FE 01015 movf MUL_R_2, W
42EC 260B 01016 addwf IRQ_TMP1, F
42EE 51FF 01017 movf MUL_R_3, W, BANKED
42F0 220C 01018 addwfc IRQ_TMP2, F
01019
42F2 01020 TIA_SW_Porta_CONST_Up_Cont ; re-used by ENV2 option
01021 ;; check if value > MAX_VALUE
42F2 90D8 01022 clrc
42F4 500B 01023 movf IRQ_TMP1, W
42F6 5C03 01024 subwf MIOS_PARAMETER1, W
42F8 500C 01025 movf IRQ_TMP2, W
42FA 5804 01026 subwfb MIOS_PARAMETER2, W
42FC E213 01027 bc TIA_SW_Porta_Cont ; branch to end if MAX_VALUE not reached
01028 rgoto TIA_SW_Porta_Cont_Reached ; else copy MAX_VALUE into value and finish portamento
42FE D00A M bra label
01029
4300 01030 TIA_SW_Porta_Down ;; increment FRQ
4300 51FE 01031 movf MUL_R_2, W
4302 5E0B 01032 subwf IRQ_TMP1, F
4304 51FF 01033 movf MUL_R_3, W, BANKED
4306 5A0C 01034 subwfb IRQ_TMP2, F
01035
4308 01036 TIA_SW_Porta_CONST_Down_Cont ; re-used by ENV2 option
01037 ;; check if value < MIN_VALUE
4308 90D8 01038 clrc
430A 5003 01039 movf MIOS_PARAMETER1, W
430C 5C0B 01040 subwf IRQ_TMP1, W
430E 5004 01041 movf MIOS_PARAMETER2, W
4310 580C 01042 subwfb IRQ_TMP2, W
4312 E208 01043 bc TIA_SW_Porta_Cont ; branch to end if MIN_VALUE not reached
01044 ; else copy MIN_VALUE into value and finish portamento
01045 ;rgoto TIA_SW_Porta_Cont_Reached ; else copy MAX_VALUE into value and finish portamento
01046
4314 01047 TIA_SW_Porta_Cont_Reached
4314 0E07 01048 movlw TIA_Vx_TARGET_FRQ_L
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 103
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
4316 CFE3 F00B 01049 movff PLUSW1, IRQ_TMP1
01050
431A 0E08 01051 movlw TIA_Vx_TARGET_FRQ_H
431C CFE3 F00C 01052 movff PLUSW1, IRQ_TMP2
01053
4320 0E03 01054 movlw TIA_Vx_STAT
4322 98E3 01055 bcf PLUSW1, Vx_STAT_PORTA_ENABLE
01056
4324 01057 TIA_SW_Porta_Cont
01058
01059
01060
01061 ;; Copy Freq
4324 0E09 01062 movlw TIA_Vx_FRQ_L
4326 C00B FFE3 01063 movff IRQ_TMP1, PLUSW1
432A 0E0A 01064 movlw TIA_Vx_FRQ_H
432C C00C FFE3 01065 movff IRQ_TMP2, PLUSW1
01066
4330 1C0C 01067 comf IRQ_TMP2, W
4332 30E8 01068 rrf WREG, W
4334 30E8 01069 rrf WREG, W
4336 30E8 01070 rrf WREG, W
4338 0B1F 01071 andlw 0x1f
433A 6EDF 01072 movwf INDF2
01073
433C 01074 TIA_SW_Porta_End
433C 0012 01075 return
01076
01077 ;; --------------------------------------------------------------------------
01078 ;; Help Function used from tia_midi.inc and tia_ccin.inc to reset ENV2
01079 ;; --------------------------------------------------------------------------
433E 01080 TIA_SW_Hlp_PortaCTR_Reset
433E C000 F001 01081 movff FSR0, FSR1
01082
4342 0E1A 01083 movlw TIA_Vx_PORTA_CTR_L
4344 6AE3 01084 clrf PLUSW1, ACCESS
4346 0E1B 01085 movlw TIA_Vx_PORTA_CTR_H
4348 6AE3 01086 clrf PLUSW1, ACCESS
01087
434A 0012 01088 return
01089
01090 ;; --------------------------------------------------------------------------
01091 ;; This function handles the amplitude
01092 ;; --------------------------------------------------------------------------
434C 01093 TIA_SW_Amp
01094 ;; TIA_AUDCx
434C EE21 F000 01095 lfsr FSR2, TIA_BASE
4350 0E04 01096 movlw 0x04
4352 250E 01097 addwf TIA_SW_VOICE, W
4354 6ED9 01098 movwf FSR2L
01099
01100
4356 01101 TIA_SW_Amp_MasterVol
01102 ;; Vx volume * Master Volume
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 104
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
4356 0E0F 01103 movlw TIA_Vx_VOLUME
4358 50E3 01104 movf PLUSW1, W
435A 6E0B 01105 movwf IRQ_TMP1
435C 510B 01106 movf TIA_MASTER_VOL, W
435E 0F01 01107 addlw 1
4360 020B 01108 mulwf IRQ_TMP1
4362 36F3 01109 rlf PRODL, F
4364 34F4 01110 rlf PRODH, W
4366 6E03 01111 movwf MIOS_PARAMETER1
4368 B4D8 01112 skpnz
01113 rgoto TIA_SW_Amp_Gate
436A D090 M bra label
01114
01115 #if 0
01116 movlw TIA_Vx_MODE
01117 BRA_IFCLR PLUSW1, Vx_MODE_ENV2AMP_ON, ACCESS, TIA_SW_Amp_Mods
01118
01119 ;; store dedicated enveloppe value in MUL_A_[LH],sign in MIOS_PARAMETER3
01120 movlw 0x40
01121 btfsc TIA_SW_VOICE, 0
01122 movlw 0x80
01123 call TIA_SW_Hlp_GetMOD
01124 ;; result in IRQ_TMP[123]
01125 movff IRQ_TMP3, MIOS_PARAMETER3
01126 movf IRQ_TMP2, W
01127 andlw 0x7f
01128 movwf MUL_A_H
01129 movf IRQ_TMP1, W
01130 movwf MUL_A_L
01131
01132 ;; modulate amplitude
01133 ;; assigned LFOs and ENVs in WREG
01134 movlw TIA_Vx_PITCH_MOD
01135 movf PLUSW1, W
01136 andlw 0x3f
01137 call TIA_SW_Hlp_GetMOD
01138 ;; result in IRQ_TMP[123]
01139
01140 TIA_SW_Amp_Mods_Env_AxB
01141 ;; Modulation mode
01142 movlw TIA_Vx_ENV_OPTION
01143 movf PLUSW1, W
01144 andlw 0x03
01145 incf WREG, W
01146 BRA_IFCLR WREG, ENVAUDx_MODTYP_AxB, ACCESS, TIA_SW_Amp_Mods_Env_AB
01147 BRA_IFSET WREG, ENVAUDx_MODTYP_AB, ACCESS,TIA_SW_Amp_Mods_Env_AxB_NotDoubled
01148 ;; Double the Dedicated ENVAUDx for AxB only Mode
01149 rlf MUL_A_L, F
01150 rlf MUL_A_H, F
01151 TIA_SW_Amp_Mods_Env_AxB_NotDoubled
01152 movf IRQ_TMP2, W
01153 movwf MUL_B_H
01154 movf IRQ_TMP1, W
01155 movwf MUL_B_L
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 105
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
01156 ;; multiplication
01157 call MATH_MUL16_16
01158 movf MUL_R_2, W, BANKED
01159 movwf IRQ_TMP1
01160 movf MUL_R_3, W, BANKED
01161 movwf IRQ_TMP2
01162 ;; process sign
01163 movf MIOS_PARAMETER3, W
01164 xorwf IRQ_TMP3, F
01165
01166 TIA_SW_Amp_Mods_Env_AB
01167 ;; Modulation mode
01168 movlw TIA_Vx_ENV_OPTION
01169 movf PLUSW1, W
01170 btfsc TIA_SW_VOICE, 0
01171 swapf WREG, W
01172 andlw 0x03
01173 incf WREG, W
01174 BRA_IFCLR WREG, ENVAUDx_MODTYP_AB, ACCESS,TIA_SW_Amp_Mods_Cont
01175 movf MIOS_PARAMETER3, W
01176 bz TIA_SW_Amp_Mods_Env_AB_Pos
01177 TIA_SW_Amp_Mods_Env_AB_Neg
01178 comf MUL_A_L, F
01179 comf MUL_A_H, F
01180 movf IRQ_TMP3, W
01181 bz TIA_SW_Amp_Mods_Env_AB_Pos
01182 movf IRQ_TMP1, W
01183 subwf MUL_A_L, W
01184 movwf IRQ_TMP1
01185 movf IRQ_TMP2, W
01186 subwfb MUL_A_H, W
01187 movwf IRQ_TMP2
01188 clrf IRQ_TMP3
01189 bc TIA_SW_Amp_Mods_Cont
01190 clrf IRQ_TMP1
01191 clrf IRQ_TMP2
01192 rgoto TIA_SW_Amp_Mods_Cont
01193
01194 TIA_SW_Amp_Mods_Env_AB_Pos
01195 movf MUL_A_L, W
01196 addwf IRQ_TMP1, F
01197 movf MUL_A_H, W
01198 addwfc IRQ_TMP2, F
01199 TIA_SW_Amp_Mods_Env_AB_Set
01200 ;; saturate on overflow (set frequency to zero to avoid unwanted HF beeps)
01201 bnc TIA_SW_Amp_Mods_Cont
01202 setf IRQ_TMP1
01203 setf IRQ_TMP2
01204 rgoto TIA_SW_Amp_Mods_Cont
01205
01206 TIA_SW_Amp_Mods
01207 ;; modulate pitch
01208 ;; assigned LFOs and ENVs in WREG
01209 movlw TIA_Vx_PITCH_MOD
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 106
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
01210 movf PLUSW1, W
01211 andlw 0x3f
01212 bz TIA_SW_Amp_CopyFrq
01213 call TIA_SW_Hlp_GetMOD
01214 ;; unsigned result in IRQ_TMP[12]
01215 ;; sign in IRQ_TMP3[0]
01216
01217 TIA_SW_Amp_Mods_Cont
01218 ;; skip tuning if IRQ_TMP[12] == zero
01219 movf IRQ_TMP1, W
01220 iorwf IRQ_TMP2, W
01221 bz TIA_SW_Amp_Mods_End
01222
01223
01224 #else
01225
436C 01226 TIA_SW_Amp_Mods
436C 0E04 01227 movlw TIA_Vx_MODE
01228 BRA_IFCLR PLUSW1, Vx_MODE_ENV2AMP_ON, ACCESS, TIA_SW_Amp_Mods_Cont
436E A8E3 M btfss reg, bit, reg_a
4370 D03D M bra label
01229
01230 ;; Modulation type in MIOS_PARAMETER3
4372 0E2A 01231 movlw TIA_Vx_ENV_OPTION
4374 50E3 01232 movf PLUSW1, W
4376 0B03 01233 andlw 0x03
4378 6E05 01234 movwf MIOS_PARAMETER3
437A 2A05 01235 incf MIOS_PARAMETER3, F
01236
01237 ;; prepare enveloppe value in MIOS_PARAMETER2
01238 ;; env2amp in WREG
437C 0E40 01239 movlw 0x40
437E B10E 01240 btfsc TIA_SW_VOICE, 0
4380 0E80 01241 movlw 0x80
4382 EC32 F023 01242 call TIA_SW_Hlp_GetMOD
01243 ;; result in IRQ_TMP[123]
4386 500C 01244 movf IRQ_TMP2, W
4388 B00D 01245 btfsc IRQ_TMP3, 0
438A 1C0C 01246 comf IRQ_TMP2, W
438C 0B7F 01247 andlw 0x7f
438E 6E04 01248 movwf MIOS_PARAMETER2
01249
01250 ;; modulate amplitude
01251 ;; assigned LFOs and ENVs in WREG
4390 0E17 01252 movlw TIA_Vx_AMP_MOD
4392 50E3 01253 movf PLUSW1, W
4394 0B3F 01254 andlw 0x3f
4396 EC32 F023 01255 call TIA_SW_Hlp_GetMOD
01256 ;; result in IRQ_TMP[123]
01257
01258
439A 01259 TIA_SW_Amp_Mods_Env_AxB
01260 BRA_IFCLR MIOS_PARAMETER3, ENVAUDx_MODTYP_AxB, ACCESS, TIA_SW_Amp_Mods_Env_AB
439A A205 M btfss reg, bit, reg_a
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 107
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
439C D017 M bra label
01261 BRA_IFSET MIOS_PARAMETER3, ENVAUDx_MODTYP_AB, ACCESS, TIA_SW_Amp_Mods_Env_AB_AxB
439E B005 M btfsc reg, bit, reg_a
43A0 D010 M bra label
43A2 3604 01262 rlcf MIOS_PARAMETER2, F
43A4 0E3F 01263 movlw 0x3f
43A6 6EF4 01264 movwf PRODH
43A8 6AF3 01265 clrf PRODL
43AA ECAC F023 01266 call TIA_SW_Hlp_AddOffset16
01267 ;; result in IRQ_TMP[12]
43AE 500C 01268 movf IRQ_TMP2, W
43B0 BE0C 01269 btfsc IRQ_TMP2, 7
43B2 0E7F 01270 movlw 0x7f
01271
43B4 0204 01272 mulwf MIOS_PARAMETER2
43B6 36F3 01273 rlf PRODL, F
43B8 34F4 01274 rlf PRODH, W
43BA BEE8 01275 btfsc WREG, 7
43BC 0E7F 01276 movlw 0x7f
43BE 6E04 01277 movwf MIOS_PARAMETER2
01278 rgoto TIA_SW_Amp_Mods_Env_Cont
43C0 D00C M bra label
01279
43C2 01280 TIA_SW_Amp_Mods_Env_AB_AxB
43C2 500C 01281 movf IRQ_TMP2, W
43C4 0204 01282 mulwf MIOS_PARAMETER2
43C6 50F4 01283 movf PRODH, W
43C8 6E0C 01284 movwf IRQ_TMP2
43CA 6A0B 01285 clrf IRQ_TMP1
01286
43CC 01287 TIA_SW_Amp_Mods_Env_AB
43CC 3004 01288 rrf MIOS_PARAMETER2, W
43CE ECA8 F023 01289 call TIA_SW_Hlp_AddOffset
01290 ;; result in IRQ_TMP[12]
43D2 500C 01291 movf IRQ_TMP2, W
43D4 BE0C 01292 btfsc IRQ_TMP2, 7
43D6 0E7F 01293 movlw 0x7f
43D8 6E04 01294 movwf MIOS_PARAMETER2
01295
43DA 01296 TIA_SW_Amp_Mods_Env_Cont
43DA 5003 01297 movf MIOS_PARAMETER1, W
43DC 04E8 01298 decf WREG, W
43DE 0204 01299 mulwf MIOS_PARAMETER2
43E0 36F3 01300 rlf PRODL, F
43E2 34F4 01301 rlf PRODH, W
43E4 BEE8 01302 btfsc WREG, 7
43E6 0E7F 01303 movlw 0x7f
43E8 6E03 01304 movwf MIOS_PARAMETER1
01305 rgoto TIA_SW_Amp_Mods_End
43EA D00E M bra label
01306
43EC 01307 TIA_SW_Amp_Mods_Cont
01308 ;; modulate amplitude
01309 ;; assigned LFOs and ENVs in WREG
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 108
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
43EC 0E17 01310 movlw TIA_Vx_AMP_MOD
43EE 50E3 01311 movf PLUSW1, W
43F0 0B3F 01312 andlw 0x3f
43F2 E00A 01313 bz TIA_SW_Amp_Mods_End
43F4 EC32 F023 01314 call TIA_SW_Hlp_GetMOD
01315 ;; result in IRQ_TMP[123]
43F8 B00D 01316 btfsc IRQ_TMP3, 0
43FA 6A03 01317 clrf MIOS_PARAMETER1
43FC 5003 01318 movf MIOS_PARAMETER1, W
43FE 020C 01319 mulwf IRQ_TMP2
4400 44F4 01320 rlncf PRODH, W
4402 BEE8 01321 btfsc WREG, 7
4404 0E7F 01322 movlw 0x7f
4406 6E03 01323 movwf MIOS_PARAMETER1
01324 #endif
4408 01325 TIA_SW_Amp_Mods_End
01326
4408 0E03 01327 movlw TIA_Vx_STAT
01328 BRA_IFSET PLUSW1, Vx_STAT_ENV_ACTIVE, ACCESS, TIA_SW_Amp_Vel
440A BCE3 M btfsc reg, bit, reg_a
440C D002 M bra label
01329 BRA_IFCLR PLUSW1, Vx_STAT_GATE_NOTE_ON, ACCESS, TIA_SW_Amp_Vel_End
440E AAE3 M btfss reg, bit, reg_a
4410 D03D M bra label
4412 01330 TIA_SW_Amp_Vel
4412 0E04 01331 movlw TIA_Vx_MODE
01332 BRA_IFCLR PLUSW1, Vx_MODE_VEL2AMP_ON, ACCESS, TIA_SW_Amp_Vel_End
4414 A6E3 M btfss reg, bit, reg_a
4416 D03A M bra label
01333 ;; Velocity calc
4418 0E29 01334 movlw TIA_Vx_DEPTH_VEL
441A 50E3 01335 movf PLUSW1, W
441C 6E0C 01336 movwf IRQ_TMP2
441E 0A40 01337 xorlw 0x40
4420 E035 01338 bz TIA_SW_Amp_Vel_End
01339
4422 6A0D 01340 clrf IRQ_TMP3
4424 0E29 01341 movlw TIA_Vx_DEPTH_VEL
4426 ACE3 01342 btfss PLUSW1, 6, ACCESS
4428 800D 01343 bsf IRQ_TMP3, 0
01344
442A 500C 01345 movf IRQ_TMP2, W
442C 0B3F 01346 andlw 0x3f
01347 ;; depth * velocity
442E 90D8 01348 clrc
4430 34E8 01349 rlf WREG, W
01350 ;addlw 2
01351 ;movwf IRQ_TMP2
01352
4432 B00D 01353 btfsc IRQ_TMP3, 0, ACCESS
01354 rgoto TIA_SW_Amp_Vel_Neg
4434 D01A M bra label
01355
4436 01356 TIA_SW_Amp_Vel_Pos
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 109
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
4436 0F02 01357 addlw 2
4438 6E0C 01358 movwf IRQ_TMP2
01359
443A 0E28 01360 movlw TIA_Vx_LAST_VEL
443C 50E3 01361 movf PLUSW1, W
443E 020C 01362 mulwf IRQ_TMP2
4440 90D8 01363 clrc
4442 36F3 01364 rlf PRODL, F
4444 34F4 01365 rlf PRODH, W
4446 0F01 01366 addlw 1
4448 6E0C 01367 movwf IRQ_TMP2
01368
444A 0E04 01369 movlw TIA_Vx_MODE
01370 BRA_IFSET PLUSW1, Vx_MODE_GSA_ACTIVE, ACCESS, TIA_SW_Amp_Vel_Pos_GSA
444C B0E3 M btfsc reg, bit, reg_a
444E D006 M bra label
4450 5003 01371 movf MIOS_PARAMETER1, W
4452 020C 01372 mulwf IRQ_TMP2
4454 36F3 01373 rlf PRODL, F
4456 34F4 01374 rlf PRODH, W
4458 6E03 01375 movwf MIOS_PARAMETER1
01376 rgoto TIA_SW_Amp_Vel_End
445A D018 M bra label
445C 01377 TIA_SW_Amp_Vel_Pos_GSA
445C 5003 01378 movf MIOS_PARAMETER1, W
445E 087F 01379 sublw 0x7f
4460 020C 01380 mulwf IRQ_TMP2
4462 36F3 01381 rlf PRODL, F
4464 34F4 01382 rlf PRODH, W
4466 2603 01383 addwf MIOS_PARAMETER1, F
01384 rgoto TIA_SW_Amp_Vel_End
4468 D011 M bra label
01385
446A 01386 TIA_SW_Amp_Vel_Neg
446A 1CE8 01387 comf WREG, W
446C 0B7F 01388 andlw 0x7f
446E 0F02 01389 addlw 2
4470 6E0C 01390 movwf IRQ_TMP2
01391
4472 0E28 01392 movlw TIA_Vx_LAST_VEL
4474 50E3 01393 movf PLUSW1, W
4476 020C 01394 mulwf IRQ_TMP2
4478 90D8 01395 clrc
447A 36F3 01396 rlf PRODL, F
447C 34F4 01397 rlf PRODH, W
447E 0F01 01398 addlw 1
4480 6E0C 01399 movwf IRQ_TMP2
01400
4482 5003 01401 movf MIOS_PARAMETER1, W
4484 020C 01402 mulwf IRQ_TMP2
4486 36F3 01403 rlf PRODL, F
4488 34F4 01404 rlf PRODH, W
448A 5E03 01405 subwf MIOS_PARAMETER1, F
01406 ;rgoto TIA_SW_Amp_Vel_End
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 110
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
448C 01407 TIA_SW_Amp_Vel_End
01408
448C 01409 TIA_SW_Amp_Gate
448C 0E04 01410 movlw TIA_Vx_MODE
01411 BRA_IFCLR PLUSW1, Vx_MODE_ENV2AMP_ON, ACCESS, TIA_SW_Amp_Gate_Act
448E A8E3 M btfss reg, bit, reg_a
4490 D003 M bra label
4492 0E03 01412 movlw TIA_Vx_STAT
01413 BRA_IFSET PLUSW1, Vx_STAT_ENV_ACTIVE, ACCESS, TIA_SW_Amp_CopyAmp
4494 BCE3 M btfsc reg, bit, reg_a
4496 D011 M bra label
4498 01414 TIA_SW_Amp_Gate_Act
4498 0E03 01415 movlw TIA_Vx_STAT
01416 BRA_IFSET PLUSW1, Vx_STAT_GATE_ACTIVE, ACCESS, TIA_SW_Amp_CopyAmp
449A B6E3 M btfsc reg, bit, reg_a
449C D00E M bra label
449E 0E0F 01417 movlw 0x0f
44A0 14DF 01418 andwf INDF2, W
44A2 E011 01419 bz TIA_SW_Amp_End
01420
44A4 01421 TIA_SW_Amp_Gate_FadeOut
44A4 6E0C 01422 movwf IRQ_TMP2
44A6 0E02 01423 movlw DEFAULT_TIA_GATE_FADEOUT
44A8 5A0C 01424 subwfb IRQ_TMP2, F
44AA A0D8 01425 skpc
44AC 6A0C 01426 clrf IRQ_TMP2
44AE 0EF0 01427 movlw 0xf0
44B0 16DF 01428 andwf INDF2, F
44B2 0E0F 01429 movlw 0x0f
44B4 140C 01430 andwf IRQ_TMP2, W
44B6 12DF 01431 iorwf INDF2, F
01432 rgoto TIA_SW_Amp_End
44B8 D006 M bra label
01433
44BA 01434 TIA_SW_Amp_Gate_ClrSkp
01435
44BA 01436 TIA_SW_Amp_CopyAmp
44BA 90D8 01437 clrc
44BC 3203 01438 rrf MIOS_PARAMETER1, F
44BE 4203 01439 rrncf MIOS_PARAMETER1, F
44C0 4003 01440 rrncf MIOS_PARAMETER1, W
44C2 0B0F 01441 andlw 0x0f
44C4 6EDF 01442 movwf INDF2
44C6 01443 TIA_SW_Amp_End
01444
44C6 0012 01445 return
01446
01447
01448 ;; --------------------------------------------------------------------------
01449 ;; This function handles the LFOs
01450 ;; --------------------------------------------------------------------------
44C8 01451 TIA_SW_LFO
01452 ;; LFO number in TIA_SW_LFO_NUMBER - calculate base address
01453 ;lfsr FSR1, TIA_LFO1_BASE
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 111
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
01454 ;movf TIA_SW_LFO_NUMBER, W, BANKED
01455 ;mullw TIA_LFOx_RECORD_LEN
01456 ;movf PRODL, W
01457 ;addwf FSR1L, F
01458
01459 ;; clear result register and skip LFO if not enabled
44C8 0E00 01460 movlw TIA_LFOx_MODE
01461 BRA_IFSET PLUSW1, LFOx_MODE_ENABLE, ACCESS, TIA_SW_LFO_Enabled
44CA B0E3 M btfsc reg, bit, reg_a
44CC D005 M bra label
44CE 01462 TIA_SW_LFO_Disabled
44CE 0E05 01463 movlw TIA_LFOx_RVALUE_L
44D0 6AE3 01464 clrf PLUSW1
44D2 0E06 01465 movlw TIA_LFOx_RVALUE_H
44D4 6AE3 01466 clrf PLUSW1
01467 rgoto TIA_SW_LFO_End
44D6 D03D M bra label
44D8 01468 TIA_SW_LFO_Enabled
01469
01470 ;; increment step counter, store result also in IRQ_TMP1
44D8 0E02 01471 movlw TIA_LFOx_CTR
44DA 2AE3 01472 incf PLUSW1, F
44DC CFE3 F00B 01473 movff PLUSW1, IRQ_TMP1
01474
01475 ;; get CTR/ADD entry from LFO table depending on LFO Rate
44E0 0E01 01476 movlw TIA_LFOx_RATE
44E2 50E3 01477 movf PLUSW1, W
44E4 ECCF F02D 01478 call TIA_LFO_TABLE_Get
01479 ;; result: CTR value in WREG and MIOS_PARAMETER1, ADD value in MIOS_PARAMETER2
01480
01481 ;; exit if max step counter value (CTR) not reached
01482 ;; movf MIOS_PARAMETER1, W
44E8 5C0B 01483 subwf IRQ_TMP1, W ; result of LFOx_CTR in IRQ_TMP1
44EA E333 01484 bnc TIA_SW_LFO_End
01485
01486 ;; else clear step counter
44EC 0E02 01487 movlw TIA_LFOx_CTR
44EE 6AE3 01488 clrf PLUSW1
01489
01490 ;; skip multiply routine if LFO_x_DEPTH is 0x40 (zero depth)
44F0 0E04 01491 movlw TIA_LFOx_DEPTH
44F2 50E3 01492 movf PLUSW1, W
44F4 0A40 01493 xorlw 0x40
44F6 E105 01494 bnz TIA_SW_LFO_DepthOk
44F8 01495 TIA_SW_LFO_Depth40
01496 ;; clear 16bit result value registers and exit
44F8 0E05 01497 movlw TIA_LFOx_RVALUE_L
44FA 6AE3 01498 clrf PLUSW1
44FC 0E06 01499 movlw TIA_LFOx_RVALUE_H
44FE 6AE3 01500 clrf PLUSW1
01501 rgoto TIA_SW_LFO_End
4500 D028 M bra label
4502 01502 TIA_SW_LFO_DepthOk
01503
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 112
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
01504 ;; add or subtract ADD value to linear LFO value
4502 0E03 01505 movlw TIA_LFOx_VALUE
4504 CFE3 F00D 01506 movff PLUSW1, IRQ_TMP3
01507
4508 0E00 01508 movlw TIA_LFOx_MODE
01509 BRA_IFSET PLUSW1, LFOx_MODE_DECINC, ACCESS, TIA_SW_LFO_Dec
450A BEE3 M btfsc reg, bit, reg_a
450C D008 M bra label
450E 01510 TIA_SW_LFO_Inc
450E 5004 01511 movf MIOS_PARAMETER2, W ; get ADD value
4510 260D 01512 addwf IRQ_TMP3, F ; add to linear LFO value
4512 E30D 01513 bnc TIA_SW_LFO_Cont ; skip next if max value (0xff) not reached
4514 1C0D 01514 comf IRQ_TMP3, W ; subtract the missing ticks
4516 260D 01515 addwf IRQ_TMP3, F
4518 0E00 01516 movlw TIA_LFOx_MODE
451A 8EE3 01517 bsf PLUSW1, LFOx_MODE_DECINC ; switch to decrement
01518 rgoto TIA_SW_LFO_Cont
451C D008 M bra label
01519
451E 01520 TIA_SW_LFO_Dec
451E 5004 01521 movf MIOS_PARAMETER2, W ; get ADD value
4520 5E0D 01522 subwf IRQ_TMP3, F ; decrement from linear LFO value
4522 E205 01523 bc TIA_SW_LFO_Cont ; skip next if min value (0x00) not reached
4524 1C0D 01524 comf IRQ_TMP3, W ; add the missing ticks
4526 0F01 01525 addlw 1
4528 260D 01526 addwf IRQ_TMP3, F
452A 0E00 01527 movlw TIA_LFOx_MODE
452C 9EE3 01528 bcf PLUSW1, LFOx_MODE_DECINC ; switch to increment
452E 01529 TIA_SW_LFO_Cont
01530
01531 ;; write back IRQ_TMP3 -> TIA_LFOx_VALUE
452E 0E03 01532 movlw TIA_LFOx_VALUE
4530 C00D FFE3 01533 movff IRQ_TMP3, PLUSW1
01534
01535 ;; convert linear LFO value to waveform by using the TIA_SW_LFO_Hlp_Waveform function
01536 ;; LFO mode in IRQ_TMP1
4534 0E00 01537 movlw TIA_LFOx_MODE
4536 CFE3 F00B 01538 movff PLUSW1, IRQ_TMP1
01539 ;; LFO depth in IRQ_TMP2
453A 0E04 01540 movlw TIA_LFOx_DEPTH
453C CFE3 F00C 01541 movff PLUSW1, IRQ_TMP2
01542 ;; linear LFO value in WREG
4540 500D 01543 movf IRQ_TMP3, W
01544 ;; process waveform
01545
4542 ECD2 F023 01546 call TIA_SW_LFO_Hlp_Waveform
01547
01548 ;; store 16bit result in RVALUE registers
4546 0E05 01549 movlw TIA_LFOx_RVALUE_L
4548 CFF3 FFE3 01550 movff PRODL, PLUSW1
454C 0E06 01551 movlw TIA_LFOx_RVALUE_H
454E CFF4 FFE3 01552 movff PRODH, PLUSW1
4552 01553 TIA_SW_LFO_End
4552 0012 01554 return
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 113
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
01555
01556
01557 ;; --------------------------------------------------------------------------
01558 ;; This function handles the ENVs
01559 ;; expects TIA_ENVx_CURVES bitfield (lower or upper nibble) in WREG
01560 ;;
01561 ;; TIA_ENVx_CURVES.7 and TIA_ENVx_CURVES.3 contain the ACCENT flag which
01562 ;; is used in TB303 mode (copied to IRQ_TMP4.3
01563 ;; --------------------------------------------------------------------------
4554 01564 TIA_SW_ENV
4554 0B07 01565 andlw 0x07
4556 6E0E 01566 movwf IRQ_TMP4
01567
4558 510F 01568 movf TIA_SW_ENV_NUMBER, W, BANKED
455A 0BFE 01569 andlw 0xfe
455C E108 01570 bnz TIA_SW_ENV_VxStatSkp
01571
01572 ;; Vx dedicated Env clear/set Active
455E 0E03 01573 movlw TIA_Vx_STAT
4560 9CDB 01574 bcf PLUSW2, Vx_STAT_ENV_ACTIVE
4562 0E00 01575 movlw TIA_ENVx_MODE
4564 50E3 01576 movf PLUSW1, W
4566 0B1F 01577 andlw 0x1f
4568 E002 01578 bz TIA_SW_ENV_VxStatSkp
456A 0E03 01579 movlw TIA_Vx_STAT
456C 8CDB 01580 bsf PLUSW2, Vx_STAT_ENV_ACTIVE
456E 01581 TIA_SW_ENV_VxStatSkp
01582
01583 ;; prepare call of TIA_SW_ENV_GetBendedValue
456E 0E07 01584 movlw TIA_ENVx_CURVE
4570 CFE3 F00C 01585 movff PLUSW1, IRQ_TMP2
4574 0E02 01586 movlw TIA_ENVx_CTR_H
4576 CFE3 F00B 01587 movff PLUSW1, IRQ_TMP1
01588
01589 ;; branch depending on ENV state
457A 0E00 01590 movlw TIA_ENVx_MODE
01591 BRA_IFSET PLUSW1, ENVx_MODE_RELEASE, ACCESS, TIA_SW_ENV_Release
457C B6E3 M btfsc reg, bit, reg_a
457E D03E M bra label
01592 BRA_IFCLR PLUSW1, ENVx_MODE_ATTACK, ACCESS, TIA_SW_ENV_Calc
4580 A0E3 M btfss reg, bit, reg_a
4582 D054 M bra label
01593 BRA_IFSET PLUSW1, ENVx_MODE_SUSTAIN, ACCESS, TIA_SW_ENV_Sustain
4584 B4E3 M btfsc reg, bit, reg_a
4586 D032 M bra label
01594 BRA_IFSET PLUSW1, ENVx_MODE_DECAY, ACCESS, TIA_SW_ENV_Decay
4588 B2E3 M btfsc reg, bit, reg_a
458A D013 M bra label
01595
458C 01596 TIA_SW_ENV_Attack
01597 ;; get attack rate depending on curve setting
458C 0E03 01598 movlw TIA_ENVx_ATTACK
458E CFE3 F00D 01599 movff PLUSW1, IRQ_TMP3
4592 500E 01600 movf IRQ_TMP4, W
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 114
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
4594 0B01 01601 andlw 0x01
4596 ECA1 F024 01602 call TIA_SW_ENV_GetBendedValue
01603 ;; result: low byte in WREG and MIOS_PARAMETER1, high byte in MIOS_PARAMETER2
01604
01605 ;; add to ENV counter
459A 0E01 01606 movlw TIA_ENVx_CTR_L
459C 50E3 01607 movf PLUSW1, W
459E 2603 01608 addwf MIOS_PARAMETER1, F
45A0 0E02 01609 movlw TIA_ENVx_CTR_H
45A2 50E3 01610 movf PLUSW1, W
45A4 2204 01611 addwfc MIOS_PARAMETER2, F
45A6 E342 01612 bnc TIA_SW_ENV_Calc
01613
01614 ;; if value >= 0xffff: set to 0xffff, switch to Decay
45A8 6803 01615 setf MIOS_PARAMETER1
45AA 6804 01616 setf MIOS_PARAMETER2
45AC 0E00 01617 movlw TIA_ENVx_MODE
45AE 82E3 01618 bsf PLUSW1, ENVx_MODE_DECAY
01619 rgoto TIA_SW_ENV_Calc
45B0 D03D M bra label
01620
01621
01622
45B2 01623 TIA_SW_ENV_Decay
01624 ;; get decay rate depending on curve setting
45B2 0E04 01625 movlw TIA_ENVx_DECAY
45B4 CFE3 F00D 01626 movff PLUSW1, IRQ_TMP3
01627
45B8 500E 01628 movf IRQ_TMP4, W
45BA 0B02 01629 andlw 0x02
45BC ECA1 F024 01630 call TIA_SW_ENV_GetBendedValue
01631 ;; result: low byte in WREG and MIOS_PARAMETER1, high byte in MIOS_PARAMETER2
01632
01633 ;; subtraction with current counter value
45C0 0E01 01634 movlw TIA_ENVx_CTR_L
45C2 CFE3 F00B 01635 movff PLUSW1, IRQ_TMP1
45C6 0E02 01636 movlw TIA_ENVx_CTR_H
45C8 CFE3 F00C 01637 movff PLUSW1, IRQ_TMP2
01638
45CC 5003 01639 movf MIOS_PARAMETER1, W
45CE 5C0B 01640 subwf IRQ_TMP1, W
45D0 6E03 01641 movwf MIOS_PARAMETER1
45D2 5004 01642 movf MIOS_PARAMETER2, W
45D4 580C 01643 subwfb IRQ_TMP2, W
45D6 6E04 01644 movwf MIOS_PARAMETER2
45D8 E309 01645 bnc TIA_SW_ENV_Sustain
01646
01647 ;; check if counter value < sustain value
45DA 0E05 01648 movlw TIA_ENVx_SUSTAIN
45DC 34E3 01649 rlf PLUSW1, W
45DE 0BFE 01650 andlw 0xfe
45E0 6E0B 01651 movwf IRQ_TMP1
45E2 0E00 01652 movlw 0x00
45E4 5C03 01653 subwf MIOS_PARAMETER1, W
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 115
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
45E6 500B 01654 movf IRQ_TMP1, W
45E8 5804 01655 subwfb MIOS_PARAMETER2, W
45EA E220 01656 bc TIA_SW_ENV_Calc
01657
45EC 01658 TIA_SW_ENV_Sustain
01659 ;; write sustain value into counter
45EC 0E05 01660 movlw TIA_ENVx_SUSTAIN
45EE 34E3 01661 rlf PLUSW1, W
45F0 0BFE 01662 andlw 0xfe
45F2 6E04 01663 movwf MIOS_PARAMETER2
45F4 6A03 01664 clrf MIOS_PARAMETER1
01665
45F6 0E00 01666 movlw TIA_ENVx_MODE
45F8 84E3 01667 bsf PLUSW1, ENVx_MODE_SUSTAIN
01668 rgoto TIA_SW_ENV_Calc
45FA D018 M bra label
01669
45FC 01670 TIA_SW_ENV_Release
01671 ;; get release rate depending on curve setting
45FC 0E06 01672 movlw TIA_ENVx_RELEASE
45FE CFE3 F00D 01673 movff PLUSW1, IRQ_TMP3
4602 500E 01674 movf IRQ_TMP4, W
4604 0B04 01675 andlw 0x04
4606 ECA1 F024 01676 call TIA_SW_ENV_GetBendedValue
01677 ;; result: low byte in WREG and MIOS_PARAMETER1, high byte in MIOS_PARAMETER2
01678
01679 ;; subtraction with current counter value
460A 0E01 01680 movlw TIA_ENVx_CTR_L
460C CFE3 F00B 01681 movff PLUSW1, IRQ_TMP1
4610 0E02 01682 movlw TIA_ENVx_CTR_H
4612 CFE3 F00C 01683 movff PLUSW1, IRQ_TMP2
01684
4616 5003 01685 movf MIOS_PARAMETER1, W
4618 5C0B 01686 subwf IRQ_TMP1, W
461A 6E03 01687 movwf MIOS_PARAMETER1
461C 5004 01688 movf MIOS_PARAMETER2, W
461E 580C 01689 subwfb IRQ_TMP2, W
4620 6E04 01690 movwf MIOS_PARAMETER2
4622 E204 01691 bc TIA_SW_ENV_Calc
01692
01693 ;; zero reached
4624 6A03 01694 clrf MIOS_PARAMETER1
4626 6A04 01695 clrf MIOS_PARAMETER2
4628 0E00 01696 movlw TIA_ENVx_MODE
462A 6AE3 01697 clrf PLUSW1
462C 01698 TIA_SW_ENV_Calc
01699 ;; copy MIOS_PARAMETER[12] to TIA_ENVx_CTR_[LH]
462C 0E01 01700 movlw TIA_ENVx_CTR_L
462E C003 FFE3 01701 movff MIOS_PARAMETER1, PLUSW1
4632 0E02 01702 movlw TIA_ENVx_CTR_H
4634 C004 FFE3 01703 movff MIOS_PARAMETER2, PLUSW1
01704
01705 ;; calculate envelope value depending on envelope rate
01706
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 116
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
01707 ;; clear ENV ResultValue Registers
4638 0E09 01708 movlw TIA_ENVx_RVALUE_L
463A 6AE3 01709 clrf PLUSW1
463C 0E0A 01710 movlw TIA_ENVx_RVALUE_H
463E 6AE3 01711 clrf PLUSW1
01712
01713 ;; skip multiply routine if ENV_x_DEPTH is 0x40
4640 0E08 01714 movlw TIA_ENVx_DEPTH
4642 50E3 01715 movf PLUSW1, W
4644 0A40 01716 xorlw 0x40
4646 E00D 01717 bz TIA_SW_ENV_End
01718
01719 ;; convert linear ENV value to waveform by using the TIA_SW_ENV_Hlp_Waveform function
01720 ;; depth in IRQ_TMP2
4648 0E08 01721 movlw TIA_ENVx_DEPTH
464A CFE3 F00C 01722 movff PLUSW1, IRQ_TMP2
01723 ;; linear ENV value in WREG
464E 0E02 01724 movlw TIA_ENVx_CTR_H
4650 30E3 01725 rrf PLUSW1, W
01726 ;; process waveform
4652 ECCA F023 01727 call TIA_SW_ENV_Hlp_Waveform
01728 ;; store 16bit result in RVALUE registers
4656 0E09 01729 movlw TIA_ENVx_RVALUE_L
4658 CFF3 FFE3 01730 movff PRODL, PLUSW1
465C 0E0A 01731 movlw TIA_ENVx_RVALUE_H
465E CFF4 FFE3 01732 movff PRODH, PLUSW1
4662 01733 TIA_SW_ENV_End
4662 0012 01734 return
01735
01736
01737 ;; --------------------------------------------------------------------------
01738 ;; Help Function: add modulation values depending on enabled sources
01739 ;; In: Enabled LFOs and ENCs in WREG, 7-bit offset in IRQ_TMP4
01740 ;; Out: signed 16bit result value in IRQ_TMP[12]
01741 ;; --------------------------------------------------------------------------
4664 01742 TIA_SW_Hlp_GetMOD
4664 6A0B 01743 clrf IRQ_TMP1
4666 6A0C 01744 clrf IRQ_TMP2
4668 6A0D 01745 clrf IRQ_TMP3
466A 6E0E 01746 movwf IRQ_TMP4 ; save assigned LFOs and ENVs in IRQ_TMP4
01747
01748 ;; add all enabled LFO values (16 bit -> 24 bit)
01749 BRA_IFCLR IRQ_TMP4, ASSIGNED_LFOS_1, ACCESS, TIA_SW_Hlp_GetMOD_NoLFO1
466C A00E M btfss reg, bit, reg_a
466E D00A M bra label
4670 01750 TIA_SW_Hlp_GetMOD_LFO1
4670 51A5 01751 movf TIA_LFO1_BASE + TIA_LFOx_RVALUE_L, W, BANKED
4672 260B 01752 addwf IRQ_TMP1, F
4674 51A6 01753 movf TIA_LFO1_BASE + TIA_LFOx_RVALUE_H, W, BANKED
4676 220C 01754 addwfc IRQ_TMP2, F
4678 0E00 01755 movlw 0x00
467A BFA6 01756 btfsc TIA_LFO1_BASE + TIA_LFOx_RVALUE_H, 7, BANKED
467C 0EFF 01757 movlw 0xff
467E B0D8 01758 skpnc
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 117
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
4680 0F01 01759 addlw 1
4682 260D 01760 addwf IRQ_TMP3, F
4684 01761 TIA_SW_Hlp_GetMOD_NoLFO1
01762
01763 BRA_IFCLR IRQ_TMP4, ASSIGNED_LFOS_2, ACCESS, TIA_SW_Hlp_GetMOD_NoLFO2
4684 A20E M btfss reg, bit, reg_a
4686 D00A M bra label
4688 01764 TIA_SW_Hlp_GetMOD_LFO2
4688 51AC 01765 movf TIA_LFO2_BASE + TIA_LFOx_RVALUE_L, W, BANKED
468A 260B 01766 addwf IRQ_TMP1, F
468C 51AD 01767 movf TIA_LFO2_BASE + TIA_LFOx_RVALUE_H, W, BANKED
468E 220C 01768 addwfc IRQ_TMP2, F
4690 0E00 01769 movlw 0x00
4692 BFAD 01770 btfsc TIA_LFO2_BASE + TIA_LFOx_RVALUE_H, 7, BANKED
4694 0EFF 01771 movlw 0xff
4696 B0D8 01772 skpnc
4698 0F01 01773 addlw 1
469A 260D 01774 addwf IRQ_TMP3, F
469C 01775 TIA_SW_Hlp_GetMOD_NoLFO2
01776
01777 BRA_IFCLR IRQ_TMP4, ASSIGNED_LFOS_3, ACCESS, TIA_SW_Hlp_GetMOD_NoLFO3
469C A40E M btfss reg, bit, reg_a
469E D00A M bra label
46A0 01778 TIA_SW_Hlp_GetMOD_LFO3
46A0 51B3 01779 movf TIA_LFO3_BASE + TIA_LFOx_RVALUE_L, W, BANKED
46A2 260B 01780 addwf IRQ_TMP1, F
46A4 51B4 01781 movf TIA_LFO3_BASE + TIA_LFOx_RVALUE_H, W, BANKED
46A6 220C 01782 addwfc IRQ_TMP2, F
46A8 0E00 01783 movlw 0x00
46AA BFB4 01784 btfsc TIA_LFO3_BASE + TIA_LFOx_RVALUE_H, 7, BANKED
46AC 0EFF 01785 movlw 0xff
46AE B0D8 01786 skpnc
46B0 0F01 01787 addlw 1
46B2 260D 01788 addwf IRQ_TMP3, F
46B4 01789 TIA_SW_Hlp_GetMOD_NoLFO3
01790
01791 BRA_IFCLR IRQ_TMP4, ASSIGNED_LFOS_4, ACCESS, TIA_SW_Hlp_GetMOD_NoLFO4
46B4 A60E M btfss reg, bit, reg_a
46B6 D00A M bra label
46B8 01792 TIA_SW_Hlp_GetMOD_LFO4
46B8 51BA 01793 movf TIA_LFO4_BASE + TIA_LFOx_RVALUE_L, W, BANKED
46BA 260B 01794 addwf IRQ_TMP1, F
46BC 51BB 01795 movf TIA_LFO4_BASE + TIA_LFOx_RVALUE_H, W, BANKED
46BE 220C 01796 addwfc IRQ_TMP2, F
46C0 0E00 01797 movlw 0x00
46C2 BFBB 01798 btfsc TIA_LFO4_BASE + TIA_LFOx_RVALUE_H, 7, BANKED
46C4 0EFF 01799 movlw 0xff
46C6 B0D8 01800 skpnc
46C8 0F01 01801 addlw 1
46CA 260D 01802 addwf IRQ_TMP3, F
46CC 01803 TIA_SW_Hlp_GetMOD_NoLFO4
01804
01805 BRA_IFCLR IRQ_TMP4, ASSIGNED_ENVS_1, ACCESS, TIA_SW_Hlp_GetMOD_NoENV1
46CC A80E M btfss reg, bit, reg_a
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 118
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
46CE D00A M bra label
46D0 01806 TIA_SW_Hlp_GetMOD_ENV1
46D0 51DB 01807 movf TIA_ENV1_BASE + TIA_ENVx_RVALUE_L, W, BANKED
46D2 260B 01808 addwf IRQ_TMP1, F
46D4 51DC 01809 movf TIA_ENV1_BASE + TIA_ENVx_RVALUE_H, W, BANKED
46D6 220C 01810 addwfc IRQ_TMP2, F
46D8 0E00 01811 movlw 0x00
46DA BFDC 01812 btfsc TIA_ENV1_BASE + TIA_ENVx_RVALUE_H, 7, BANKED
46DC 0EFF 01813 movlw 0xff
46DE B0D8 01814 skpnc
46E0 0F01 01815 addlw 1
46E2 260D 01816 addwf IRQ_TMP3, F
46E4 01817 TIA_SW_Hlp_GetMOD_NoENV1
01818
01819 BRA_IFCLR IRQ_TMP4, ASSIGNED_ENVS_2, ACCESS, TIA_SW_Hlp_GetMOD_NoENV2
46E4 AA0E M btfss reg, bit, reg_a
46E6 D00A M bra label
46E8 01820 TIA_SW_Hlp_GetMOD_ENV2
46E8 51E6 01821 movf TIA_ENV2_BASE + TIA_ENVx_RVALUE_L, W, BANKED
46EA 260B 01822 addwf IRQ_TMP1, F
46EC 51E7 01823 movf TIA_ENV2_BASE + TIA_ENVx_RVALUE_H, W, BANKED
46EE 220C 01824 addwfc IRQ_TMP2, F
46F0 0E00 01825 movlw 0x00
46F2 BFE7 01826 btfsc TIA_ENV2_BASE + TIA_ENVx_RVALUE_H, 7, BANKED
46F4 0EFF 01827 movlw 0xff
46F6 B0D8 01828 skpnc
46F8 0F01 01829 addlw 1
46FA 260D 01830 addwf IRQ_TMP3, F
46FC 01831 TIA_SW_Hlp_GetMOD_NoENV2
01832
01833 BRA_IFCLR IRQ_TMP4, ASSIGNED_ENVS_A0, ACCESS, TIA_SW_Hlp_GetMOD_NoENVAUD0
46FC AC0E M btfss reg, bit, reg_a
46FE D00A M bra label
4700 01834 TIA_SW_Hlp_GetMOD_ENVAUD0
4700 51C5 01835 movf TIA_ENVAUD0_BASE + TIA_ENVx_RVALUE_L, W, BANKED
4702 260B 01836 addwf IRQ_TMP1, F
4704 51C6 01837 movf TIA_ENVAUD0_BASE + TIA_ENVx_RVALUE_H, W, BANKED
4706 220C 01838 addwfc IRQ_TMP2, F
4708 0E00 01839 movlw 0x00
470A BFC6 01840 btfsc TIA_ENVAUD0_BASE + TIA_ENVx_RVALUE_H, 7, BANKED
470C 0EFF 01841 movlw 0xff
470E B0D8 01842 skpnc
4710 0F01 01843 addlw 1
4712 260D 01844 addwf IRQ_TMP3, F
4714 01845 TIA_SW_Hlp_GetMOD_NoENVAUD0
01846
01847 BRA_IFCLR IRQ_TMP4, ASSIGNED_ENVS_A1, ACCESS, TIA_SW_Hlp_GetMOD_NoENVAUD1
4714 AE0E M btfss reg, bit, reg_a
4716 D00A M bra label
4718 01848 TIA_SW_Hlp_GetMOD_ENVAUD1
4718 51D0 01849 movf TIA_ENVAUD1_BASE + TIA_ENVx_RVALUE_L, W, BANKED
471A 260B 01850 addwf IRQ_TMP1, F
471C 51D1 01851 movf TIA_ENVAUD1_BASE + TIA_ENVx_RVALUE_H, W, BANKED
471E 220C 01852 addwfc IRQ_TMP2, F
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 119
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
4720 0E00 01853 movlw 0x00
4722 BFD1 01854 btfsc TIA_ENVAUD1_BASE + TIA_ENVx_RVALUE_H, 7, BANKED
4724 0EFF 01855 movlw 0xff
4726 B0D8 01856 skpnc
4728 0F01 01857 addlw 1
472A 260D 01858 addwf IRQ_TMP3, F
472C 01859 TIA_SW_Hlp_GetMOD_NoENVAUD1
01860
01861 ;; saturate to absolute 16 bit-value, keep sign in IRQ_TMP3[0]
01862 BRA_IFSET IRQ_TMP3, 7, ACCESS, TIA_SW_Hlp_GetMOD_Negative
472C BE0D M btfsc reg, bit, reg_a
472E D006 M bra label
4730 01863 TIA_SW_Hlp_GetMOD_Positive
4730 500D 01864 movf IRQ_TMP3, W
4732 E00D 01865 bz TIA_SW_Hlp_GetMOD_Cont
4734 680B 01866 setf IRQ_TMP1
4736 680C 01867 setf IRQ_TMP2
4738 6A0D 01868 clrf IRQ_TMP3 ; save sign in IRQ_TMP3
01869 rgoto TIA_SW_Hlp_GetMOD_Cont
473A D009 M bra label
01870
473C 01871 TIA_SW_Hlp_GetMOD_Negative
473C 500D 01872 movf IRQ_TMP3, W
473E 0B7F 01873 andlw 0x7f
4740 E102 01874 bnz TIA_SW_Hlp_GetMOD_Negative_C
4742 6A0B 01875 clrf IRQ_TMP1
4744 6A0C 01876 clrf IRQ_TMP2
4746 01877 TIA_SW_Hlp_GetMOD_Negative_C
4746 1E0B 01878 comf IRQ_TMP1, F ; invert result
4748 1E0C 01879 comf IRQ_TMP2, F
474A 0E01 01880 movlw 0x01 ; save sign in IRQ_TMP3
474C 6E0D 01881 movwf IRQ_TMP3
474E 01882 TIA_SW_Hlp_GetMOD_Cont
01883
474E 0012 01884 return
01885
01886 ;; --------------------------------------------------------------------------
01887 ;; Help Function to add a 7-bit offset to IRQ_TMP[123] and saturate
01888 ;; In: offset in WREG, absolute 16-bit value in IRQ_TMP[12], sign in IRQ_TMP3[0]
01889 ;; Out: New value in IRQ_TMP[12]
01890 ;; --------------------------------------------------------------------------
4750 01891 TIA_SW_Hlp_AddOffset
4750 90D8 01892 clrc
4752 34E8 01893 rlf WREG, W
4754 6EF4 01894 movwf PRODH
4756 6AF3 01895 clrf PRODL
01896 ;; rgoto TIA_SW_Hlp_AddOffset16
01897
01898 ;; --------------------------------------------------------------------------
01899 ;; Help Function to add a 16-bit offset to IRQ_TMP[123] and saturate
01900 ;; In: offset in PROD[LH], absolute 16-bit value in IRQ_TMP[12], sign in IRQ_TMP3[0]
01901 ;; Out: New value in IRQ_TMP[12]
01902 ;; --------------------------------------------------------------------------
4758 01903 TIA_SW_Hlp_AddOffset16
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 120
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
01904 ;; add offset and saturate
01905 BRA_IFSET IRQ_TMP3, 0, ACCESS, TIA_SW_Hlp_AddOffset16_Negative
4758 B00D M btfsc reg, bit, reg_a
475A D008 M bra label
475C 01906 TIA_SW_Hlp_AddOffset16_Positive
475C 50F3 01907 movf PRODL, W ; add offset
475E 260B 01908 addwf IRQ_TMP1, F
4760 50F4 01909 movf PRODH, W
4762 220C 01910 addwfc IRQ_TMP2, F
4764 E30C 01911 bnc TIA_SW_Hlp_AddOffset16_End
4766 680B 01912 setf IRQ_TMP1 ; saturate
4768 680C 01913 setf IRQ_TMP2
01914 rgoto TIA_SW_Hlp_AddOffset16_End
476A D009 M bra label
476C 01915 TIA_SW_Hlp_AddOffset16_Negative
476C 500B 01916 movf IRQ_TMP1, W ; subtract offset
476E 5CF3 01917 subwf PRODL, W
4770 6E0B 01918 movwf IRQ_TMP1
4772 500C 01919 movf IRQ_TMP2, W
4774 58F4 01920 subwfb PRODH, W
4776 6E0C 01921 movwf IRQ_TMP2
4778 E202 01922 bc TIA_SW_Hlp_AddOffset16_End
477A 6A0B 01923 clrf IRQ_TMP1
477C 6A0C 01924 clrf IRQ_TMP2
477E 01925 TIA_SW_Hlp_AddOffset16_End
01926
477E 0012 01927 return
01928
01929 ;; --------------------------------------------------------------------------
01930 ;; Help Function: Get absolute value
01931 ;; IN: signed 16-bit value in IRQ_TMP[12]
01932 ;; Out: unsigned absolute value in IRQ_TMP[12]
01933 ;; sign in IRQ_TMP3[0]
01934 ;; --------------------------------------------------------------------------
4780 01935 TIA_SW_Hlp_GetAbs16
01936 ;; convert IRQ_TMP[12] to unsigned integer, keep sign in IRQ_TMP3[0]
4780 6A0D 01937 clrf IRQ_TMP3
01938 BRA_IFCLR IRQ_TMP2, 7, ACCESS, TIA_SW_Hlp_GetABS16_Pos
4782 AE0C M btfss reg, bit, reg_a
4784 D006 M bra label
4786 01939 TIA_SW_Hlp_GetABS16_Neg
4786 800D 01940 bsf IRQ_TMP3, 0 ; memorize sign in IRQ_TMP3[0]
4788 1E0B 01941 comf IRQ_TMP1, F
478A 1E0C 01942 comf IRQ_TMP2, F
478C 2A0B 01943 incf IRQ_TMP1, F
478E B4D8 01944 skpnz
4790 2A0C 01945 incf IRQ_TMP2, F
4792 01946 TIA_SW_Hlp_GetABS16_Pos
4792 0012 01947 return
01948
01949
01950 ;; --------------------------------------------------------------------------
01951 ;; Help Function for ENV Waveforms (resuses the LFO Waveform routine)
01952 ;; In: ENV_x_VALUE in WREG
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 121
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
01953 ;; ENV_x_DEPTH in IRQ_TMP2,
01954 ;; Accent flag in IRQ_TMP4.3
01955 ;; Out: Result in PROD[LH]
01956 ;; --------------------------------------------------------------------------
4794 01957 TIA_SW_ENV_Hlp_Waveform
01958
01959 ; BRA_IFCLR TIA_SE_OPTION, SE_OPTION_TB303, BANKED, TIA_SW_ENV_Hlp_Waveform_NotTB303
01960 ;TIA_SW_ENV_Hlp_Waveform_TB303
01961 ; movwf IRQ_TMP1
01962 ; ;; in TB303 mode the depth parameter is used as "env mod" which is always positive
01963 ; ;; modify depth depending on ACCENT flag
01964 ; rrf IRQ_TMP2, W
01965 ; andlw 0x3f
01966 ; movwf IRQ_TMP2
01967 ; BRA_IFCLR IRQ_TMP4, 3, ACCESS, TIA_SW_ENV_Hlp_Waveform_NoAcc
01968 ;TIA_SW_ENV_Hlp_Waveform_Acc
01969 ;; addlw 0x10
01970 ; movwf IRQ_TMP2
01971 ;TIA_SW_ENV_Hlp_Waveform_NoAcc
01972 ; movf IRQ_TMP1, W
01973 ; andlw 0x7f
01974 ; mulwf IRQ_TMP2, ACCESS
01975 ; return
01976
01977 ;TIA_SW_ENV_Hlp_Waveform_NotTB303
01978 ;; set mode to 0x10, don't overwrite WREG
4794 6A0B 01979 clrf IRQ_TMP1
4796 880B 01980 bsf IRQ_TMP1, 4 ; (triangle waveform)
01981
01982 ;; convert linear envelope value
4798 0B7F 01983 andlw 0x7f
479A BC0C 01984 btfsc IRQ_TMP2, 6; shift positive values to > 0x0000
479C 0F80 01985 addlw 0x80
479E AC0C 01986 btfss IRQ_TMP2, 6; inversion if depth < 0x40
47A0 0A7F 01987 xorlw 0x7f
01988 rgoto TIA_SW_ENV_Hlp_Waveform_Cont
47A2 D002 M bra label
01989
01990 ;; --------------------------------------------------------------------------
01991 ;; Help Function for LFO and ENV Waveforms
01992 ;; In: LFO_x_VALUE in WREG
01993 ;; LFO_x_MODE in IRQ_TMP1
01994 ;; LFO_x_DEPTH in IRQ_TMP2,
01995 ;; LFO/ENV number in TIA_SW_LFO_NUMBER
01996 ;; pointer to LFOx_BASE in FSR1
01997 ;; Out: Result in PROD[LH]
01998 ;; Scaled Value in IRQ_TMP1
01999 ;; --------------------------------------------------------------------------
47A4 02000 TIA_SW_LFO_Hlp_Waveform
02001 ;; invert if negative depth (<0x40)
47A4 AC0C 02002 btfss IRQ_TMP2, 6
47A6 0AFF 02003 xorlw 0xff
02004
02005 ;; envelope waveform routine continues here
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 122
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
47A8 02006 TIA_SW_ENV_Hlp_Waveform_Cont
47A8 6E0D 02007 movwf IRQ_TMP3
02008
02009 ;; get absolute value of depth from TIA_DEPTH_TABLE
02010 ;; (to keep it compatible with MIDIbox TIA V1.5)
47AA 500C 02011 movf IRQ_TMP2, W
47AC D8C3 02012 rcall TIA_SW_Hlp_Abs7
47AE 0F3E 02013 addlw TIA_DEPTH_TABLE & 0xff
47B0 6EF6 02014 movwf TBLPTRL
47B2 6AF7 02015 clrf TBLPTRH
47B4 0E32 02016 movlw TIA_DEPTH_TABLE >> 8
47B6 22F7 02017 addwfc TBLPTRH, F
47B8 0009 02018 tblrd*+
47BA 50F5 02019 movf TABLAT, W
47BC 6E0C 02020 movwf IRQ_TMP2
02021
02022 ;; branch depending on selected waveform
47BE 380B 02023 swapf IRQ_TMP1, W
47C0 0B07 02024 andlw 0x07
02025 JUMPTABLE_2BYTES_UNSECURE
47C2 ECC8 F016 M call MIOS_HLP_GetIndex_2bytes
02026 rgoto TIA_SW_LFO_Hlp_WFBranch_0
47C6 D007 M bra label
02027 rgoto TIA_SW_LFO_Hlp_WFBranch_1
47C8 D00A M bra label
02028 rgoto TIA_SW_LFO_Hlp_WFBranch_2
47CA D00D M bra label
02029 rgoto TIA_SW_LFO_Hlp_WFBranch_3
47CC D011 M bra label
02030 rgoto TIA_SW_LFO_Hlp_WFBranch_4
47CE D014 M bra label
02031 rgoto TIA_SW_LFO_Hlp_WFBranch_5
47D0 D02A M bra label
02032 rgoto TIA_SW_LFO_Hlp_WFBranch_6
47D2 D001 M bra label
02033 rgoto TIA_SW_LFO_Hlp_WFBranch_7
47D4 D000 M bra label
02034
47D6 02035 TIA_SW_LFO_Hlp_WFBranch_0 ; Sine
47D6 02036 TIA_SW_LFO_Hlp_WFBranch_6 ; (reserved)
47D6 02037 TIA_SW_LFO_Hlp_WFBranch_7 ; (reserved)
47D6 500D 02038 movf IRQ_TMP3, W
47D8 ECD0 F018 02039 call TIA_SIN_TABLE_Get
02040 rgoto TIA_SW_LFO_Hlp_WFBranch_Cont
47DC D025 M bra label
02041
47DE 02042 TIA_SW_LFO_Hlp_WFBranch_1 ; Triangle
02043 ;; Triangle: return unsigned value
47DE 500D 02044 movf IRQ_TMP3, W
47E0 AE0D 02045 btfss IRQ_TMP3, 7
47E2 0A7F 02046 xorlw 0x7f
02047 rgoto TIA_SW_LFO_Hlp_WFBranch_Cont
47E4 D021 M bra label
02048
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 123
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
47E6 02049 TIA_SW_LFO_Hlp_WFBranch_2 ; sawtooth
02050 ;; Sawtooth: x/2, MODE_DECINC is the eight bit
47E6 300D 02051 rrf IRQ_TMP3, W
47E8 0B7F 02052 andlw 0x7f
47EA BE0B 02053 btfsc IRQ_TMP1, LFOx_MODE_DECINC ; (IRQ_TMP1=LFO_x_MODE)
47EC 0980 02054 iorlw 0x80
02055 rgoto TIA_SW_LFO_Hlp_WFBranch_Cont
47EE D01C M bra label
47F0 02056 TIA_SW_LFO_Hlp_WFBranch_3 ; pulse
02057 ;; Pulse: 0x00 when Dec, 0xff when Inc, take inversion bit also into account
47F0 0E00 02058 movlw 0x00
47F2 BE0B 02059 btfsc IRQ_TMP1, LFOx_MODE_DECINC; (IRQ_TMP1=LFO_x_MODE)
47F4 0EFF 02060 movlw 0xff
02061 rgoto TIA_SW_LFO_Hlp_WFBranch_Cont
47F6 D018 M bra label
47F8 02062 TIA_SW_LFO_Hlp_WFBranch_4 ; random
02063 ;; each second LFO is in S&H mode
02064 BRA_IFCLR TIA_SW_LFO_NUMBER, 0, BANKED, TIA_SW_LFO_Hlp_WFBranch_4_Random
47F8 A10F M btfss reg, bit, reg_a
47FA D00C M bra label
47FC 02065 TIA_SW_LFO_Hlp_WFBranch_4_S_H
47FC 500D 02066 movf IRQ_TMP3, W ; latch on period match
47FE 0E05 02067 movlw TIA_LFOx_RVALUE_L
4800 B4D8 02068 skpnz
4802 0EFE 02069 movlw TIA_LFOx_RVALUE_L - TIA_LFOx_RECORD_LEN
4804 CFE3 FFF3 02070 movff PLUSW1, PRODL
02071
4808 0E06 02072 movlw TIA_LFOx_RVALUE_H
480A B4D8 02073 skpnz
480C 0EFF 02074 movlw TIA_LFOx_RVALUE_H - TIA_LFOx_RECORD_LEN
480E CFE3 FFF4 02075 movff PLUSW1, PRODH
02076 rgoto TIA_SW_LFO_Hlp_Waveform_End
4812 D011 M bra label
02077
4814 02078 TIA_SW_LFO_Hlp_WFBranch_4_Random
4814 511D 02079 movf TIA_LFO_RANDOM_SEED_H, W, BANKED
4816 0B55 02080 andlw 0x55
4818 6E0B 02081 movwf IRQ_TMP1
481A 511C 02082 movf TIA_LFO_RANDOM_SEED_L, W, BANKED
481C 0BAA 02083 andlw 0xaa
481E 100B 02084 iorwf IRQ_TMP1, W
4820 24CE 02085 addwf TMR1L, W ; super-random ;-)
4822 18CC 02086 xorwf TMR2, W
02087 rgoto TIA_SW_LFO_Hlp_WFBranch_Cont
4824 D001 M bra label
02088
4826 02089 TIA_SW_LFO_Hlp_WFBranch_5 ; (AIN)
02090 #if ENABLE_AIN_LFO_WAVEFORM
02091 movf TIA_SW_LFO_NUMBER, W, BANKED
02092 movff FSR1L, IRQ_TMP1 ; save FSR1
02093 movff FSR1H, IRQ_TMP3
02094 call MIOS_AIN_PinGet ; get value of analog pin
02095 movff IRQ_TMP1, FSR1L ; restore FSR1
02096 movff IRQ_TMP3, FSR1H
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 124
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
02097 SET_BSR TIA_BASE
02098 rrf MIOS_PARAMETER2, F ; convert 10bit to 8bit
02099 rrf MIOS_PARAMETER1, F
02100 rrf MIOS_PARAMETER2, F
02101 rrf MIOS_PARAMETER1, W
02102
02103 ;; biased at 0x80
02104 BRA_IFSET WREG, 7, ACCESS, TIA_SW_LFO_Hlp_WFBranch_Cont
02105 xorlw 0x7f
02106 addlw 1
02107 btfsc WREG, 7
02108 movlw 0x7f
02109 #else
4826 0E80 02110 movlw 0x80
02111 #endif
02112 ;; rgoto TIA_SW_LFO_Hlp_WFBranch_Cont
02113
4828 02114 TIA_SW_LFO_Hlp_WFBranch_Cont
4828 6E0B 02115 movwf IRQ_TMP1
02116
02117 ;; process scaling (depth * scaled value)
482A 0B7F 02118 andlw 0x7f ; remove sign from value
482C 020C 02119 mulwf IRQ_TMP2 ; multiply with depth (in IRQ_TMP2)
02120 ;; result in PROD[LH]
02121
02122 ;; invert if DECINC flag not set
02123 BRA_IFSET IRQ_TMP1, 7, ACCESS, TIA_SW_LFO_Hlp_Waveform_End
482E BE0B M btfsc reg, bit, reg_a
4830 D002 M bra label
4832 1EF3 02124 comf PRODL, F
4834 1EF4 02125 comf PRODH, F
4836 02126 TIA_SW_LFO_Hlp_Waveform_End
4836 0012 02127 return
02128
02129
02130 ;; --------------------------------------------------------------------------
02131 ;; Help Function to sync all LFOs
02132 ;; --------------------------------------------------------------------------
4838 02133 TIA_SW_Hlp_SyncAllLFOs
4838 EE21 F0A0 02134 lfsr FSR2, TIA_LFO1_BASE + TIA_LFOx_MODE
483C 0E04 02135 movlw 0x04
483E 6E0B 02136 movwf IRQ_TMP1
4840 02137 TIA_SW_Hlp_SyncAllLFOs_Loop
4840 EC35 F024 02138 call TIA_SW_Hlp_SyncLFO_Now
4844 2E0B 02139 decfsz IRQ_TMP1, F
02140 rgoto TIA_SW_Hlp_SyncAllLFOs_Loop
4846 D7FC M bra label
4848 0012 02141 return
02142
02143 ;; --------------------------------------------------------------------------
02144 ;; Help Function for gate bit, syncs the LFOs
02145 ;; In: TIA_Vx_PITCH_MOD | TIA_Vx_VOLUME_MOD | assigned filter flags
02146 ;; --------------------------------------------------------------------------
484A 02147 TIA_SW_Hlp_SyncLFOs
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 125
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
484A EE21 F0A0 02148 lfsr FSR2, TIA_LFO1_BASE + TIA_LFOx_MODE
484E 6E0B 02149 movwf IRQ_TMP1
4850 D806 02150 rcall TIA_SW_Hlp_SyncSingleLFO
4852 320B 02151 rrf IRQ_TMP1, F
4854 D804 02152 rcall TIA_SW_Hlp_SyncSingleLFO
4856 320B 02153 rrf IRQ_TMP1, F
4858 D802 02154 rcall TIA_SW_Hlp_SyncSingleLFO
485A 320B 02155 rrf IRQ_TMP1, F
485C D800 02156 rcall TIA_SW_Hlp_SyncSingleLFO
02157
02158
485E 02159 TIA_SW_Hlp_SyncSingleLFO
02160 BRA_IFSET INDF2, LFOx_MODE_SYNC_ALL, ACCESS, TIA_SW_Hlp_SyncLFO_Now
485E B4DF M btfsc reg, bit, reg_a
4860 D004 M bra label
02161 BRA_IFCLR IRQ_TMP1, 0, ACCESS, TIA_SW_Hlp_SyncLFO_Skip
4862 A00B M btfss reg, bit, reg_a
4864 D00C M bra label
02162 BRA_IFCLR INDF2, LFOx_MODE_SYNC, ACCESS, TIA_SW_Hlp_SyncLFO_Skip
4866 A2DF M btfss reg, bit, reg_a
4868 D00A M bra label
486A 02163 TIA_SW_Hlp_SyncLFO_Now
486A 9EDF 02164 bcf INDF2, LFOx_MODE_DECINC
486C 2AD9 02165 incf FSR2L, F ; switch to LFO_x_RATE
486E 2AD9 02166 incf FSR2L, F ; switch to LFO_x_CTR
4870 6ADE 02167 clrf POSTINC2 ; clear counter,
02168 ; switch to LFO_x_VALUE
4872 0E80 02169 movlw 0x80 ; write 0x80 into value
4874 6EDE 02170 movwf POSTINC2
02171 ; switch to LFO_x_DEPTH
4876 2AD9 02172 incf FSR2L, F ; switch to LFO_x_RVALUE_L
4878 6ADE 02173 clrf POSTINC2 ; clear LFO_x_RAVLUE_L
487A 6ADE 02174 clrf POSTINC2 ; clear LFO_x_RAVLUE_H
02175
487C 0012 02176 return
02177
487E 02178 TIA_SW_Hlp_SyncLFO_Skip
487E 0E07 02179 movlw TIA_LFOx_RECORD_LEN ; switch to LFO_x+1_MODE
4880 26D9 02180 addwf FSR2L, F
4882 0012 02181 return
02182
02183 ;; --------------------------------------------------------------------------
02184 ;; Help Function for gate bit, sets ENVs to attack mode
02185 ;; In: TIA_Vx_ENVS | assigned filter flags
02186 ;; --------------------------------------------------------------------------
4884 02187 TIA_SW_Hlp_ENVAttack
02188 ;; set envelope generators to attack mode if voice (or filter) has been assigned
4884 6E0B 02189 movwf IRQ_TMP1
02190
02191 ;movf IRQ_TMP1, W
4886 0B11 02192 andlw 0x11
4888 E002 02193 bz TIA_SW_Hlp_ENVAttack_Not1
488A 0E01 02194 movlw (1 << ENVx_MODE_ATTACK)
488C 6FD2 02195 movwf TIA_ENV1_BASE + TIA_ENVx_MODE, BANKED
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 126
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
488E 02196 TIA_SW_Hlp_ENVAttack_Not1
02197
488E 500B 02198 movf IRQ_TMP1, W
4890 0B22 02199 andlw 0x22
4892 E002 02200 bz TIA_SW_Hlp_ENVAttack_Not2
4894 0E01 02201 movlw (1 << ENVx_MODE_ATTACK)
4896 6FDD 02202 movwf TIA_ENV2_BASE + TIA_ENVx_MODE, BANKED
4898 02203 TIA_SW_Hlp_ENVAttack_Not2
02204
4898 500B 02205 movf IRQ_TMP1, W
489A 0B0C 02206 andlw 0x0c
489C E002 02207 bz TIA_SW_Hlp_ENVAttack_Not3
489E 0E01 02208 movlw (1 << ENVx_MODE_ATTACK)
48A0 6FBC 02209 movwf TIA_ENVAUD0_BASE + TIA_ENVx_MODE, BANKED
48A2 02210 TIA_SW_Hlp_ENVAttack_Not3
02211
48A2 500B 02212 movf IRQ_TMP1, W
48A4 0BC0 02213 andlw 0xc0
48A6 E002 02214 bz TIA_SW_Hlp_ENVAttack_Not4
48A8 0E01 02215 movlw (1 << ENVx_MODE_ATTACK)
48AA 6FC7 02216 movwf TIA_ENVAUD1_BASE + TIA_ENVx_MODE, BANKED
48AC 02217 TIA_SW_Hlp_ENVAttack_Not4
48AC 0012 02218 return
02219
02220 ;; --------------------------------------------------------------------------
02221 ;; Help Function for gate bit, sets ENVs to release mode
02222 ;; In: TIA_Vx_ENVS | assigned filter flags
02223 ;; --------------------------------------------------------------------------
48AE 02224 TIA_SW_Hlp_ENVRelease
02225 ;; set envelope generators to release mode if voice (or filter) has been assigned
48AE 6E0B 02226 movwf IRQ_TMP1
02227
48B0 0B11 02228 andlw 0x11
48B2 E002 02229 bz TIA_SW_Hlp_ENVRelease_Not1
48B4 0E08 02230 movlw (1 << ENVx_MODE_RELEASE)
48B6 6FD2 02231 movwf TIA_ENV1_BASE + TIA_ENVx_MODE, BANKED
48B8 02232 TIA_SW_Hlp_ENVRelease_Not1
02233
48B8 500B 02234 movf IRQ_TMP1, W
48BA 0B22 02235 andlw 0x22
48BC E002 02236 bz TIA_SW_Hlp_ENVRelease_Not2
48BE 0E08 02237 movlw (1 << ENVx_MODE_RELEASE)
48C0 6FDD 02238 movwf TIA_ENV2_BASE + TIA_ENVx_MODE, BANKED
48C2 02239 TIA_SW_Hlp_ENVRelease_Not2
02240
48C2 500B 02241 movf IRQ_TMP1, W
48C4 0B0C 02242 andlw 0x0c
48C6 E002 02243 bz TIA_SW_Hlp_ENVRelease_Not3
48C8 0E08 02244 movlw (1 << ENVx_MODE_RELEASE)
48CA 6FBC 02245 movwf TIA_ENVAUD0_BASE + TIA_ENVx_MODE, BANKED
48CC 02246 TIA_SW_Hlp_ENVRelease_Not3
02247
48CC 500B 02248 movf IRQ_TMP1, W
48CE 0BC0 02249 andlw 0xc0
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 127
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
48D0 E002 02250 bz TIA_SW_Hlp_ENVRelease_Not4
48D2 0E08 02251 movlw (1 << ENVx_MODE_RELEASE)
48D4 6FC7 02252 movwf TIA_ENVAUD1_BASE + TIA_ENVx_MODE, BANKED
48D6 02253 TIA_SW_Hlp_ENVRelease_Not4
48D6 0012 02254 return
02255
02256 ;; --------------------------------------------------------------------------
02257 ;; Help Function for TIA_SW_Pitch
02258 ;; IN: TIA_Vx_TARGET_FRQ_LH in FSR2
02259 ;; OUT: new result in TIA_Vx_TARGET_FRQ_LH
02260 ;; --------------------------------------------------------------------------
48D8 02261 TIA_SW_Hlp_AddMul
02262 BRA_IFCLR IRQ_TMP3, 0, ACCESS, TIA_SW_Hlp_AddMul_Pos
48D8 A00D M btfss reg, bit, reg_a
48DA D00D M bra label
48DC 02263 TIA_SW_Hlp_AddMul_Neg
02264 ;; calc MUL_A_[LH] = TIA_Vx_FRQ_[LH] - MIOS_PARAMETER[12]
48DC 5003 02265 movf MIOS_PARAMETER1, W
48DE 5CDE 02266 subwf POSTINC2, W ; TIA_Vx_TARGET_FRQ_LH+0, W, BANKED
48E0 6FF8 02267 movwf MUL_A_L, BANKED
48E2 5004 02268 movf MIOS_PARAMETER2, W
48E4 58DD 02269 subwfb POSTDEC2, W ; TIA_Vx_TARGET_FRQ_LH+1, W, BANKED
48E6 6FF9 02270 movwf MUL_A_H, BANKED
02271
02272 ;; calc MUL_R_[12] = MUL_A_[LH] * MUL_B_[LH]
48E8 ECDC F019 02273 call MATH_MUL16_16
02274 ;; TIA_Vx_FRQ -= result
48EC 51FD 02275 movf MUL_R_1, W, BANKED
48EE 5EDE 02276 subwf POSTINC2, F ; TIA_Vx_TARGET_FRQ_LH+0, F, BANKED
48F0 51FE 02277 movf MUL_R_2, W, BANKED
48F2 5ADD 02278 subwfb POSTDEC2, F ; TIA_Vx_TARGET_FRQ_LH+1, F, BANKED
48F4 0012 02279 return
02280
48F6 02281 TIA_SW_Hlp_AddMul_Pos
02282 ;; calc MUL_A_[LH] = MIOS_PARAMETER[12] - TIA_Vx_FRQ_[LH]
48F6 50DE 02283 movf POSTINC2, W ; TIA_Vx_TARGET_FRQ_LH+0, W, BANKED
48F8 5C03 02284 subwf MIOS_PARAMETER1, W
48FA 6FF8 02285 movwf MUL_A_L, BANKED
48FC 50DD 02286 movf POSTDEC2, W ; TIA_Vx_TARGET_FRQ_LH+1, W, BANKED
48FE 5804 02287 subwfb MIOS_PARAMETER2, W
4900 6FF9 02288 movwf MUL_A_H, BANKED
02289
02290 ;; calc MUL_R_[12] = MUL_A_[LH] * MUL_B_[LH]
4902 ECDC F019 02291 call MATH_MUL16_16
02292 ;; TIA_Vx_FRQ += result
4906 51FD 02293 movf MUL_R_1, W, BANKED
4908 26DE 02294 addwf POSTINC2, F ; TIA_Vx_TARGET_FRQ_LH+0, F, BANKED
490A 51FE 02295 movf MUL_R_2, W, BANKED
490C 22DD 02296 addwfc POSTDEC2, F ; TIA_Vx_TARGET_FRQ_LH+1, F, BANKED
490E 0012 02297 return
02298
02299
02300 ;; --------------------------------------------------------------------------
02301 ;; Help Function for TIA_SW_Pitch
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 128
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
02302 ;; IN: addend and IRQ_TMP[12], TIA_Vx_TARGET_FRQ_LH in FSR2
02303 ;; OUT: new result in TIA_Vx_TARGET_FRQ_LH
02304 ;; --------------------------------------------------------------------------
4910 02305 TIA_SW_Hlp_Add16
02306 ;; divide / 4 for a better scaling
02307 ;clrc
02308 ;rrf IRQ_TMP2, F
02309 ;rrf IRQ_TMP1, F
02310 ;clrc
02311 ;rrf IRQ_TMP2, F
02312 ;rrf IRQ_TMP1, F
02313
02314 BRA_IFCLR IRQ_TMP3, 0, ACCESS, TIA_SW_Hlp_Add16_Pos
4910 A00D M btfss reg, bit, reg_a
4912 D008 M bra label
4914 02315 TIA_SW_Hlp_Add16_Neg
02316 ;; TIA_Vx_TARGET_FRQ -= MOD
4914 500B 02317 movf IRQ_TMP1, W
4916 5EDE 02318 subwf POSTINC2, F ; TIA_Vx_TARGET_FRQ_LH+0, F, BANKED
4918 500C 02319 movf IRQ_TMP2, W
491A 5ADD 02320 subwfb POSTDEC2, F ; TIA_Vx_TARGET_FRQ_LH+1, F, BANKED
02321 ;; saturate on overflow
491C E202 02322 bc TIA_SW_Hlp_Add16_Neg_End
491E 6ADE 02323 clrf POSTINC2 ; TIA_Vx_TARGET_FRQ_LH+0, BANKED
4920 6ADD 02324 clrf POSTDEC2 ; TIA_Vx_TARGET_FRQ_LH+1, BANKED
4922 02325 TIA_SW_Hlp_Add16_Neg_End
4922 0012 02326 return
02327
4924 02328 TIA_SW_Hlp_Add16_Pos
02329 ;; TIA_Vx_TARGET_FRQ += MOD
4924 500B 02330 movf IRQ_TMP1, W
4926 26DE 02331 addwf POSTINC2, F ; TIA_Vx_TARGET_FRQ_LH+0, F, BANKED
4928 500C 02332 movf IRQ_TMP2, W
492A 22DD 02333 addwfc POSTDEC2, F ; TIA_Vx_TARGET_FRQ_LH+1, F, BANKED
02334 ;; saturate on overflow (set frequency to zero to avoid unwanted HF beeps)
492C E302 02335 bnc TIA_SW_Hlp_Add16_Pos_End
492E 68DE 02336 setf POSTINC2 ; TIA_Vx_TARGET_FRQ_LH+0, BANKED
4930 68DD 02337 setf POSTDEC2 ; TIA_Vx_TARGET_FRQ_LH+1, BANKED
4932 02338 TIA_SW_Hlp_Add16_Pos_End
4932 0012 02339 return
02340
02341
02342 ;; --------------------------------------------------------------------------
02343 ;; Help Function for TIA_SW_ENV, etc.
02344 ;; IN: 7-bit signed value in WREG
02345 ;; OUT: absolute value (0x00-0x3f) in WREG
02346 ;; --------------------------------------------------------------------------
4934 02347 TIA_SW_Hlp_Abs7
4934 50E8 02348 movf WREG, W
4936 B4D8 02349 skpnz
4938 0F01 02350 addlw 1
493A ACE8 02351 btfss WREG, 6
493C 0840 02352 sublw 0x40
493E 0B3F 02353 andlw 0x3f
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 129
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
4940 0012 02354 return
02355
02356 ;; --------------------------------------------------------------------------
02357 ;; Help Function for TIA_SW_ENV
02358 ;; IN: ENV_x_CTR_H in IRQ_TMP1
02359 ;; ENV_x_CURVE in IRQ_TMP2
02360 ;; ENV_x_ATTACK/ENV_x_DECAY or ENV_x_SUSTAIN in IRQ_TMP3
02361 ;; WREG != 0: use curve, WREG == 0: don't use curve parameter
02362 ;; OUT: value which should be added to - or subtracted from - ENV_x_CTR_[LH]
02363 ;; low-byte in WREG and MIOS_PARAMETER1; high-byte in MIOS_PARAMETER2
02364 ;; --------------------------------------------------------------------------
4942 02365 TIA_SW_ENV_GetBendedValue
4942 E103 02366 bnz TIA_SW_ENV_GetBendedValue_Curve
02367
02368 ;; curve not selected, get value from ENV_TABLE
4944 500D 02369 movf IRQ_TMP3, W
4946 EF3F F02D 02370 goto TIA_ENV_TABLE_Get
02371
494A 02372 TIA_SW_ENV_GetBendedValue_Curve
02373 ;; return ENV_x_DECAY when ENV_x_CURVE == 0x40
494A 0E40 02374 movlw 0x40
494C 620C 02375 cpfseq IRQ_TMP2, ACCESS
02376 rgoto TIA_SW_ENV_GetBendedValue_UD
494E D002 M bra label
4950 1C0D 02377 comf IRQ_TMP3, W
02378 rgoto TIA_SW_ENV_GetBendedValue_Cont
4952 D011 M bra label
02379
4954 02380 TIA_SW_ENV_GetBendedValue_UD
02381 ;; feedback: calculate ABS7(CURVE) * ENV_x_CTR_H
4954 500C 02382 movf IRQ_TMP2, W ; get absolute value of curve parameter
4956 DFEE 02383 rcall TIA_SW_Hlp_Abs7
4958 020B 02384 mulwf IRQ_TMP1, ACCESS ; multiply with current counter value
02385
02386 ;; when CURVE parameter < 0x40: bend down, else up
02387 BRA_IFCLR IRQ_TMP2, 6, ACCESS, TIA_SW_ENV_GetBendedValue_Down
495A AC0C M btfss reg, bit, reg_a
495C D007 M bra label
495E 02388 TIA_SW_ENV_GetBendedValue_Up
495E 1E0D 02389 comf IRQ_TMP3, F
4960 9E0D 02390 bcf IRQ_TMP3, 7
4962 50F4 02391 movf PRODH, W
4964 5C0D 02392 subwf IRQ_TMP3, W
4966 BEE8 02393 btfsc WREG, 7
4968 0E00 02394 movlw 0x00
02395 rgoto TIA_SW_ENV_GetBendedValue_Cont
496A D005 M bra label
02396
496C 02397 TIA_SW_ENV_GetBendedValue_Down
496C 1C0D 02398 comf IRQ_TMP3, W
496E 0B7F 02399 andlw 0x7f
4970 24F4 02400 addwf PRODH, W
4972 BEE8 02401 btfsc WREG, 7
4974 0E7F 02402 movlw 0x7f
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 130
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
02403 ;; rgoto TIA_SW_ENV_GetBendedValue_Cont
02404
4976 02405 TIA_SW_ENV_GetBendedValue_Cont
4976 0B7F 02406 andlw 0x7f
4978 EF41 F018 02407 goto TIA_FRQ_TABLE_Get
02408
02409
00373 #include "tia_midi.inc"
00001 ; $Id: tia_midi.inc bdupeyron.tech@gmail.com(Antichambre)
00002 ;
00003 ; MIDIbox TIA
00004 ; MIDI Interface part
00005 ;
00006 ; ==========================================================================
00007 ;
00008 ; Copyright 1998-2006 Thorsten Klose (tk@midibox.org)
00009 ; Licensed for personal non-commercial use only.
00010 ; All other rights reserved.
00011 ;
00012 ; ==========================================================================
00013
00014 ;; --------------------------------------------------------------------------
00015 ;; This function is called by TIA_MPROC when a complete MIDI event has been
00016 ;; received
00017 ;; Input:
00018 ;; o first MIDI event byte in MIOS_PARAMETER1
00019 ;; o second MIDI event byte in MIOS_PARAMETER2
00020 ;; o third MIDI event byte in MIOS_PARAMETER3
00021 ;; --------------------------------------------------------------------------
497C 00022 TIA_MIDI_NotifyReceivedEvent
00023
00024 ;; branch to appr. TIA routine depending on received event
497C 3803 00025 swapf MIOS_PARAMETER1, W
497E 0B07 00026 andlw 0x07
00027 JUMPTABLE_2BYTES_UNSECURE
4980 ECC8 F016 M call MIOS_HLP_GetIndex_2bytes
00028 rgoto TIA_MIDI_NoteOff
4984 D040 M bra label
00029 rgoto TIA_MIDI_NoteOn
4986 D006 M bra label
00030 rgoto TIA_MIDI_AfterTouch
4988 D0C2 M bra label
00031 rgoto TIA_MIDI_CC
498A D081 M bra label
00032 rgoto TIA_MIDI_ProgramChange
498C D0A7 M bra label
00033 rgoto TIA_MIDI_PolyAfterTouch
498E D0BC M bra label
00034 rgoto TIA_MIDI_PitchBender
4990 D06D M bra label
4992 0012 00035 return
00036
00037 ;; --------------------------------------------------------------------------
00038 ;; This function is rcalled to forward a Note On event to the synthesizer
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 131
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00039 ;; Input:
00040 ;; o first MIDI event byte in MIOS_PARAMETER1
00041 ;; o second MIDI event byte in MIOS_PARAMETER2
00042 ;; o third MIDI event byte in MIOS_PARAMETER3
00043 ;; --------------------------------------------------------------------------
4994 00044 TIA_MIDI_NoteOn
4994 5005 00045 movf MIOS_PARAMETER3, W ; branch to NoteOff if velocity is zero
4996 B4D8 00046 skpnz
00047 rgoto TIA_MIDI_NoteOff
4998 D036 M bra label
00048
00049
00050
00051 SET_BSR TIA_BASE ; prepare BSR for TIA register access
499A 0101 M movlb HIGH(reg)
00052
00053 BRA_IFCLR TIA_PLAY_MODE, TIA_PLAY_MODE_POLY, BANKED, TIA_MIDI_NoteOn_MonoMode
499C A10C M btfss reg, bit, reg_a
499E D00F M bra label
49A0 00054 TIA_MIDI_NoteOn_PolyMode
00055 ;; in poly mode we only react on MIDI channel of voice 1!
49A0 5003 00056 movf MIOS_PARAMETER1, W ; leave routine if MIDI channel doesn't match
49A2 0B0F 00057 andlw 0x0f
49A4 6320 00058 cpfseq TIA_V1_BASE + TIA_Vx_MIDI_CHANNEL, BANKED
49A6 0012 00059 return
00060
00061 ;; in poly mode: determine free voice
49A8 0E01 00062 movlw 0x01
49AA 5342 00063 movf TIA_V1_BASE + TIA_Vx_NOTE_STACK_0, F, BANKED
49AC E004 00064 bz TIA_MIDI_NoteOn_Poly_Cont
49AE 0E02 00065 movlw 0x02
49B0 5382 00066 movf TIA_V2_BASE + TIA_Vx_NOTE_STACK_0, F, BANKED
49B2 E001 00067 bz TIA_MIDI_NoteOn_Poly_Cont
00068 rgoto TIA_MIDI_NoteOn_Poly_Failed
49B4 D026 M bra label
49B6 00069 TIA_MIDI_NoteOn_Poly_Cont
49B6 6E0A 00070 movwf TMP5 ; TMP5 contains the voices which should be played
49B8 D960 00071 rcall TIA_MIDI_GetAssignedKeys
49BA D95F 00072 rcall TIA_MIDI_GetAssignedKeys
00073 rgoto TIA_MIDI_NoteOn_Start_Handlers
49BC D005 M bra label
00074
49BE 00075 TIA_MIDI_NoteOn_MonoMode
00076 ;; check for the assigned MIDI channels, result in TMP5
49BE D938 00077 rcall TIA_MIDI_GetAssignedChannels
49C0 D944 00078 rcall TIA_MIDI_GetAssignedVoices
49C2 D95B 00079 rcall TIA_MIDI_GetAssignedKeys
00080 ;; leave routine if no voice is assigned to channel
49C4 B4D8 00081 skpnz
49C6 0012 00082 return
00083
49C8 00084 TIA_MIDI_NoteOn_Start_Handlers
00085 IRQ_DISABLE
49C8 9EF2 M bcf INTCON, GIE
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 132
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00086
00087 ;; --[ Voice 1 Handler ]--
49CA 00088 TIA_MIDI_NoteOn_V1
00089 BRA_IFCLR TMP5, 0, ACCESS, TIA_MIDI_NoteOn_V1_Failed
49CA A00A M btfss reg, bit, reg_a
49CC D00C M bra label
49CE EE11 F042 00090 lfsr FSR1, TIA_V1_BASE + TIA_Vx_NOTE_STACK_0 ; push note to stack
49D2 D8A9 00091 rcall TIA_MIDI_Hlp_PushNote
00092 BRA_IFSET WREG, 0, ACCESS, TIA_MIDI_NoteOn_V1_Failed ; exit if note already in stack
49D4 B0E8 M btfsc reg, bit, reg_a
49D6 D007 M bra label
49D8 EE01 F020 00093 lfsr FSR0, TIA_V1_BASE
49DC 5004 00094 movf MIOS_PARAMETER2, W ; note which should be disabled
00095 ; RCALL_IFSET TIA_PLAY_MODE, TIA_PLAY_MODE_LEGATO_OFF, BANKED, TIA_MIDI_Hlp_GateOff ; request gate-off if !legato
49DE D8D4 00096 rcall TIA_MIDI_Hlp_NoteOn ; call note-on handler
49E0 EE21 F020 00097 lfsr FSR2, TIA_V1_BASE ; sort notes for arpeggios
49E4 D966 00098 rcall TIA_MIDI_Arp_Sorter
49E6 00099 TIA_MIDI_NoteOn_V1_Failed
00100
00101 ;; --[ Voice 2 Handler ]--
49E6 00102 TIA_MIDI_NoteOn_V2
00103 BRA_IFCLR TMP5, 1, ACCESS, TIA_MIDI_NoteOn_V2_Failed
49E6 A20A M btfss reg, bit, reg_a
49E8 D00C M bra label
49EA EE11 F082 00104 lfsr FSR1, TIA_V2_BASE + TIA_Vx_NOTE_STACK_0 ; push note to stack
49EE D89B 00105 rcall TIA_MIDI_Hlp_PushNote
00106 BRA_IFSET WREG, 0, ACCESS, TIA_MIDI_NoteOn_V2_Failed ; exit if note already in stack
49F0 B0E8 M btfsc reg, bit, reg_a
49F2 D007 M bra label
49F4 EE01 F060 00107 lfsr FSR0, TIA_V2_BASE
49F8 5004 00108 movf MIOS_PARAMETER2, W ; note which should be disabled
00109 ; RCALL_IFSET TIA_PLAY_MODE, TIA_PLAY_MODE_LEGATO_OFF, BANKED, TIA_MIDI_Hlp_GateOff ; request gate-off if !legato
49FA D8C6 00110 rcall TIA_MIDI_Hlp_NoteOn ; call note-on handler
49FC EE21 F060 00111 lfsr FSR2, TIA_V2_BASE ; sort notes for arpeggios
4A00 D958 00112 rcall TIA_MIDI_Arp_Sorter
4A02 00113 TIA_MIDI_NoteOn_V2_Failed
00114
4A02 00115 TIA_MIDI_NoteOn_Poly_Failed
00116
00117 IRQ_ENABLE
4A02 8EF2 M bsf INTCON, GIE
4A04 0012 00118 return
00119
00120 ;; --------------------------------------------------------------------------
00121 ;; This function is rcalled to forward a Note Off event to the synthesizer
00122 ;; Input:
00123 ;; o first MIDI event byte in MIOS_PARAMETER1
00124 ;; o second MIDI event byte in MIOS_PARAMETER2
00125 ;; o third MIDI event byte in MIOS_PARAMETER3
00126 ;; --------------------------------------------------------------------------
4A06 00127 TIA_MIDI_NoteOff
00128 SET_BSR TIA_BASE ; prepare BSR for TIA register access
4A06 0101 M movlb HIGH(reg)
00129
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 133
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00130 ;; ensure that velocity is cleared
4A08 6A05 00131 clrf MIOS_PARAMETER3
00132
00133 BRA_IFCLR TIA_PLAY_MODE, TIA_PLAY_MODE_POLY, BANKED, TIA_MIDI_NoteOff_MonoMode
4A0A A10C M btfss reg, bit, reg_a
4A0C D003 M bra label
4A0E 00134 TIA_MIDI_NoteOff_PolyMode
00135 ;; in poly mode, handle all channels
4A0E 0E0F 00136 movlw 0x0f
4A10 6E0A 00137 movwf TMP5
00138 rgoto TIA_MIDI_NoteOff_Start_Handlers
4A12 D005 M bra label
4A14 00139 TIA_MIDI_NoteOff_MonoMode
00140 ;; check for the assigned MIDI channels, result in TMP5
4A14 D90D 00141 rcall TIA_MIDI_GetAssignedChannels
4A16 D919 00142 rcall TIA_MIDI_GetAssignedVoices ; (not so optimal if split points modified during notes are played)
4A18 D930 00143 rcall TIA_MIDI_GetAssignedKeys
00144 ;; leave routine if no voice is assigned to channel
4A1A B4D8 00145 skpnz
4A1C 0012 00146 return
00147
4A1E 00148 TIA_MIDI_NoteOff_Start_Handlers
00149 IRQ_DISABLE
4A1E 9EF2 M bcf INTCON, GIE
00150
00151 ;; --[ Voice 1 Handler ]--
4A20 00152 TIA_MIDI_NoteOff_V1
00153 BRA_IFCLR TMP5, 0, ACCESS, TIA_MIDI_NoteOff_V1_NotFnd
4A20 A00A M btfss reg, bit, reg_a
4A22 D010 M bra label
4A24 EE11 F042 00154 lfsr FSR1, TIA_V1_BASE + TIA_Vx_NOTE_STACK_0 ; pop note from stack
4A28 CFE7 F008 00155 movff INDF1, TMP3 ; save current #0 entry in TMP3 for later use
4A2C D895 00156 rcall TIA_MIDI_Hlp_PopNote
00157 BRA_IFSET WREG, 0, ACCESS, TIA_MIDI_NoteOff_V1_NotFnd
4A2E B0E8 M btfsc reg, bit, reg_a
4A30 D009 M bra label
4A32 EE01 F020 00158 lfsr FSR0, TIA_V1_BASE
4A36 5008 00159 movf TMP3, W ; restore note
4A38 D8DA 00160 rcall TIA_MIDI_Hlp_NoteOff
00161 RCALL_IFSET WREG, 0, ACCESS, TIA_MIDI_Hlp_NoteOn
4A3A B0E8 M btfsc reg, bit, reg_a
4A3C D8A5 M rcall label
4A3E EE21 F020 00162 lfsr FSR2, TIA_V1_BASE ; sort notes for arpeggios
4A42 D937 00163 rcall TIA_MIDI_Arp_Sorter
4A44 00164 TIA_MIDI_NoteOff_V1_NotFnd
00165
00166 ;; --[ Voice 2 Handler ]--
4A44 00167 TIA_MIDI_NoteOff_V2
00168 BRA_IFCLR TMP5, 1, ACCESS, TIA_MIDI_NoteOff_V2_NotFnd
4A44 A20A M btfss reg, bit, reg_a
4A46 D010 M bra label
4A48 EE11 F082 00169 lfsr FSR1, TIA_V2_BASE + TIA_Vx_NOTE_STACK_0 ; pop note from stack
4A4C CFE7 F008 00170 movff INDF1, TMP3 ; save current #0 entry in TMP3 for later use
4A50 D883 00171 rcall TIA_MIDI_Hlp_PopNote
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 134
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00172 BRA_IFSET WREG, 0, ACCESS, TIA_MIDI_NoteOff_V2_NotFnd
4A52 B0E8 M btfsc reg, bit, reg_a
4A54 D009 M bra label
4A56 EE01 F060 00173 lfsr FSR0, TIA_V2_BASE
4A5A 5008 00174 movf TMP3, W ; restore note
4A5C D8C8 00175 rcall TIA_MIDI_Hlp_NoteOff
00176 RCALL_IFSET WREG, 0, ACCESS, TIA_MIDI_Hlp_NoteOn
4A5E B0E8 M btfsc reg, bit, reg_a
4A60 D893 M rcall label
4A62 EE21 F060 00177 lfsr FSR2, TIA_V2_BASE ; sort notes for arpeggios
4A66 D925 00178 rcall TIA_MIDI_Arp_Sorter
4A68 00179 TIA_MIDI_NoteOff_V2_NotFnd
00180
00181 IRQ_ENABLE
4A68 8EF2 M bsf INTCON, GIE
4A6A 0012 00182 return
00183
00184
00185 ;; --------------------------------------------------------------------------
00186 ;; This function is rcalled to forward a PitchBender event to the synthesizer
00187 ;; Input:
00188 ;; o first MIDI event byte in MIOS_PARAMETER1
00189 ;; o second MIDI event byte in MIOS_PARAMETER2
00190 ;; o third MIDI event byte in MIOS_PARAMETER3
00191 ;; --------------------------------------------------------------------------
4A6C 00192 TIA_MIDI_PitchBender
00193 SET_BSR TIA_BASE
4A6C 0101 M movlb HIGH(reg)
4A6E 3404 00194 rlf MIOS_PARAMETER2, W
4A70 0BFE 00195 andlw 0xfe
4A72 0A80 00196 xorlw 0x80
4A74 6E04 00197 movwf MIOS_PARAMETER2
00198
4A76 5003 00199 movf MIOS_PARAMETER1, W ; leave routine if MIDI channel doesn't match
4A78 0B0F 00200 andlw 0x0f
4A7A 00201 TIA_MIDI_PitchBender_v1
4A7A 6320 00202 cpfseq TIA_V1_BASE + TIA_Vx_MIDI_CHANNEL, BANKED
00203 rgoto TIA_MIDI_PitchBender_v2
4A7C D003 M bra label
4A7E 5004 00204 movf MIOS_PARAMETER2, W
4A80 6F2B 00205 movwf TIA_V1_BASE + TIA_Vx_PITCHBENDER, BANKED
00206 rgoto TIA_MIDI_PitchBender_End
4A82 D004 M bra label
00207
4A84 00208 TIA_MIDI_PitchBender_v2
4A84 6360 00209 cpfseq TIA_V2_BASE + TIA_Vx_MIDI_CHANNEL, BANKED
00210 rgoto TIA_MIDI_PitchBender_End
4A86 D002 M bra label
4A88 5004 00211 movf MIOS_PARAMETER2, W
4A8A 6F6B 00212 movwf TIA_V2_BASE + TIA_Vx_PITCHBENDER, BANKED
4A8C 00213 TIA_MIDI_PitchBender_End
4A8C 0012 00214 return
00215
00216 ;; --------------------------------------------------------------------------
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 135
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00217 ;; This function is rcalled to forward a Controller event to the synthesizer
00218 ;; Input:
00219 ;; o first MIDI event byte in MIOS_PARAMETER1
00220 ;; o second MIDI event byte in MIOS_PARAMETER2
00221 ;; o third MIDI event byte in MIOS_PARAMETER3
00222 ;; --------------------------------------------------------------------------
4A8E 00223 TIA_MIDI_CC
00224 SET_BSR TIA_BASE
4A8E 0101 M movlb HIGH(reg)
00225
00226 ;; special treatment for CC#0 (bank change)
4A90 5004 00227 movf MIOS_PARAMETER2, W
4A92 E11A 00228 bnz TIA_MIDI_CC_No00
4A94 00229 TIA_MIDI_CC_00
00230 ;; exit if bank number >= DEFAULT_BS_KBANK_ID*4
4A94 0E14 00231 movlw DEFAULT_BS_KBANK_ID*4
4A96 6005 00232 cpfslt MIOS_PARAMETER3
4A98 0012 00233 return
00234
4A9A 5003 00235 movf MIOS_PARAMETER1, W ; leave routine if MIDI channel doesn't match
4A9C 0B0F 00236 andlw 0x0f
4A9E 6320 00237 cpfseq TIA_V1_BASE + TIA_Vx_MIDI_CHANNEL, BANKED
4AA0 0012 00238 return
00239
4AA2 C005 F014 00240 movff MIOS_PARAMETER3, TIA_PBANK
00241
00242 ;; Int.Patch if ==0
4AA6 5013 00243 movf TIA_PATCH, W
4AA8 E00C 00244 bz TIA_MIDI_CC_00_Ok
00245
00246 ;; Banstick Ready
4AAA 5014 00247 movf TIA_PBANK, W
4AAC EC7E F01B 00248 call TIA_BANK_GetBankStickReady
4AB0 B4D8 00249 skpnz
4AB2 6A13 00250 clrf TIA_PATCH ;; to Int. Patch if BS not ready
00251
00252 ;; Banstick Size
4AB4 EC8B F01B 00253 call TIA_BANK_GetBankStickSize
4AB8 E104 00254 bnz TIA_MIDI_CC_00_Ok
00255 ;; 64/128 patches
4ABA 5013 00256 movf TIA_PATCH, W
4ABC 0BC0 00257 andlw 0xc0
4ABE A4D8 00258 skpz
4AC0 6A13 00259 clrf TIA_PATCH ;; to Int. Patch if >63
00260
4AC2 00261 TIA_MIDI_CC_00_Ok
4AC2 ECBD F01A 00262 call TIA_PATCH_Init
00263 ;;goto USER_DISPLAY_Init
4AC6 00264 TIA_MIDI_CC_00_End
4AC6 0012 00265 return
00266
00267
4AC8 00268 TIA_MIDI_CC_No00
4AC8 5003 00269 movf MIOS_PARAMETER1, W ; leave routine if MIDI channel doesn't match
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 136
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
4ACA 0B0F 00270 andlw 0x0f
4ACC 6320 00271 cpfseq TIA_V1_BASE + TIA_Vx_MIDI_CHANNEL, BANKED
4ACE 0012 00272 return
00273
00274 ;; forward CC to CCIN_Set routine
4AD0 C005 F003 00275 movff MIOS_PARAMETER3, MIOS_PARAMETER1
4AD4 5004 00276 movf MIOS_PARAMETER2, W
4AD6 EC67 F02A 00277 call TIA_CCIN_Set
00278
4ADA 0012 00279 return
00280
00281
00282 ;; --------------------------------------------------------------------------
00283 ;; This function is rcalled to forward a Program Change event to the synthesizer
00284 ;; Input:
00285 ;; o first MIDI event byte in MIOS_PARAMETER1
00286 ;; o second MIDI event byte in MIOS_PARAMETER2
00287 ;; --------------------------------------------------------------------------
4ADC 00288 TIA_MIDI_ProgramChange
00289 SET_BSR TIA_BASE
4ADC 0101 M movlb HIGH(reg)
00290
4ADE 5003 00291 movf MIOS_PARAMETER1, W ; leave routine if MIDI channel doesn't match
4AE0 0B0F 00292 andlw 0x0f
4AE2 6320 00293 cpfseq TIA_V1_BASE + TIA_Vx_MIDI_CHANNEL, BANKED
4AE4 0012 00294 return
00295
00296 ;; Int.Patch if ==0
4AE6 5004 00297 movf MIOS_PARAMETER2, W
4AE8 E00A 00298 bz TIA_MIDI_ProgramChange_Ok
00299
00300 ;; Banstick Ready
4AEA 5014 00301 movf TIA_PBANK, W
4AEC EC7E F01B 00302 call TIA_BANK_GetBankStickReady
4AF0 B4D8 00303 skpnz
4AF2 6A04 00304 clrf MIOS_PARAMETER2
00305
00306 ;; Banstick Size
4AF4 EC8B F01B 00307 call TIA_BANK_GetBankStickSize
4AF8 E102 00308 bnz TIA_MIDI_ProgramChange_Ok
00309 ;; 64/128 patches
4AFA BC04 00310 btfsc MIOS_PARAMETER2, 6
00311 rgoto TIA_MIDI_ProgramChange_End
4AFC D004 M bra label
00312
4AFE 00313 TIA_MIDI_ProgramChange_Ok
4AFE C004 F013 00314 movff MIOS_PARAMETER2, TIA_PATCH
4B02 ECBD F01A 00315 call TIA_PATCH_Init
00316 ;;goto USER_DISPLAY_Init
4B06 00317 TIA_MIDI_ProgramChange_End
4B06 0012 00318 return
00319
00320 ;; --------------------------------------------------------------------------
00321 ;; This function is rcalled to forward a Poly Aftertouch event to the synthesizer
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 137
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00322 ;; Input:
00323 ;; o first MIDI event byte in MIOS_PARAMETER1
00324 ;; o second MIDI event byte in MIOS_PARAMETER2
00325 ;; --------------------------------------------------------------------------
4B08 00326 TIA_MIDI_PolyAfterTouch
4B08 C004 F005 00327 movff MIOS_PARAMETER2, MIOS_PARAMETER3
00328 rgoto TIA_MIDI_AfterTouch
4B0C D000 M bra label
00329
00330 ;; --------------------------------------------------------------------------
00331 ;; This function is rcalled to forward a Aftertouch event to the synthesizer
00332 ;; Input:
00333 ;; o first MIDI event byte in MIOS_PARAMETER1
00334 ;; o second MIDI event byte in MIOS_PARAMETER2
00335 ;; o third MIDI event byte in MIOS_PARAMETER3
00336 ;; --------------------------------------------------------------------------
4B0E 00337 TIA_MIDI_AfterTouch
00338 SET_BSR TIA_BASE
4B0E 0101 M movlb HIGH(reg)
00339
4B10 5003 00340 movf MIOS_PARAMETER1, W ; leave routine if MIDI channel doesn't match
4B12 0B0F 00341 andlw 0x0f
4B14 6320 00342 cpfseq TIA_V1_BASE + TIA_Vx_MIDI_CHANNEL, BANKED
4B16 0012 00343 return
00344
4B18 5005 00345 movf MIOS_PARAMETER3, W
4B1A 00346 _TIA_MIDI_AfterTouch
4B1A 6E03 00347 movwf MIOS_PARAMETER1
00348 SET_BSR TIA_BASE ; prepare BSR for TIA register access
4B1C 0101 M movlb HIGH(reg)
4B1E EE11 F0E8 00349 lfsr FSR1, TIA_CTRL_AFTERTOUCH_BASE; prepare FSR1
4B22 EF2B F02B 00350 goto TIA_CCIN_Cmd_AFTERTOUCH ; set aftertouch value
00351
00352
00353 ;; --------------------------------------------------------------------------
00354 ;; help routines
00355 ;; --------------------------------------------------------------------------
00356
00357 ;; ------------------------------------------------------------------
00358 ;; Push a note into the stack
00359 ;; ------------------------------------------------------------------
4B26 00360 TIA_MIDI_Hlp_PushNote
4B26 6A06 00361 clrf TMP1
00362 ;; do nothing if note is already stored in note stack
4B28 00363 TIA_MIDI_Hlp_PushNote_CheckLoop
4B28 5006 00364 movf TMP1, W
4B2A 50E3 00365 movf PLUSW1, W
4B2C 1804 00366 xorwf MIOS_PARAMETER2, W
4B2E B4D8 00367 skpnz
00368 rgoto TIA_MIDI_Hlp_PushNote_Failed ; leave note routine if note already stored
4B30 D012 M bra label
4B32 2A06 00369 incf TMP1, F
4B34 0E04 00370 movlw TIA_NOTE_STACK_LEN
4B36 6206 00371 cpfseq TMP1, ACCESS
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 138
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00372 rgoto TIA_MIDI_Hlp_PushNote_CheckLoop
4B38 D7F7 M bra label
00373
00374 ;; shift right note stack
4B3A 0E02 00375 movlw (TIA_NOTE_STACK_LEN-2)
4B3C 6E06 00376 movwf TMP1
4B3E 00377 TIA_MIDI_Hlp_PushNote_ShiftLoop
4B3E 5006 00378 movf TMP1, W
4B40 CFE3 F007 00379 movff PLUSW1, TMP2
4B44 2806 00380 incf TMP1, W
4B46 C007 FFE3 00381 movff TMP2, PLUSW1
4B4A 0606 00382 decf TMP1, F
4B4C 2806 00383 incf TMP1, W
4B4E E1F7 00384 bnz TIA_MIDI_Hlp_PushNote_ShiftLoop
00385
00386 ;; store new note at offset 0
4B50 C004 FFE7 00387 movff MIOS_PARAMETER2, INDF1
00388
4B54 0C00 00389 retlw 0x00 ; return 0x00 as error status
00390
4B56 00391 TIA_MIDI_Hlp_PushNote_Failed
4B56 0C01 00392 retlw 0x01 ; return 0x01 as error status
00393
00394 ;; ------------------------------------------------------------------
00395
00396 ;; ------------------------------------------------------------------
00397 ;; Pop a note from the stack
00398 ;; ------------------------------------------------------------------
4B58 00399 TIA_MIDI_Hlp_PopNote
00400 ; search for note entry with the same number, erase it and push the entries behind
4B58 6A06 00401 clrf TMP1
4B5A 00402 TIA_MIDI_Hlp_PopNote_SearchLoop
4B5A 5006 00403 movf TMP1, W
4B5C 50E3 00404 movf PLUSW1, W
4B5E 1804 00405 xorwf MIOS_PARAMETER2, W
4B60 E005 00406 bz TIA_MIDI_Hlp_PopNote_Found
4B62 2A06 00407 incf TMP1, F
4B64 0E04 00408 movlw TIA_NOTE_STACK_LEN
4B66 6206 00409 cpfseq TMP1, ACCESS
00410 rgoto TIA_MIDI_Hlp_PopNote_SearchLoop
4B68 D7F8 M bra label
00411 rgoto TIA_MIDI_Hlp_PopNote_Failed
4B6A D00D M bra label
4B6C 00412 TIA_MIDI_Hlp_PopNote_Found
00413
00414 ;; push the entries behind the found entry
4B6C 00415 TIA_MIDI_Hlp_PopNote_ShiftLoop
4B6C 2806 00416 incf TMP1, W
4B6E CFE3 F007 00417 movff PLUSW1, TMP2
4B72 5006 00418 movf TMP1, W
4B74 C007 FFE3 00419 movff TMP2, PLUSW1
4B78 2A06 00420 incf TMP1, F
4B7A 0E04 00421 movlw TIA_NOTE_STACK_LEN
4B7C 6206 00422 cpfseq TMP1, ACCESS
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 139
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00423 rgoto TIA_MIDI_Hlp_PopNote_ShiftLoop
4B7E D7F6 M bra label
00424 ;; clear the last entry
4B80 0E03 00425 movlw TIA_NOTE_STACK_LEN-1
4B82 6AE3 00426 clrf PLUSW1
4B84 0C00 00427 retlw 0x00 ; return with 0x00: note deleted from stack
00428
4B86 00429 TIA_MIDI_Hlp_PopNote_Failed
4B86 0C01 00430 retlw 0x01 ; return with 0x01: note not found in stack
00431
00432 ;; ------------------------------------------------------------------
00433
00434 ;; ------------------------------------------------------------------
00435 ;; Note On help function
00436 ;; ------------------------------------------------------------------
4B88 00437 TIA_MIDI_Hlp_NoteOn
00438 ; BRA_IFCLR TIA_PLAY_MODE, TIA_PLAY_MODE_ONLY_WT_OFF, BANKED, TIA_MIDI_Hlp_NoteOn_NoNewNote
4B88 00439 TIA_MIDI_Hlp_NoteOn_NewNote
4B88 0E10 00440 movlw TIA_Vx_NOTE
4B8A CFEB FFF5 00441 movff PLUSW0, TABLAT
4B8E CFE7 FFEB 00442 movff INDF1, PLUSW0
4B92 00443 TIA_MIDI_Hlp_NoteOn_NoNewNote
00444
00445 ;; if sus-key enabled, skip enable portamento when only one key pressed
00446 ; BRA_IFCLR TIA_PLAY_MODE, TIA_PLAY_MODE_SUS_KEY, BANKED, TIA_MIDI_Hlp_NoteOn_SusKeyPor
00447
00448 ;; special case: don't disable portamento on a note off event
00449 ; movf MIOS_PARAMETER3, W
00450 ; bz TIA_MIDI_Hlp_NoteOn_SusKeySkip
00451
00452 ; movlw TIA_Vx_STAT
00453 ; bcf PLUSW0, Vx_STAT_PORTA_ENABLE
00454
00455 ; movlw 0x01
00456 ; movf PLUSW1, W
00457 ; bz TIA_MIDI_Hlp_NoteOn_SusKeyNoPor
00458
4B92 00459 TIA_MIDI_Hlp_NoteOn_SusKeyPor
00460 ;BRA_IFSET TIA_SE_OPTION, SE_OPTION_ENV2PORTA, BANKED, TIA_MIDI_Hlp_NoteOn_SusKeyPor_NC
00461 ;; enable portamento if rate is > 0
00462
4B92 0E0E 00463 movlw TIA_Vx_PORTA_RATE
4B94 50EB 00464 movf PLUSW0, W
4B96 E012 00465 bz TIA_MIDI_Hlp_NoteOn_SusKeyNoPor
4B98 00466 TIA_MIDI_Hlp_NoteOn_SusKeyPor_NC
4B98 0E03 00467 movlw TIA_Vx_STAT
4B9A 88EB 00468 bsf PLUSW0, Vx_STAT_PORTA_ENABLE
00469
00470 ;; store current frequency in TIA_Vx_PORTA_FRQ_L
00471
4B9C 0E09 00472 movlw TIA_Vx_FRQ_L
4B9E CFEB F006 00473 movff PLUSW0, TMP1
4BA2 0E0A 00474 movlw TIA_Vx_FRQ_H
4BA4 CFEB F007 00475 movff PLUSW0, TMP2
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 140
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00476
4BA8 0E1C 00477 movlw TIA_Vx_PORTA_FRQ_L
4BAA C006 FFEB 00478 movff TMP1, PLUSW0
4BAE 0E1D 00479 movlw TIA_Vx_PORTA_FRQ_H
4BB0 C007 FFEB 00480 movff TMP2, PLUSW0
00481
4BB4 0E1A 00482 movlw TIA_Vx_PORTA_CTR_L
4BB6 6AEB 00483 clrf PLUSW0
4BB8 0E1B 00484 movlw TIA_Vx_PORTA_CTR_H
4BBA 6AEB 00485 clrf PLUSW0
00486
00487 ;; reset Porta counter if constant time flag enabled
00488 ;movlw TIA_Vx_MODE
00489 ;CALL_IFSET PLUSW0, Vx_MODE_PORTA_CONST, ACCESS, TIA_SW_Hlp_PortaCTR_Reset
00490
4BBC 00491 TIA_MIDI_Hlp_NoteOn_SusKeyNoPor
00492 ;TIA_MIDI_Hlp_NoteOn_SusKeySkip
00493
00494 ;; always re-init arpeggiator (in mono as well as in legato mode)
4BBC 0E15 00495 movlw TIA_Vx_ARP_CTR
4BBE 6AEB 00496 clrf PLUSW0
4BC0 0E14 00497 movlw TIA_Vx_ARP_NOTE_NUMBER
4BC2 6AEB 00498 clrf PLUSW0 ; (next increment will play the second note)
00499
00500 ;; skip the rest if legato mode and current note is first note
00501 ; BRA_IFSET TIA_PLAY_MODE, TIA_PLAY_MODE_LEGATO_OFF, BANKED, TIA_MIDI_Hlp_NoteOn_TrgGateNL
00502 ; movf MIOS_PARAMETER2, W
00503 ; cpfseq INDF1, ACCESS
00504 ; rgoto TIA_MIDI_Hlp_NoteOn_TrgGateLSkp
00505 ; movlw 0x01
00506 ; movf PLUSW1, W
00507 ; bnz TIA_MIDI_Hlp_NoteOn_TrgGateLSkp
00508 ;TIA_MIDI_Hlp_NoteOn_TrgGateNL
00509
00510 ;; request gate bit
4BC4 D81C 00511 rcall TIA_MIDI_Hlp_GateOn
00512
00513
00514 ;; ---[ END handle velocity ]---
00515
00516 ;; ---[ BEGIN handle velocity ]---
00517
4BC6 C003 F006 00518 movff MIOS_PARAMETER1, TMP1 ; store MIOS_PARAMETER1
4BCA C004 F007 00519 movff MIOS_PARAMETER2, TMP2 ; store MIOS_PARAMETER2
4BCE 5005 00520 movf MIOS_PARAMETER3, W ; copy velocity value to MIOS_PARAMETER1
4BD0 E00D 00521 bz TIA_MIDI_Hlp_NoteOn_NoVel; no velocity on note off!
4BD2 6E03 00522 movwf MIOS_PARAMETER1
4BD4 0E28 00523 movlw TIA_Vx_LAST_VEL
4BD6 C005 FFEB 00524 movff MIOS_PARAMETER3, PLUSW0
00525 SET_BSR TIA_BASE ; prepare BSR for TIA register access
4BDA 0101 M movlb HIGH(reg)
4BDC EE10 F000 00526 lfsr FSR1, FSR0
4BE0 ECBC F02A 00527 call TIA_CCIN_Cmd_VELOCITY_SkpCopy ; set velocity value
4BE4 C006 F003 00528 movff TMP1, MIOS_PARAMETER1 ; restore MIOS_PARAMETER1
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 141
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
4BE8 C007 F004 00529 movff TMP2, MIOS_PARAMETER2 ; restore MIOS_PARAMETER2
00530 ;; ---[ END handle velocity ]---
00531
00532
00533
4BEC 00534 TIA_MIDI_Hlp_NoteOn_NoVel
00535
4BEC 00536 TIA_MIDI_Hlp_NoteOn_TrgGateLSkp
4BEC 0012 00537 return
00538
00539
00540 ;; ------------------------------------------------------------------
00541 ;; Note Off help function
00542 ;; ------------------------------------------------------------------
4BEE 00543 TIA_MIDI_Hlp_NoteOff
00544 ;; last note number of #0 (before pop) in WREG!
00545
00546 ;; if not in legato mode and current note-off number equal to last entry #0: gate off
00547 ; BRA_IFCLR TIA_PLAY_MODE, TIA_PLAY_MODE_LEGATO_OFF, BANKED, TIA_MIDI_Hlp_NoteOff_NoGOff
4BEE 6204 00548 cpfseq MIOS_PARAMETER2, ACCESS
00549 rgoto TIA_MIDI_Hlp_NoteOff_End
4BF0 D005 M bra label
4BF2 D812 00550 rcall TIA_MIDI_Hlp_GateOff
4BF4 00551 TIA_MIDI_Hlp_NoteOff_NoGOff
00552 ;; ------------------------------------------------------------------
00553
00554 ;; if still note available, play new note in NoteOn Section
4BF4 50E7 00555 movf INDF1, W
4BF6 A4D8 00556 skpz
4BF8 0C01 00557 retlw 0x01 ; return, request Note On!
00558
00559 ;; else request gate clear bit
4BFA D80E 00560 rcall TIA_MIDI_Hlp_GateOff
4BFC 00561 TIA_MIDI_Hlp_NoteOff_End
4BFC 0C00 00562 retlw 0x00 ; return, request NO Note On!
00563
00564 ;; ------------------------------------------------------------------
00565
00566 ;; ------------------------------------------------------------------
00567 ;; Gate On help function
00568 ;; ------------------------------------------------------------------
4BFE 00569 TIA_MIDI_Hlp_GateOn
4BFE 90D8 00570 clrc
4C00 0E11 00571 movlw TIA_Vx_NOTE_DELAY
4C02 34EB 00572 rlf PLUSW0, W
4C04 6EF5 00573 movwf TABLAT
4C06 0E12 00574 movlw TIA_Vx_NOTE_DELAY_CTR
4C08 CFF5 FFEB 00575 movff TABLAT, PLUSW0
00576
4C0C 0E03 00577 movlw TIA_Vx_STAT
00578 ;btfsc TIA_PLAY_MODE, TIA_PLAY_MODE_ONLY_WT_OFF, BANKED
4C0E 82EB 00579 bsf PLUSW0, Vx_STAT_GATE_SET_REQ
4C10 80EB 00580 bsf PLUSW0, Vx_STAT_VOICE_ACTIVE
00581
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 142
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00582 ;; reset wavetable handler
4C12 0E2E 00583 movlw TIA_Vx_WT_STATE
4C14 83EB 00584 bsf PLUSW0, WT_STATE_RESET, BANKED
00585
4C16 0012 00586 return
00587
00588 ;; ------------------------------------------------------------------
00589 ;; Gate Off help function
00590 ;; ------------------------------------------------------------------
4C18 00591 TIA_MIDI_Hlp_GateOff
4C18 90D8 00592 clrc
4C1A 0E11 00593 movlw TIA_Vx_NOTE_DELAY
4C1C 34EB 00594 rlf PLUSW0, W
4C1E 6EF5 00595 movwf TABLAT
4C20 0E12 00596 movlw TIA_Vx_NOTE_DELAY_CTR
4C22 CFF5 FFEB 00597 movff TABLAT, PLUSW0
00598
4C26 0E03 00599 movlw TIA_Vx_STAT
4C28 92EB 00600 bcf PLUSW0, Vx_STAT_GATE_SET_REQ
4C2A 84EB 00601 bsf PLUSW0, Vx_STAT_GATE_CLR_REQ
4C2C 90EB 00602 bcf PLUSW0, Vx_STAT_VOICE_ACTIVE
4C2E 0012 00603 return
00604
00605 ;; ------------------------------------------------------------------
00606 ;; for Note On/Note Off in Mono mode
00607 ;; MIDI channel in MIOS_PARAMETER1[0..3]
00608 ;; result in TMP5
4C30 00609 TIA_MIDI_GetAssignedChannels
4C30 6A0A 00610 clrf TMP5 ; TMP5 contains the voices which should be played
00611
4C32 5003 00612 movf MIOS_PARAMETER1, W
4C34 0B0F 00613 andlw 0x0f
4C36 1920 00614 xorwf TIA_V1_BASE + TIA_Vx_MIDI_CHANNEL, W, BANKED
4C38 B4D8 00615 skpnz
4C3A 800A 00616 bsf TMP5, 0 ; play voice 1
00617
4C3C 5003 00618 movf MIOS_PARAMETER1, W
4C3E 0B0F 00619 andlw 0x0f
4C40 1960 00620 xorwf TIA_V2_BASE + TIA_Vx_MIDI_CHANNEL, W, BANKED
4C42 B4D8 00621 skpnz
4C44 820A 00622 bsf TMP5, 1 ; play voice 2
00623
00624
4C46 500A 00625 movf TMP5, W
4C48 0012 00626 return
00627
00628 ;; ------------------------------------------------------------------
00629 ;; for Note On/Off in Mono mode
00630 ;; note number in MIOS_PARAMETER2
00631 ;; result will be ANDed to TMP5 --- TIA_MIDI_GetAssignedChannels should be called before!
00632 TIA_MIDI_GETASSIGNEDVOICEx MACRO FLAG_Vx, TIA_Vx_BASE
00633 LOCAL TIA_MIDI_GETASSIGNEDVOICEx_LOk
00634 LOCAL TIA_MIDI_GETASSIGNEDVOICEx_LOff
00635 LOCAL TIA_MIDI_GETASSIGNEDVOICEx_End
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 143
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00636
00637 ;; handle split points
00638 movf TIA_Vx_BASE + TIA_Vx_SPLIT_LOWER, W, BANKED ; (don't split if 0)
00639 iorwf TIA_Vx_BASE + TIA_Vx_SPLIT_UPPER, W, BANKED
00640 bz TIA_MIDI_GETASSIGNEDVOICEx_End
00641
00642 movf TIA_Vx_BASE + TIA_Vx_SPLIT_LOWER, W, BANKED
00643 cpfslt MIOS_PARAMETER2, ACCESS
00644 rgoto TIA_MIDI_GETASSIGNEDVOICEx_LOk
00645 rgoto TIA_MIDI_GETASSIGNEDVOICEx_LOff
00646
00647 TIA_MIDI_GETASSIGNEDVOICEx_LOk
00648 movf TIA_Vx_BASE + TIA_Vx_SPLIT_UPPER, W, BANKED
00649 cpfsgt MIOS_PARAMETER2, ACCESS
00650 rgoto TIA_MIDI_GETASSIGNEDVOICEx_End
00651 TIA_MIDI_GETASSIGNEDVOICEx_LOff
00652 bcf TMP5, FLAG_Vx ; don't play voice
00653 TIA_MIDI_GETASSIGNEDVOICEx_End
00654 ENDM
00655
4C4A 00656 TIA_MIDI_GetAssignedVoices
00657 TIA_MIDI_GETASSIGNEDVOICEx 0, TIA_V1_BASE
M LOCAL TIA_MIDI_GETASSIGNEDVOICEx_LOk
M LOCAL TIA_MIDI_GETASSIGNEDVOICEx_LOff
M LOCAL TIA_MIDI_GETASSIGNEDVOICEx_End
M
M ;; handle split points
4C4A 5121 M movf TIA_Vx_BASE + TIA_Vx_SPLIT_LOWER, W, BANKED ; (don't split if 0)
4C4C 1122 M iorwf TIA_Vx_BASE + TIA_Vx_SPLIT_UPPER, W, BANKED
4C4E E008 M bz TIA_MIDI_GETASSIGNEDVOICEx_End
M
4C50 5121 M movf TIA_Vx_BASE + TIA_Vx_SPLIT_LOWER, W, BANKED
4C52 6004 M cpfslt MIOS_PARAMETER2, ACCESS
M rgoto TIA_MIDI_GETASSIGNEDVOICEx_LOk
4C54 D001 M bra label
M rgoto TIA_MIDI_GETASSIGNEDVOICEx_LOff
4C56 D003 M bra label
M
4C58 M TIA_MIDI_GETASSIGNEDVOICEx_LOk
4C58 5122 M movf TIA_Vx_BASE + TIA_Vx_SPLIT_UPPER, W, BANKED
4C5A 6404 M cpfsgt MIOS_PARAMETER2, ACCESS
M rgoto TIA_MIDI_GETASSIGNEDVOICEx_End
4C5C D001 M bra label
4C5E M TIA_MIDI_GETASSIGNEDVOICEx_LOff
4C5E 900A M bcf TMP5, FLAG_Vx ; don't play voice
4C60 M TIA_MIDI_GETASSIGNEDVOICEx_End
00658 TIA_MIDI_GETASSIGNEDVOICEx 1, TIA_V2_BASE
M LOCAL TIA_MIDI_GETASSIGNEDVOICEx_LOk
M LOCAL TIA_MIDI_GETASSIGNEDVOICEx_LOff
M LOCAL TIA_MIDI_GETASSIGNEDVOICEx_End
M
M ;; handle split points
4C60 5161 M movf TIA_Vx_BASE + TIA_Vx_SPLIT_LOWER, W, BANKED ; (don't split if 0)
4C62 1162 M iorwf TIA_Vx_BASE + TIA_Vx_SPLIT_UPPER, W, BANKED
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 144
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
4C64 E008 M bz TIA_MIDI_GETASSIGNEDVOICEx_End
M
4C66 5161 M movf TIA_Vx_BASE + TIA_Vx_SPLIT_LOWER, W, BANKED
4C68 6004 M cpfslt MIOS_PARAMETER2, ACCESS
M rgoto TIA_MIDI_GETASSIGNEDVOICEx_LOk
4C6A D001 M bra label
M rgoto TIA_MIDI_GETASSIGNEDVOICEx_LOff
4C6C D003 M bra label
M
4C6E M TIA_MIDI_GETASSIGNEDVOICEx_LOk
4C6E 5162 M movf TIA_Vx_BASE + TIA_Vx_SPLIT_UPPER, W, BANKED
4C70 6404 M cpfsgt MIOS_PARAMETER2, ACCESS
M rgoto TIA_MIDI_GETASSIGNEDVOICEx_End
4C72 D001 M bra label
4C74 M TIA_MIDI_GETASSIGNEDVOICEx_LOff
4C74 920A M bcf TMP5, FLAG_Vx ; don't play voice
4C76 M TIA_MIDI_GETASSIGNEDVOICEx_End
4C76 500A 00659 movf TMP5, W
4C78 0012 00660 return
00661
00662 ;; ------------------------------------------------------------------
00663 ;; for Note On/Off in Mono mode
00664 ;; note number in MIOS_PARAMETER2
00665 ;; result will be ANDed to TMP5 --- TIA_MIDI_GetAssignedChannels should be called before!
00666 TIA_MIDI_GETASSIGNEDKEYx MACRO FLAG_Vx, TIA_Vx_BASE
00667 LOCAL TIA_MIDI_GETASSIGNEDKEYx_LOk
00668 LOCAL TIA_MIDI_GETASSIGNEDKEYx_LOff
00669 LOCAL TIA_MIDI_GETASSIGNEDKEYx_End
00670
00671 btfsc TIA_Vx_BASE + TIA_Vx_MODE, Vx_MODE_KEY_EXTENDED, BANKED
00672 rgoto TIA_MIDI_GETASSIGNEDKEYx_End
00673
00674 movf TIA_Vx_BASE + TIA_Vx_KEY_OFFSET, W, BANKED
00675 cpfslt MIOS_PARAMETER2, ACCESS
00676 rgoto TIA_MIDI_GETASSIGNEDKEYx_LOk
00677 rgoto TIA_MIDI_GETASSIGNEDKEYx_LOff
00678
00679 TIA_MIDI_GETASSIGNEDKEYx_LOk
00680 movlw 0x1f
00681 cpfsgt TIA_Vx_BASE + TIA_Vx_KEY_LENGTH, BANKED
00682 movf TIA_Vx_BASE + TIA_Vx_KEY_LENGTH, W, BANKED
00683 addwf TIA_Vx_BASE + TIA_Vx_KEY_OFFSET, W, BANKED
00684 cpfsgt MIOS_PARAMETER2, ACCESS
00685 rgoto TIA_MIDI_GETASSIGNEDKEYx_End
00686 TIA_MIDI_GETASSIGNEDKEYx_LOff
00687 bcf TMP5, FLAG_Vx ; don't play voice
00688 TIA_MIDI_GETASSIGNEDKEYx_End
00689 ENDM
00690
4C7A 00691 TIA_MIDI_GetAssignedKeys
00692 TIA_MIDI_GETASSIGNEDKEYx 0, TIA_V1_BASE
M LOCAL TIA_MIDI_GETASSIGNEDKEYx_LOk
M LOCAL TIA_MIDI_GETASSIGNEDKEYx_LOff
M LOCAL TIA_MIDI_GETASSIGNEDKEYx_End
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 145
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
M
4C7A B524 M btfsc TIA_Vx_BASE + TIA_Vx_MODE, Vx_MODE_KEY_EXTENDED, BANKED
M rgoto TIA_MIDI_GETASSIGNEDKEYx_End
4C7C D00B M bra label
M
4C7E 5125 M movf TIA_Vx_BASE + TIA_Vx_KEY_OFFSET, W, BANKED
4C80 6004 M cpfslt MIOS_PARAMETER2, ACCESS
M rgoto TIA_MIDI_GETASSIGNEDKEYx_LOk
4C82 D001 M bra label
M rgoto TIA_MIDI_GETASSIGNEDKEYx_LOff
4C84 D006 M bra label
M
4C86 M TIA_MIDI_GETASSIGNEDKEYx_LOk
4C86 0E1F M movlw 0x1f
4C88 6526 M cpfsgt TIA_Vx_BASE + TIA_Vx_KEY_LENGTH, BANKED
4C8A 5126 M movf TIA_Vx_BASE + TIA_Vx_KEY_LENGTH, W, BANKED
4C8C 2525 M addwf TIA_Vx_BASE + TIA_Vx_KEY_OFFSET, W, BANKED
4C8E 6404 M cpfsgt MIOS_PARAMETER2, ACCESS
M rgoto TIA_MIDI_GETASSIGNEDKEYx_End
4C90 D001 M bra label
4C92 M TIA_MIDI_GETASSIGNEDKEYx_LOff
4C92 900A M bcf TMP5, FLAG_Vx ; don't play voice
4C94 M TIA_MIDI_GETASSIGNEDKEYx_End
00693 TIA_MIDI_GETASSIGNEDKEYx 1, TIA_V2_BASE
M LOCAL TIA_MIDI_GETASSIGNEDKEYx_LOk
M LOCAL TIA_MIDI_GETASSIGNEDKEYx_LOff
M LOCAL TIA_MIDI_GETASSIGNEDKEYx_End
M
4C94 B564 M btfsc TIA_Vx_BASE + TIA_Vx_MODE, Vx_MODE_KEY_EXTENDED, BANKED
M rgoto TIA_MIDI_GETASSIGNEDKEYx_End
4C96 D00B M bra label
M
4C98 5165 M movf TIA_Vx_BASE + TIA_Vx_KEY_OFFSET, W, BANKED
4C9A 6004 M cpfslt MIOS_PARAMETER2, ACCESS
M rgoto TIA_MIDI_GETASSIGNEDKEYx_LOk
4C9C D001 M bra label
M rgoto TIA_MIDI_GETASSIGNEDKEYx_LOff
4C9E D006 M bra label
M
4CA0 M TIA_MIDI_GETASSIGNEDKEYx_LOk
4CA0 0E1F M movlw 0x1f
4CA2 6566 M cpfsgt TIA_Vx_BASE + TIA_Vx_KEY_LENGTH, BANKED
4CA4 5166 M movf TIA_Vx_BASE + TIA_Vx_KEY_LENGTH, W, BANKED
4CA6 2565 M addwf TIA_Vx_BASE + TIA_Vx_KEY_OFFSET, W, BANKED
4CA8 6404 M cpfsgt MIOS_PARAMETER2, ACCESS
M rgoto TIA_MIDI_GETASSIGNEDKEYx_End
4CAA D001 M bra label
4CAC M TIA_MIDI_GETASSIGNEDKEYx_LOff
4CAC 920A M bcf TMP5, FLAG_Vx ; don't play voice
4CAE M TIA_MIDI_GETASSIGNEDKEYx_End
4CAE 500A 00694 movf TMP5, W
4CB0 0012 00695 return
00696
00697
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 146
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00698 ;; ------------------------------------------------------------------
00699 ;; arpeggiator sorter
00700 ;; expecting base pointer to voice record in FSR2
4CB2 00701 TIA_MIDI_Arp_Sorter
00702 ;; TIA_Vx_ARP_NOTE_0 -> FSR0
4CB2 CFDA FFEA 00703 movff FSR2H, FSR0H
4CB6 50D9 00704 movf FSR2L, W
4CB8 0F1E 00705 addlw TIA_Vx_ARP_NOTE_0
4CBA 6EE9 00706 movwf FSR0L
00707
00708 ;; TIA_Vx_NOTE_STACK_0 -> FSR1
4CBC CFDA FFE2 00709 movff FSR2H, FSR1H
4CC0 50D9 00710 movf FSR2L, W
4CC2 0F22 00711 addlw TIA_Vx_NOTE_STACK_0
4CC4 6EE1 00712 movwf FSR1L
00713
4CC6 CFE9 F006 00714 movff FSR0L, TMP1 ; save pointer to ARP_NOTE_0 in TMP1
00715 ;; clear all current entries
4CCA 6AEE 00716 clrf POSTINC0 ; (TIA_Vx_ARP_NOTE_0)
4CCC 6AEE 00717 clrf POSTINC0 ; (TIA_Vx_ARP_NOTE_1)
4CCE 6AEE 00718 clrf POSTINC0 ; (TIA_Vx_ARP_NOTE_2)
4CD0 6AEE 00719 clrf POSTINC0 ; (TIA_Vx_ARP_NOTE_3)
4CD2 C006 FFE9 00720 movff TMP1, FSR0L ; restore pointer to ARP_NOTE_0 from TMP1
00721
4CD6 50E7 00722 movf INDF1, W ; (TIA_Vx_NOTE_STACK_0)
4CD8 E017 00723 bz TIA_MIDI_Arp_Sorter_End
00724
4CDA 50E6 00725 movf POSTINC1, W ; (TIA_Vx_NOTE_STACK_0)
4CDC D816 00726 rcall TIA_MIDI_ARP_Sorter_Add
4CDE 50E6 00727 movf POSTINC1, W ; (TIA_Vx_NOTE_STACK_1)
4CE0 D814 00728 rcall TIA_MIDI_ARP_Sorter_Add
4CE2 50E6 00729 movf POSTINC1, W ; (TIA_Vx_NOTE_STACK_2)
4CE4 D812 00730 rcall TIA_MIDI_ARP_Sorter_Add
4CE6 50E6 00731 movf POSTINC1, W ; (TIA_Vx_NOTE_STACK_3)
4CE8 D810 00732 rcall TIA_MIDI_ARP_Sorter_Add
00733
00734 ;; if rate is > 0, and arp has been reset: copy first arp note into TIA_Vx_NOTE
4CEA 0E13 00735 movlw TIA_Vx_ARP_RATE
4CEC 50DB 00736 movf PLUSW2, W
4CEE E00C 00737 bz TIA_MIDI_Arp_Sorter_End
4CF0 0E15 00738 movlw TIA_Vx_ARP_CTR
4CF2 50DB 00739 movf PLUSW2, W
4CF4 E109 00740 bnz TIA_MIDI_Arp_Sorter_End
4CF6 0E14 00741 movlw TIA_Vx_ARP_NOTE_NUMBER
4CF8 50DB 00742 movf PLUSW2, W
4CFA E106 00743 bnz TIA_MIDI_Arp_Sorter_End
00744
4CFC 0E1E 00745 movlw TIA_Vx_ARP_NOTE_0
4CFE CFDB FFF5 00746 movff PLUSW2, TABLAT
4D02 0E10 00747 movlw TIA_Vx_NOTE
4D04 CFF5 FFDB 00748 movff TABLAT, PLUSW2
00749
4D08 00750 TIA_MIDI_Arp_Sorter_End
4D08 0012 00751 return
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 147
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00752
00753 ;; ---
00754 ;; add to ARP note buffer, sort automatically from lowest to highest note
4D0A 00755 TIA_MIDI_ARP_Sorter_Add
4D0A B4D8 00756 skpnz ; only add notes > 0
4D0C 0012 00757 return
00758
4D0E 6E06 00759 movwf TMP1 ; store new note number in TMP2
4D10 6A07 00760 clrf TMP2 ; TMP2 used as loop counter
4D12 00761 TIA_MIDI_ARP_Sorter_Loop
4D12 5007 00762 movf TMP2, W
4D14 50EB 00763 movf PLUSW0, W
4D16 E006 00764 bz TIA_MIDI_ARP_Sorter_Push; the fourth note will ever be pushed as the appr. byte is zero
4D18 5C06 00765 subwf TMP1, W
4D1A E304 00766 bnc TIA_MIDI_ARP_Sorter_Push
4D1C 2A07 00767 incf TMP2, F
00768 BRA_IFCLR TMP2, 2, ACCESS, TIA_MIDI_ARP_Sorter_Loop
4D1E A407 M btfss reg, bit, reg_a
4D20 D7F8 M bra label
4D22 0012 00769 return ; this case never happens
00770
4D24 00771 TIA_MIDI_ARP_Sorter_Push
4D24 5007 00772 movf TMP2, W ; fourth note: no shift required
4D26 0A03 00773 xorlw 0x03
4D28 E00D 00774 bz TIA_MIDI_ARP_Sorter_PushN
4D2A 0E02 00775 movlw 0x02
4D2C 6E08 00776 movwf TMP3
4D2E 00777 TIA_MIDI_ARP_Sorter_PushL
4D2E 5008 00778 movf TMP3, W
4D30 CFEB F009 00779 movff PLUSW0, TMP4
4D34 0F01 00780 addlw 1
4D36 C009 FFEB 00781 movff TMP4, PLUSW0
4D3A 5007 00782 movf TMP2, W
4D3C 1808 00783 xorwf TMP3, W
4D3E E002 00784 bz TIA_MIDI_ARP_Sorter_PushN
4D40 0608 00785 decf TMP3, F
00786 rgoto TIA_MIDI_ARP_Sorter_PushL
4D42 D7F5 M bra label
00787
4D44 00788 TIA_MIDI_ARP_Sorter_PushN
4D44 5007 00789 movf TMP2, W
4D46 C006 FFEB 00790 movff TMP1, PLUSW0
4D4A 0012 00791 return
00374 #include "tia_sysex.inc"
00001 ; $Id: tia_sysex.inc bdupeyron.tech@gmail.com(Antichambre)
00002 ;
00003 ; MIDIbox TIA SysEx Parser
00004 ;
00005 ; ==========================================================================
00006 ;
00007 ; Copyright 1998-2006 Thorsten Klose (tk@midibox.org)
00008 ; Licensed for personal non-commercial use only.
00009 ; All other rights reserved.
00010 ;
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 148
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00011 ; ==========================================================================
00012
00000007 00013 TIA_SYSEX_STATE_MYSYSEX EQU 7
00000006 00014 TIA_SYSEX_STATE_ACTION EQU 6
00015
00000005 00016 TIA_SYSEX_STATE_PRESET_RECEIVED EQU 5 ; used by Action PATCH_[Read/Write]
00000004 00017 TIA_SYSEX_STATE_BANK_RECEIVED EQU 4 ; used by Action PATCH_[Read/Write]
00000003 00018 TIA_SYSEX_STATE_TYPE_RECEIVED EQU 3 ; used by Action PATCH_[Read/Write]
00000002 00019 TIA_SYSEX_STATE_WAIT_CHECKSUM EQU 2 ; used by Action PATCH_Write
00020
00000005 00021 TIA_SYSEX_STATE_AH_RECEIVED EQU 5 ; used by Action PAR_[Read/Write]
00000004 00022 TIA_SYSEX_STATE_AL_RECEIVED EQU 4 ; used by Action PAR_[Read/Write]
00000003 00023 TIA_SYSEX_STATE_D_RECEIVED EQU 3 ; used by Action PAR_[Write]
00024
00000005 00025 TIA_SYSEX_STATE_A_RECEIVED EQU 5 ; used by Action CFG_[Read/Write]
00000004 00026 TIA_SYSEX_STATE_DH_RECEIVED EQU 4 ; used by Action CFG_[Read/Write]
00000003 00027 TIA_SYSEX_STATE_DL_RECEIVED EQU 3 ; used by Action CFG_[Read/Write]
00028
00029 ;; --------------------------------------------------------------------------
00030 ;; This sysex parser waits for the TIA Header
00031 ;; --------------------------------------------------------------------------
4D4C 00032 TIA_SYSEX_SysExCheck
00033 ;; store received byte in TIA_SYSEX_IN
4D4C 6E23 00034 movwf TIA_SYSEX_IN
00035
00036 ;; ignore realtime messages
4D4E 0EF8 00037 movlw 0xf8
4D50 6023 00038 cpfslt TIA_SYSEX_IN, ACCESS
4D52 0012 00039 return
00040
00041 ;; check sysex state
00042 BRA_IFSET TIA_SYSEX_STATE, TIA_SYSEX_STATE_MYSYSEX, ACCESS, TIA_SYSEX_Handler
4D54 BE21 M btfsc reg, bit, reg_a
4D56 D020 M bra label
00043
4D58 5021 00044 movf TIA_SYSEX_STATE, W
4D5A D80E 00045 rcall TIA_SYSEX_SysExHeaderGet
4D5C 6223 00046 cpfseq TIA_SYSEX_IN, ACCESS
00047 rgoto TIA_SYSEX_SysExCheckFailed
4D5E D00A M bra label
4D60 2A21 00048 incf TIA_SYSEX_STATE, F
4D62 5021 00049 movf TIA_SYSEX_STATE, W
4D64 0B07 00050 andlw 0x07
4D66 0A06 00051 xorlw 0x06 ; wait for 6 bytes (f0 00 00 7E 46 <device-id>)
4D68 E106 00052 bnz TIA_SYSEX_SysExCheckOk
00053
00054 ;; SysEx ID received, lets go
4D6A 0E80 00055 movlw (1 << TIA_SYSEX_STATE_MYSYSEX)
4D6C 6E21 00056 movwf TIA_SYSEX_STATE
4D6E EC28 F016 00057 call MIOS_MPROC_MergerDisable
00058 rgoto TIA_SYSEX_SysExCheckOk
4D72 D001 M bra label
00059
4D74 00060 TIA_SYSEX_SysExCheckFailed
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 149
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00061 ;; reset the sysex counter and action ID
4D74 D80B 00062 rcall TIA_SYSEX_ActionInvalid
4D76 00063 TIA_SYSEX_SysExCheckOk
00064
4D76 00065 TIA_SYSEX_SysExCheck_End
4D76 0012 00066 return
00067
00068 ; ==========================================================================
00069
00070 ;; --------------------------------------------------------------------------
00071 ;; Returns expected MIDI bytes from SysEx header
00072 ;; --------------------------------------------------------------------------
4D78 00073 TIA_SYSEX_SysExHeaderGet
4D78 0B07 00074 andlw 0x07
00075 JUMPTABLE_2BYTES_UNSECURE
4D7A ECC8 F016 M call MIOS_HLP_GetIndex_2bytes
4D7E 0CF0 00076 retlw 0xf0
4D80 0C00 00077 retlw 0x00 ; Vendor ID
4D82 0C00 00078 retlw 0x00
4D84 0C7E 00079 retlw 0x7e
4D86 0C51 00080 retlw 0x51 ; MIDIbox TIA ID (51 - the ultimative number + 4)
4D88 5020 00081 movf TIA_MIDI_DEVICE, W
4D8A 0012 00082 return
00083
00084 ;; --------------------------------------------------------------------------
00085 ;; Action Invalid will be invoked when receiving an invalid sequence
00086 ;; --------------------------------------------------------------------------
4D8C 00087 TIA_SYSEX_ActionInvalid
00088
00089 ;; --------------------------------------------------------------------------
00090 ;; Action finished will be invoked when midi action is done
00091 ;; --------------------------------------------------------------------------
4D8C 00092 TIA_SYSEX_ActionFinished
4D8C 6A21 00093 clrf TIA_SYSEX_STATE
4D8E 6A22 00094 clrf TIA_SYSEX_ACTION
00095 ;; reinit patch if engine has been disabled during upload
4D90 9010 00096 bcf TIA_STAT, TIA_STAT_ENGINE_DISABLE
00097
4D92 EC2A F016 00098 call MIOS_MPROC_MergerEnable
00099 rgoto TIA_SYSEX_SysExCheck_End
4D96 D7EF M bra label
00100
00101
00102 ;; --------------------------------------------------------------------------
00103 ;; MIDI Check action: perform a sysex action
00104 ;; --------------------------------------------------------------------------
4D98 00105 TIA_SYSEX_Handler
00106 BRA_IFSET TIA_SYSEX_STATE, TIA_SYSEX_STATE_ACTION, ACCESS, TIA_SYSEX_Handler_DoAction
4D98 BC21 M btfsc reg, bit, reg_a
4D9A D005 M bra label
00107
4D9C 8C21 00108 bsf TIA_SYSEX_STATE, TIA_SYSEX_STATE_ACTION
00109
4D9E C023 F022 00110 movff TIA_SYSEX_IN, TIA_SYSEX_ACTION ; store action ID
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 150
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
4DA2 D81A 00111 rcall TIA_SYSEX_Handler_InitAction ; initialize the action
00112 rgoto TIA_SYSEX_SysExCheck_End ; branch to the end
4DA4 D7E8 M bra label
00113
00114 ;; ---
00115
4DA6 00116 TIA_SYSEX_Handler_DoAction
00117 ;; branch to end if status byte (i.e. F7)
00118 BRA_IFSET TIA_SYSEX_IN, 7, ACCESS, TIA_SYSEX_Handler_EndAction
4DA6 BE23 M btfsc reg, bit, reg_a
4DA8 D02E M bra label
00119
00120 ;; branch depending on current action ID
4DAA 5022 00121 movf TIA_SYSEX_ACTION, W
00122 JUMPTABLE_2BYTES 16 ; 16 entries
4DAC 0FF0 M addlw -(max_value) ; ensure that jump index is not greater than (max_value-1)
4DAE B0D8 M skpnc
4DB0 0EF0 M movlw -(max_value)
4DB2 0F10 M addlw max_value
4DB4 ECC8 F016 M call MIOS_HLP_GetIndex_2bytes
00123 rgoto TIA_SYSEX_ActionInvalid
4DB8 D7E9 M bra label
00124 rgoto TIA_SYSEX_Action_PRESET_Read
4DBA D040 M bra label
00125 rgoto TIA_SYSEX_Action_PRESET_Write
4DBC D091 M bra label
00126 rgoto TIA_SYSEX_Action_BANK_Read
4DBE D10C M bra label
00127 rgoto TIA_SYSEX_Action_BANK_WriteName
4DC0 D16D M bra label
00128 rgoto TIA_SYSEX_Action_PAR_Read
4DC2 D1BC M bra label
00129 rgoto TIA_SYSEX_Action_PAR_Write
4DC4 D1EC M bra label
00130 rgoto TIA_SYSEX_ActionInvalid
4DC6 D7E2 M bra label
00131 rgoto TIA_SYSEX_ActionInvalid
4DC8 D7E1 M bra label
00132 rgoto TIA_SYSEX_ActionInvalid
4DCA D7E0 M bra label
00133 rgoto TIA_SYSEX_ActionInvalid
4DCC D7DF M bra label
00134 rgoto TIA_SYSEX_Action_BANK_Sel
4DCE D21D M bra label
00135 rgoto TIA_SYSEX_Action_CFG_Read
4DD0 D235 M bra label
00136 rgoto TIA_SYSEX_Action_CFG_Write
4DD2 D2BD M bra label
00137 rgoto TIA_SYSEX_Action_RequestCC
4DD4 D2ED M bra label
00138 rgoto TIA_SYSEX_Action_Ping
4DD6 D2F0 M bra label
00139
00140
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 151
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00141 ;; --------------------------------------------------------------------------
00142 ;; Initialize an action depending on TIA_SYSEX_ACTION
00143 ;; --------------------------------------------------------------------------
4DD8 00144 TIA_SYSEX_Handler_InitAction
4DD8 5022 00145 movf TIA_SYSEX_ACTION, W
00146 JUMPTABLE_2BYTES 16 ; 16 entries
4DDA 0FF0 M addlw -(max_value) ; ensure that jump index is not greater than (max_value-1)
4DDC B0D8 M skpnc
4DDE 0EF0 M movlw -(max_value)
4DE0 0F10 M addlw max_value
4DE2 ECC8 F016 M call MIOS_HLP_GetIndex_2bytes
00147 rgoto TIA_SYSEX_ActionInvalid
4DE6 D7D2 M bra label
00148 rgoto TIA_SYSEX_Init_PRESET_Read
4DE8 D028 M bra label
00149 rgoto TIA_SYSEX_Init_PRESET_Write
4DEA D076 M bra label
00150 rgoto TIA_SYSEX_Init_BANK_Read
4DEC D0F1 M bra label
00151 rgoto TIA_SYSEX_Init_BANK_WriteName
4DEE D155 M bra label
00152 rgoto TIA_SYSEX_Init_PAR_Read
4DF0 D1A4 M bra label
00153 rgoto TIA_SYSEX_Init_PAR_Write
4DF2 D1D4 M bra label
00154 rgoto TIA_SYSEX_ActionInvalid
4DF4 D7CB M bra label
00155 rgoto TIA_SYSEX_ActionInvalid
4DF6 D7CA M bra label
00156 rgoto TIA_SYSEX_ActionInvalid
4DF8 D7C9 M bra label
00157 rgoto TIA_SYSEX_ActionInvalid
4DFA D7C8 M bra label
00158 rgoto TIA_SYSEX_Init_BANK_Sel
4DFC D204 M bra label
00159 rgoto TIA_SYSEX_Init_CFG_Read
4DFE D21D M bra label
00160 rgoto TIA_SYSEX_Init_CFG_Write
4E00 D2A4 M bra label
00161 rgoto TIA_SYSEX_Init_RequestCC
4E02 D2D5 M bra label
00162 rgoto TIA_SYSEX_Init_Ping
4E04 D2D8 M bra label
00163
00164
00165 ;; --------------------------------------------------------------------------
00166 ;; Finish an action depending on TIA_SYSEX_ACTION
00167 ;; --------------------------------------------------------------------------
4E06 00168 TIA_SYSEX_Handler_EndAction
00169 ;; if sysex footer (F7) has not been received here, action is invalid!
4E06 0EF7 00170 movlw 0xf7
4E08 1823 00171 xorwf TIA_SYSEX_IN, W
4E0A E1C0 00172 bnz TIA_SYSEX_ActionInvalid
00173
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 152
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00174 ;; else finish action
4E0C 5022 00175 movf TIA_SYSEX_ACTION, W
00176 JUMPTABLE_2BYTES 16 ; 16 entries
4E0E 0FF0 M addlw -(max_value) ; ensure that jump index is not greater than (max_value-1)
4E10 B0D8 M skpnc
4E12 0EF0 M movlw -(max_value)
4E14 0F10 M addlw max_value
4E16 ECC8 F016 M call MIOS_HLP_GetIndex_2bytes
00177 rgoto TIA_SYSEX_ActionInvalid
4E1A D7B8 M bra label
00178 rgoto TIA_SYSEX_End_PRESET_Read
4E1C D022 M bra label
00179 rgoto TIA_SYSEX_End_PRESET_Write
4E1E D087 M bra label
00180 rgoto TIA_SYSEX_End_BANK_Read
4E20 D0E8 M bra label
00181 rgoto TIA_SYSEX_End_BANK_WriteName
4E22 D155 M bra label
00182 rgoto TIA_SYSEX_End_PAR_Read
4E24 D19A M bra label
00183 rgoto TIA_SYSEX_End_PAR_Write
4E26 D1D0 M bra label
00184 rgoto TIA_SYSEX_ActionInvalid
4E28 D7B1 M bra label
00185 rgoto TIA_SYSEX_ActionInvalid
4E2A D7B0 M bra label
00186 rgoto TIA_SYSEX_ActionInvalid
4E2C D7AF M bra label
00187 rgoto TIA_SYSEX_ActionInvalid
4E2E D7AE M bra label
00188 rgoto TIA_SYSEX_End_BANK_Sel
4E30 D1EF M bra label
00189 rgoto TIA_SYSEX_End_CFG_Read
4E32 D20B M bra label
00190 rgoto TIA_SYSEX_End_CFG_Write
4E34 D2A0 M bra label
00191 rgoto TIA_SYSEX_End_RequestCC
4E36 D2BD M bra label
00192 rgoto TIA_SYSEX_End_Ping
4E38 D2C0 M bra label
00193
00194 ;; --------------------------------------------------------------------------
00195 ;; MIDI Action: Patch Read
00196 ;; --------------------------------------------------------------------------
4E3A 00197 TIA_SYSEX_Init_PRESET_Read
4E3A 0012 00198 return
00199
4E3C 00200 TIA_SYSEX_Action_PRESET_Read
00201 ;; receive <type> <bank> <patch> F7
4E3C 00202 TIA_SYSEX_Action_PRESET_Read_T
00203 BRA_IFSET TIA_SYSEX_STATE, TIA_SYSEX_STATE_TYPE_RECEIVED, ACCESS, TIA_SYSEX_Action_PRESET_Read_B
4E3C B621 M btfsc reg, bit, reg_a
4E3E D004 M bra label
4E40 8621 00204 bsf TIA_SYSEX_STATE, TIA_SYSEX_STATE_TYPE_RECEIVED
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 153
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
4E42 C023 F025 00205 movff TIA_SYSEX_IN, TIA_SYSEX_ADDRESS ; load preset type
00206 rgoto TIA_SYSEX_SysExCheck_End ; wait for next byte
4E46 D797 M bra label
00207
4E48 00208 TIA_SYSEX_Action_PRESET_Read_B
00209 BRA_IFSET TIA_SYSEX_STATE, TIA_SYSEX_STATE_BANK_RECEIVED, ACCESS, TIA_SYSEX_Action_PRESET_Read_P
4E48 B821 M btfsc reg, bit, reg_a
4E4A D004 M bra label
4E4C 8821 00210 bsf TIA_SYSEX_STATE, TIA_SYSEX_STATE_BANK_RECEIVED
4E4E C023 F011 00211 movff TIA_SYSEX_IN, TIA_BANK ; load bank
00212 rgoto TIA_SYSEX_SysExCheck_End ; wait for next byte
4E52 D791 M bra label
00213
4E54 00214 TIA_SYSEX_Action_PRESET_Read_P
00215 BRA_IFSET TIA_SYSEX_STATE, TIA_SYSEX_STATE_PRESET_RECEIVED, ACCESS, TIA_SYSEX_Action_PRESET_ReadStall
4E54 BA21 M btfsc reg, bit, reg_a
4E56 D004 M bra label
4E58 8A21 00216 bsf TIA_SYSEX_STATE, TIA_SYSEX_STATE_PRESET_RECEIVED
4E5A C023 F012 00217 movff TIA_SYSEX_IN, TIA_PRESET ; load preset
00218 rgoto TIA_SYSEX_SysExCheck_End ; wait for next byte
4E5E D78B M bra label
00219
4E60 00220 TIA_SYSEX_Action_PRESET_ReadStall
00221 ;; do nothing until sysex footer (F7) has been received
00222 rgoto TIA_SYSEX_SysExCheck_End
4E60 D78A M bra label
00223
4E62 00224 TIA_SYSEX_End_PRESET_Read
00225 ;; action invalid if patch number has not been received
00226 BRA_IFCLR TIA_SYSEX_STATE, TIA_SYSEX_STATE_PRESET_RECEIVED, ACCESS, TIA_SYSEX_ActionInvalid
4E62 AA21 M btfss reg, bit, reg_a
4E64 D793 M bra label
00227
4E66 C011 F007 00228 movff TIA_BANK, TMP2 ;; store relative bank
4E6A 5025 00229 movf TIA_SYSEX_ADDRESS, W
4E6C DAFD 00230 rcall TIA_SYSEX_Hlp_GetAbsoluteBank ; set bank to absolute
4E6E 6E26 00231 movwf TIA_SYSEX_ERROR
4E70 E10F 00232 bnz TIA_SYSEX_End_PRESET_Read_Cont
00233
4E72 5012 00234 movf TIA_PRESET, W
4E74 E00D 00235 bz TIA_SYSEX_End_PRESET_Read_Cont
4E76 5011 00236 movf TIA_BANK, W
4E78 EC7E F01B 00237 call TIA_BANK_GetBankStickReady
4E7C A4D8 00238 skpz
00239 rgoto TIA_SYSEX_End_PRESET_Read_Size
4E7E D003 M bra label
00240 ;; BS not ready Error #3
4E80 0E03 00241 movlw 0x03
4E82 6E26 00242 movwf TIA_SYSEX_ERROR
00243 rgoto TIA_SYSEX_End_PRESET_Read_Cont
4E84 D005 M bra label
4E86 00244 TIA_SYSEX_End_PRESET_Read_Size
4E86 EC8B F01B 00245 call TIA_BANK_GetBankStickSize
4E8A E102 00246 bnz TIA_SYSEX_End_PRESET_Read_Cont
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 154
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00247
4E8C BC12 00248 btfsc TIA_PRESET, 6
4E8E 6A12 00249 clrf TIA_PRESET
00250
4E90 00251 TIA_SYSEX_End_PRESET_Read_Cont
00252
00253 ;; send SysEx header
4E90 DA9C 00254 rcall TIA_SYSEX_Send_SysExHeader
00255
00256 ;; Send PRESET_Read ID
4E92 0E01 00257 movlw 0x01
4E94 EC24 F016 00258 call MIOS_MIDI_TxBufferPut
00259
00260 ;; send requested preset type number
4E98 5025 00261 movf TIA_SYSEX_ADDRESS, W
4E9A 0B7F 00262 andlw 0x7f
4E9C EC24 F016 00263 call MIOS_MIDI_TxBufferPut
00264
00265 ;; send requested relative bank number
4EA0 5007 00266 movf TMP2, W
4EA2 0B1F 00267 andlw 0x1f
4EA4 EC24 F016 00268 call MIOS_MIDI_TxBufferPut
00269
00270 ;; send requested preset number
4EA8 5012 00271 movf TIA_PRESET, W
4EAA 0B7F 00272 andlw 0x7f
4EAC EC24 F016 00273 call MIOS_MIDI_TxBufferPut
00274
4EB0 5026 00275 movf TIA_SYSEX_ERROR, W
4EB2 E004 00276 bz TIA_SYSEX_End_PRESET_Read_Cont_Ok
4EB4 0B7F 00277 andlw 0x7f
4EB6 EC24 F016 00278 call MIOS_MIDI_TxBufferPut
00279 rgoto TIA_SYSEX_End_PRESET_Read_Footer
4EBA D00B M bra label
00280
4EBC 00281 TIA_SYSEX_End_PRESET_Read_Cont_Ok
00282 ;; clear checksum
4EBC 6A24 00283 clrf TIA_SYSEX_CHECKSUM
00284
00285 ;movf TIA_SYSEX_ADDRESS, W
00286 ;rcall TIA_SYSEX_Hlp_GetAbsoluteBank ; set bank to absolute
00287
4EBE 5025 00288 movf TIA_SYSEX_ADDRESS, W
4EC0 E102 00289 bnz TIA_SYSEX_End_PRESET_Read_Cont_WTKit
00290 ;; send patch (128 bytes)
4EC2 00291 TIA_SYSEX_End_PRESET_Read_Cont_Patch
4EC2 DAA1 00292 rcall TIA_SYSEX_Hlp_SendPreset
00293 rgoto TIA_SYSEX_End_PRESET_Read_Cont_ChkSum
4EC4 D001 M bra label
00294
4EC6 00295 TIA_SYSEX_End_PRESET_Read_Cont_WTKit
4EC6 DAB4 00296 rcall TIA_SYSEX_Hlp_SendWTKit
00297
4EC8 00298 TIA_SYSEX_End_PRESET_Read_Cont_ChkSum
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 155
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00299 ;; send checksum
4EC8 5024 00300 movf TIA_SYSEX_CHECKSUM, W
4ECA 0880 00301 sublw 0x80
4ECC 0B7F 00302 andlw 0x7f
4ECE EC24 F016 00303 call MIOS_MIDI_TxBufferPut
00304
4ED2 00305 TIA_SYSEX_End_PRESET_Read_Footer
00306 ;; send of SysEx footer
4ED2 0E01 00307 movlw 0x01 ; (independend from merger state)
4ED4 DA8D 00308 rcall TIA_SYSEX_Send_SysExFooter
00309
00310 ;; finish Action
00311 rgoto TIA_SYSEX_ActionFinished
4ED6 D75A M bra label
00312
00313 ;; --------------------------------------------------------------------------
00314 ;; MIDI Action: Patch Write
00315 ;; --------------------------------------------------------------------------
4ED8 00316 TIA_SYSEX_Init_PRESET_Write
00317 ;; disable TIA engine until end of transfer (will be requested by ActionFinished)
4ED8 8010 00318 bsf TIA_STAT, TIA_STAT_ENGINE_DISABLE
4EDA EC50 F01E 00319 call TIA_TUNE_Note_Off
4EDE 0012 00320 return
00321
4EE0 00322 TIA_SYSEX_Action_PRESET_Write
00323 ;; receive <type> <bank> <patch> <128 bytes> F7
4EE0 00324 TIA_SYSEX_Action_PRESET_WriteT
00325 BRA_IFSET TIA_SYSEX_STATE, TIA_SYSEX_STATE_TYPE_RECEIVED, ACCESS, TIA_SYSEX_Action_PRESET_WriteB
4EE0 B621 M btfsc reg, bit, reg_a
4EE2 D004 M bra label
4EE4 8621 00326 bsf TIA_SYSEX_STATE, TIA_SYSEX_STATE_TYPE_RECEIVED
4EE6 C023 F025 00327 movff TIA_SYSEX_IN, TIA_SYSEX_ADDRESS ; load preset type
00328 rgoto TIA_SYSEX_SysExCheck_End ; wait for next byte
4EEA D745 M bra label
00329
4EEC 00330 TIA_SYSEX_Action_PRESET_WriteB
00331 BRA_IFSET TIA_SYSEX_STATE, TIA_SYSEX_STATE_BANK_RECEIVED, ACCESS, TIA_SYSEX_Action_PRESET_WriteP
4EEC B821 M btfsc reg, bit, reg_a
4EEE D004 M bra label
4EF0 8821 00332 bsf TIA_SYSEX_STATE, TIA_SYSEX_STATE_BANK_RECEIVED
4EF2 C023 F011 00333 movff TIA_SYSEX_IN, TIA_BANK ; load bank
00334 rgoto TIA_SYSEX_SysExCheck_End ; wait for next byte
4EF6 D73F M bra label
00335
4EF8 00336 TIA_SYSEX_Action_PRESET_WriteP
00337 BRA_IFSET TIA_SYSEX_STATE, TIA_SYSEX_STATE_PRESET_RECEIVED, ACCESS, TIA_SYSEX_Action_PRESET_WriteC
4EF8 BA21 M btfsc reg, bit, reg_a
4EFA D007 M bra label
4EFC 8A21 00338 bsf TIA_SYSEX_STATE, TIA_SYSEX_STATE_PRESET_RECEIVED
4EFE C023 F012 00339 movff TIA_SYSEX_IN, TIA_PRESET ; load preset
00340
4F02 6A24 00341 clrf TIA_SYSEX_CHECKSUM ; clear checksum
4F04 6AA9 00342 clrf EEADR ; clear address
4F06 6A26 00343 clrf TIA_SYSEX_ERROR ; clear reply error
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 156
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00344 rgoto TIA_SYSEX_SysExCheck_End ; wait for next byte
4F08 D736 M bra label
00345
4F0A 00346 TIA_SYSEX_Action_PRESET_WriteC
00347 BRA_IFSET TIA_SYSEX_STATE, TIA_SYSEX_STATE_WAIT_CHECKSUM, ACCESS, TIA_SYSEX_Action_PRESET_WriteChk
4F0A B421 M btfsc reg, bit, reg_a
4F0C D00D M bra label
00348
4F0E EE07 F000 00349 lfsr FSR0, BANKSTICK_FORMAT_BEGIN ; init pointer to upload buffer
4F12 CFA9 FFE9 00350 movff EEADR, FSR0L
00351
00352 ;; store received byte in upload buffer
4F16 5023 00353 movf TIA_SYSEX_IN, W
4F18 6EEF 00354 movwf INDF0
00355
00356 ;; add to checksum
4F1A 0B7F 00357 andlw 0x7f
4F1C 2624 00358 addwf TIA_SYSEX_CHECKSUM, F
00359
00360 ;; increment address
4F1E 2AA9 00361 incf EEADR, F
00362
00363 ;; if FSR0L is zero, go into WAIT_CHECKSUM state
4F20 0E80 00364 movlw 0x80
4F22 60A9 00365 cpfslt EEADR, ACCESS
4F24 8421 00366 bsf TIA_SYSEX_STATE, TIA_SYSEX_STATE_WAIT_CHECKSUM
00367
00368 ;; wait for next byte
00369 rgoto TIA_SYSEX_SysExCheck_End
4F26 D727 M bra label
00370
4F28 00371 TIA_SYSEX_Action_PRESET_WriteChk
00372 ;; store received byte in checksum (using TIA_SYSEX_ADDRESS as store register)
4F28 C023 FFA9 00373 movff TIA_SYSEX_IN, EEADR
00374
00375 ;; wait for next byte
00376 rgoto TIA_SYSEX_SysExCheck_End
4F2C D724 M bra label
00377
4F2E 00378 TIA_SYSEX_End_PRESET_Write
00379 ;; action invalid if checksum has not been received
00380 BRA_IFCLR TIA_SYSEX_STATE, TIA_SYSEX_STATE_WAIT_CHECKSUM, ACCESS, TIA_SYSEX_ActionInvalid
4F2E A421 M btfss reg, bit, reg_a
4F30 D72D M bra label
00381
00382 ;; calc final checksum
4F32 5024 00383 movf TIA_SYSEX_CHECKSUM, W
4F34 0880 00384 sublw 0x80
4F36 0B7F 00385 andlw 0x7f
00386
00387 ;; compare with received checksum
4F38 18A9 00388 xorwf EEADR, W
00389
00390 ;; if not equal jump to ActionInvalid
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 157
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
4F3A A4D8 00391 skpz
00392 rgoto TIA_SYSEX_End_PRESET_Write_Reply_ChksumErr
4F3C D01F M bra label
00393
4F3E 5025 00394 movf TIA_SYSEX_ADDRESS, W
4F40 DA93 00395 rcall TIA_SYSEX_Hlp_GetAbsoluteBank
4F42 6E26 00396 movwf TIA_SYSEX_ERROR
4F44 E123 00397 bnz TIA_SYSEX_End_PRESET_Write_Reply
00398
4F46 5012 00399 movf TIA_PRESET, W
4F48 E00A 00400 bz TIA_SYSEX_End_PRESET_Write_Cont
4F4A 5011 00401 movf TIA_BANK, W
4F4C EC7E F01B 00402 call TIA_BANK_GetBankStickReady
4F50 B4D8 00403 skpnz
00404 rgoto TIA_SYSEX_End_PRESET_Write_Reply_NotReady
4F52 D017 M bra label
00405
4F54 EC8B F01B 00406 call TIA_BANK_GetBankStickSize
4F58 E102 00407 bnz TIA_SYSEX_End_PRESET_Write_Cont
00408
4F5A BC12 00409 btfsc TIA_PRESET, 6
00410 rgoto TIA_SYSEX_End_PRESET_Write_Reply_32k
4F5C D015 M bra label
00411
4F5E 00412 TIA_SYSEX_End_PRESET_Write_Cont
00413 ;; write buffer to EEPROM
4F5E EE17 F000 00414 lfsr FSR1, BANKSTICK_FORMAT_BEGIN ; init pointer to upload buffer
4F62 0E00 00415 movlw EEPROM_PATCH & 0xff
4F64 6EA9 00416 movwf EEADR
4F66 0E00 00417 movlw (EEPROM_PATCH >> 8) & 0xff
4F68 6EAA 00418 movwf EEADRH
00419
4F6A 00420 TIA_SYSEX_End_PRESET_WritePages
4F6A 0004 00421 clrwdt ; feed watchdog
4F6C EC24 F01B 00422 call TIA_BANK_WritePage ; write a 64 bytes page to EEPROM
00423 ;; increment FSR1 by 0x40
4F70 0E40 00424 movlw 0x40
4F72 26E1 00425 addwf FSR1L, F
4F74 0004 00426 clrwdt ; feed watchdog
4F76 EC24 F01B 00427 call TIA_BANK_WritePage ; write a 64 bytes page to EEPROM
00428 rgoto TIA_SYSEX_End_PRESET_Write_Reply
4F7A D008 M bra label
00429 ;; to do... bank num in command and set patch/kit/WT +init if BANK==xBANK/ PRESET==xPRESET
00430
4F7C 00431 TIA_SYSEX_End_PRESET_Write_Reply_ChksumErr
00432 ;; CheckSum Error #5
4F7C 0E05 00433 movlw 0x05
4F7E 6E26 00434 movwf TIA_SYSEX_ERROR
00435 rgoto TIA_SYSEX_End_PRESET_Write_Reply
4F80 D005 M bra label
00436
4F82 00437 TIA_SYSEX_End_PRESET_Write_Reply_NotReady
00438 ;; BS not ready Error #3
4F82 0E03 00439 movlw 0x03
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 158
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
4F84 6E26 00440 movwf TIA_SYSEX_ERROR
00441 rgoto TIA_SYSEX_End_PRESET_Write_Reply
4F86 D002 M bra label
00442
4F88 00443 TIA_SYSEX_End_PRESET_Write_Reply_32k
00444 ;; BS 32k 64 presets max Error #4
4F88 0E04 00445 movlw 0x04
4F8A 6E26 00446 movwf TIA_SYSEX_ERROR
00447 ;;rgoto TIA_SYSEX_End_PRESET_Write_Reply
00448
4F8C 00449 TIA_SYSEX_End_PRESET_Write_Reply
00450 ;; send SysEx header
4F8C DA1E 00451 rcall TIA_SYSEX_Send_SysExHeader
00452
00453 ;; Send PRESET_Write ID
4F8E 0E02 00454 movlw 0x02
4F90 EC24 F016 00455 call MIOS_MIDI_TxBufferPut
00456
00457 ;; send requested preset type number
4F94 DA85 00458 rcall TIA_SYSEX_Hlp_GetRelativeBank
4F96 0B7F 00459 andlw 0x7f
4F98 EC24 F016 00460 call MIOS_MIDI_TxBufferPut
00461
00462 ;; send requested bank number
4F9C 5011 00463 movf TIA_BANK, W
4F9E 0B1F 00464 andlw 0x1f
4FA0 EC24 F016 00465 call MIOS_MIDI_TxBufferPut
00466
00467 ;; send requested preset number
4FA4 5012 00468 movf TIA_PRESET, W
4FA6 0B7F 00469 andlw 0x7f
4FA8 EC24 F016 00470 call MIOS_MIDI_TxBufferPut
00471
00472 ;; send error status
4FAC 5026 00473 movf TIA_SYSEX_ERROR, W
4FAE 0B7F 00474 andlw 0x7f
4FB0 EC24 F016 00475 call MIOS_MIDI_TxBufferPut
00476
00477 ;; send of SysEx footer
4FB4 0E01 00478 movlw 0x01 ; (independend from merger state)
4FB6 DA1C 00479 rcall TIA_SYSEX_Send_SysExFooter
00480
00481 ;; finish Action
00482 rgoto TIA_SYSEX_ActionFinished
4FB8 D6E9 M bra label
00483
4FBA 00484 TIA_SYSEX_End_PRESET_Write_STR
00485 STRING 20, 0x00, "Patch A 1 uploaded "
4FBA 1400 6150 M da ((length) << 8) | (pos), str
6374 2068
2041 3120
7520 6C70
616F 6564
2064
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 159
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00486
00487 ;; --------------------------------------------------------------------------
00488 ;; MIDI Action: All Patch Read
00489 ;; --------------------------------------------------------------------------
4FD0 00490 TIA_SYSEX_Init_BANK_Read
00491 ;; disable TIA engine until end of transfer (will be requested by ActionFinished)
4FD0 8010 00492 bsf TIA_STAT, TIA_STAT_ENGINE_DISABLE
4FD2 EC50 F01E 00493 call TIA_TUNE_Note_Off
4FD6 0012 00494 return
00495
4FD8 00496 TIA_SYSEX_Action_BANK_Read
00497 ;; receive <type> <bank> F7
4FD8 00498 TIA_SYSEX_Action_BANK_Read_T
00499 BRA_IFSET TIA_SYSEX_STATE, TIA_SYSEX_STATE_TYPE_RECEIVED, ACCESS, TIA_SYSEX_Action_BANK_Read_B
4FD8 B621 M btfsc reg, bit, reg_a
4FDA D004 M bra label
4FDC 8621 00500 bsf TIA_SYSEX_STATE, TIA_SYSEX_STATE_TYPE_RECEIVED
4FDE C023 F025 00501 movff TIA_SYSEX_IN, TIA_SYSEX_ADDRESS ; load preset type
00502 rgoto TIA_SYSEX_SysExCheck_End ; wait for next byte
4FE2 D6C9 M bra label
00503
4FE4 00504 TIA_SYSEX_Action_BANK_Read_B
00505 BRA_IFSET TIA_SYSEX_STATE, TIA_SYSEX_STATE_BANK_RECEIVED, ACCESS, TIA_SYSEX_Action_BANK_ReadStall
4FE4 B821 M btfsc reg, bit, reg_a
4FE6 D004 M bra label
4FE8 8821 00506 bsf TIA_SYSEX_STATE, TIA_SYSEX_STATE_BANK_RECEIVED
4FEA C023 F011 00507 movff TIA_SYSEX_IN, TIA_BANK ; load bank
00508 rgoto TIA_SYSEX_SysExCheck_End ; wait for next byte
4FEE D6C3 M bra label
00509
4FF0 00510 TIA_SYSEX_Action_BANK_ReadStall
00511 ;; do nothing until sysex footer (F7) has been received
00512 rgoto TIA_SYSEX_SysExCheck_End
4FF0 D6C2 M bra label
00513
4FF2 00514 TIA_SYSEX_End_BANK_Read
00515 ;; action invalid if patch number has not been received
00516 BRA_IFCLR TIA_SYSEX_STATE, TIA_SYSEX_STATE_BANK_RECEIVED, ACCESS, TIA_SYSEX_ActionInvalid
4FF2 A821 M btfss reg, bit, reg_a
4FF4 D6CB M bra label
00517
4FF6 C011 F007 00518 movff TIA_BANK, TMP2 ;; store relative bank
4FFA 5025 00519 movf TIA_SYSEX_ADDRESS, W
4FFC DA35 00520 rcall TIA_SYSEX_Hlp_GetAbsoluteBank ; set bank to absolute
4FFE 6E26 00521 movwf TIA_SYSEX_ERROR
5000 E10A 00522 bnz TIA_SYSEX_End_BANK_Read_Cont
00523
5002 5012 00524 movf TIA_PRESET, W
5004 E008 00525 bz TIA_SYSEX_End_BANK_Read_Cont
5006 5011 00526 movf TIA_BANK, W
5008 EC7E F01B 00527 call TIA_BANK_GetBankStickReady
500C A4D8 00528 skpz
00529 rgoto TIA_SYSEX_End_BANK_Read_Cont
500E D003 M bra label
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 160
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00530 ;; BS not ready Error #3
5010 0E03 00531 movlw 0x03
5012 6E26 00532 movwf TIA_SYSEX_ERROR
00533 rgoto TIA_SYSEX_End_BANK_Read_Cont
5014 D000 M bra label
00534
5016 00535 TIA_SYSEX_End_BANK_Read_Cont
00536
00537 ;; send SysEx header
5016 D9D9 00538 rcall TIA_SYSEX_Send_SysExHeader
00539
00540 ;; send PTCHES_Write ID
5018 0E03 00541 movlw 0x03
501A EC24 F016 00542 call MIOS_MIDI_TxBufferPut
00543
00544 ;; send requested preset type number
501E 5025 00545 movf TIA_SYSEX_ADDRESS, W
5020 0B7F 00546 andlw 0x7f
5022 EC24 F016 00547 call MIOS_MIDI_TxBufferPut
00548
00549 ;; send requested bank number
5026 5007 00550 movf TMP2, W
5028 0B1F 00551 andlw 0x1f
502A EC24 F016 00552 call MIOS_MIDI_TxBufferPut
00553
00554 ;movf TIA_SYSEX_ADDRESS, W
00555 ;rcall TIA_SYSEX_Hlp_GetAbsoluteBank ; set bank to absolute
502E 5011 00556 movf TIA_BANK, W
5030 EC7E F01B 00557 call TIA_BANK_GetBankStickReady
00558 ;; send requested bank size
5034 EC8B F01B 00559 call TIA_BANK_GetBankStickSize
5038 EC24 F016 00560 call MIOS_MIDI_TxBufferPut
00561
503C 5026 00562 movf TIA_SYSEX_ERROR, W
503E E004 00563 bz TIA_SYSEX_End_BANK_Read_Cont_Ok
5040 0B7F 00564 andlw 0x7f
5042 EC24 F016 00565 call MIOS_MIDI_TxBufferPut
00566 rgoto TIA_SYSEX_End_BANK_Read_Footer
5046 D026 M bra label
00567
5048 00568 TIA_SYSEX_End_BANK_Read_Cont_Ok
00569
00570 ;; clear checksum
5048 6A24 00571 clrf TIA_SYSEX_CHECKSUM
00572
00573 #if 1
00574 ;; send bank informations
504A EC64 F01B 00575 call TIA_BANK_SetBankStickAddressMagic
504E 00576 TIA_SYSEX_End_BANK_Read_Cont_Name_Loop
504E ECB8 F016 00577 call MIOS_BANKSTICK_Read ; read content, inc MIOS_PARAMETER12
5052 6EF5 00578 movwf TABLAT ; store data in TABLAT
00579
5054 5003 00580 movf MIOS_PARAMETER1, W
5056 0BF0 00581 andlw 0xf0
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 161
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
5058 0A10 00582 xorlw 0x10
505A E104 00583 bnz TIA_SYSEX_End_BANK_Read_Cont_Name_Jump
505C 0E20 00584 movlw 0x20
505E 60F5 00585 cpfslt TABLAT, ACCESS ; ensure that patch name doesn't contain characters < 0x20
00586 rgoto TIA_SYSEX_End_BANK_Read_Cont_Name_Jump
5060 D001 M bra label
5062 6EF5 00587 movwf TABLAT
5064 00588 TIA_SYSEX_End_BANK_Read_Cont_Name_Jump
5064 50F5 00589 movf TABLAT, W
5066 0B7F 00590 andlw 0x7f
5068 2624 00591 addwf TIA_SYSEX_CHECKSUM, F
506A EC24 F016 00592 call MIOS_MIDI_TxBufferPut
506E AE03 00593 btfss MIOS_PARAMETER1, 7 ; until == 0x20 send 16 bytes
00594 rgoto TIA_SYSEX_End_BANK_Read_Cont_Name_Loop
5070 D7EE M bra label
00595
00596 ;; 127 patches to send(1-127), TIA_PRESET used as counter
5072 0E01 00597 movlw 0x01
5074 6E12 00598 movwf TIA_PRESET
00599 #else
00600
00601 ;; 128 patches to send, TIA_PRESET used as counter
00602 clrf TIA_PRESET
00603 #endif
00604
5076 00605 TIA_SYSEX_End_BANK_Read_OL ; outer loop
5076 0004 00606 clrwdt ; feed the watchdog
5078 D9C6 00607 rcall TIA_SYSEX_Hlp_SendPreset ; send 128 bytes
00608
507A 2A12 00609 incf TIA_PRESET, F ; loop 64/128 times depends on BS Size
507C EC8B F01B 00610 call TIA_BANK_GetBankStickSize
5080 0E7F 00611 movlw 128-1
5082 B4D8 00612 skpnz
5084 0E3F 00613 movlw 64-1
5086 6412 00614 cpfsgt TIA_PRESET, ACCESS
00615 rgoto TIA_SYSEX_End_BANK_Read_OL
5088 D7F6 M bra label
00616
00617 ;; send checksum
508A 5024 00618 movf TIA_SYSEX_CHECKSUM, W
508C 0880 00619 sublw 0x80
508E 0B7F 00620 andlw 0x7f
5090 EC24 F016 00621 call MIOS_MIDI_TxBufferPut
00622
5094 00623 TIA_SYSEX_End_BANK_Read_Footer
00624 ;; send of SysEx footer
5094 0E01 00625 movlw 0x01 ; (independend from merger state)
5096 D9AC 00626 rcall TIA_SYSEX_Send_SysExFooter
00627
00628 ;; finish Action
00629 rgoto TIA_SYSEX_ActionFinished
5098 D679 M bra label
00630
00631
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 162
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00632 ;; --------------------------------------------------------------------------
00633 ;; MIDI Action: Bank Write Name
00634 ;; --------------------------------------------------------------------------
509A 00635 TIA_SYSEX_Init_BANK_WriteName
00636 ;; disable TIA engine until end of transfer (will be requested by ActionFinished)
00637 ;;bsf TIA_STAT, TIA_STAT_ENGINE_DISABLE
509A 0012 00638 return
00639
509C 00640 TIA_SYSEX_Action_BANK_WriteName
00641 ;; receive <type> <bank> <16 bytes> F7
509C 00642 TIA_SYSEX_Action_BANK_WriteNameT
00643 BRA_IFSET TIA_SYSEX_STATE, TIA_SYSEX_STATE_TYPE_RECEIVED, ACCESS, TIA_SYSEX_Action_BANK_WriteNameB
509C B621 M btfsc reg, bit, reg_a
509E D004 M bra label
50A0 8621 00644 bsf TIA_SYSEX_STATE, TIA_SYSEX_STATE_TYPE_RECEIVED
50A2 C023 F025 00645 movff TIA_SYSEX_IN, TIA_SYSEX_ADDRESS ; load preset type
00646 rgoto TIA_SYSEX_SysExCheck_End ; wait for next byte
50A6 D667 M bra label
00647
50A8 00648 TIA_SYSEX_Action_BANK_WriteNameB
00649 BRA_IFSET TIA_SYSEX_STATE, TIA_SYSEX_STATE_BANK_RECEIVED, ACCESS, TIA_SYSEX_Action_BANK_WriteNameC
50A8 B821 M btfsc reg, bit, reg_a
50AA D006 M bra label
50AC 8821 00650 bsf TIA_SYSEX_STATE, TIA_SYSEX_STATE_BANK_RECEIVED
50AE C023 F011 00651 movff TIA_SYSEX_IN, TIA_BANK ; load bank
00652
50B2 6AA9 00653 clrf EEADR ; clear address
50B4 6A26 00654 clrf TIA_SYSEX_ERROR ; clear reply error
00655 rgoto TIA_SYSEX_SysExCheck_End ; wait for next byt
50B6 D65F M bra label
00656
50B8 00657 TIA_SYSEX_Action_BANK_WriteNameC
50B8 EE07 F000 00658 lfsr FSR0, BANKSTICK_FORMAT_BEGIN ; init pointer to upload buffer
50BC CFA9 FFE9 00659 movff EEADR, FSR0L
00660
00661 ;; store received byte in upload buffer
50C0 5023 00662 movf TIA_SYSEX_IN, W
50C2 6EEF 00663 movwf INDF0
00664
00665 ;; increment address
50C4 2AA9 00666 incf EEADR, F
00667
00668 ;; if FSR0L is zero, go into WAIT_CHECKSUM state
50C6 0E10 00669 movlw 0x10
50C8 60A9 00670 cpfslt EEADR, ACCESS
50CA 8A21 00671 bsf TIA_SYSEX_STATE, TIA_SYSEX_STATE_PRESET_RECEIVED
00672
00673 ;; wait for next byte
00674 rgoto TIA_SYSEX_SysExCheck_End
50CC D654 M bra label
00675
50CE 00676 TIA_SYSEX_End_BANK_WriteName
00677 ;; action invalid if checksum has not been received
00678 BRA_IFCLR TIA_SYSEX_STATE, TIA_SYSEX_STATE_PRESET_RECEIVED, ACCESS, TIA_SYSEX_ActionInvalid
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 163
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
50CE AA21 M btfss reg, bit, reg_a
50D0 D65D M bra label
00679
50D2 5025 00680 movf TIA_SYSEX_ADDRESS, W
50D4 D9C9 00681 rcall TIA_SYSEX_Hlp_GetAbsoluteBank
50D6 6E26 00682 movwf TIA_SYSEX_ERROR
50D8 E11D 00683 bnz TIA_SYSEX_End_BANK_WriteName_Reply
00684
50DA 5011 00685 movf TIA_BANK, W
50DC EC7E F01B 00686 call TIA_BANK_GetBankStickReady
50E0 B4D8 00687 skpnz
00688 rgoto TIA_SYSEX_End_BANK_WriteName_Reply_NotReady
50E2 D015 M bra label
00689
50E4 00690 TIA_SYSEX_End_BANK_WriteName_Cont
50E4 EE17 F000 00691 lfsr FSR1, BANKSTICK_FORMAT_BEGIN ; init pointer to upload buffer
00692 ;; add name offset to MP1 start @0x10
50E8 EC64 F01B 00693 call TIA_BANK_SetBankStickAddressMagic
50EC 0E10 00694 movlw 0x10
50EE 2603 00695 addwf MIOS_PARAMETER1, F
00696
50F0 00697 TIA_SYSEX_End_BANK_WriteName_Loop
50F0 0004 00698 clrwdt ; feed watchdog
50F2 0E20 00699 movlw 0x20
50F4 61E7 00700 cpfslt INDF1, BANKED ; ensure that patch name doesn't contain characters < 0x20
50F6 6EE7 00701 movwf INDF1
50F8 00702 TIA_SYSEX_End_BANK_WriteName_Loop_Jump
50F8 50E6 00703 movf POSTINC1, W
50FA ECBA F016 00704 call MIOS_BANKSTICK_Write ; write byte to EEPROM
50FE E104 00705 bnz TIA_SYSEX_End_BANK_WriteName_Reply_WError
00706
00707 ;; if FSR0L is zero, go into WAIT_CHECKSUM state
5100 0E20 00708 movlw 0x20
5102 6003 00709 cpfslt MIOS_PARAMETER1, ACCESS
00710 rgoto TIA_SYSEX_End_BANK_WriteName_Reply
5104 D007 M bra label
00711 rgoto TIA_SYSEX_End_BANK_WriteName_Loop
5106 D7F4 M bra label
00712
5108 00713 TIA_SYSEX_End_BANK_WriteName_Reply_WError
00714 ;; BS write byte Error #8
5108 0E08 00715 movlw 0x08
510A 6E26 00716 movwf TIA_SYSEX_ERROR
00717 rgoto TIA_SYSEX_End_BANK_WriteName_Reply
510C D003 M bra label
00718
510E 00719 TIA_SYSEX_End_BANK_WriteName_Reply_NotReady
00720 ;; BS not ready Error #3
510E 0E03 00721 movlw 0x03
5110 6E26 00722 movwf TIA_SYSEX_ERROR
00723 rgoto TIA_SYSEX_End_BANK_WriteName_Reply
5112 D000 M bra label
00724
5114 00725 TIA_SYSEX_End_BANK_WriteName_Reply
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 164
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00726 ;; send SysEx header
5114 D95A 00727 rcall TIA_SYSEX_Send_SysExHeader
00728
00729 ;; Send PRESET_WriteName ID
5116 0E04 00730 movlw 0x04
5118 EC24 F016 00731 call MIOS_MIDI_TxBufferPut
00732
00733 ;; send requested preset type number
511C D9C1 00734 rcall TIA_SYSEX_Hlp_GetRelativeBank
511E 0B7F 00735 andlw 0x7f
5120 EC24 F016 00736 call MIOS_MIDI_TxBufferPut
00737
00738 ;; send requested bank number
5124 5011 00739 movf TIA_BANK, W
5126 0B1F 00740 andlw 0x1f
5128 EC24 F016 00741 call MIOS_MIDI_TxBufferPut
00742
00743 ;; send error status
512C 5026 00744 movf TIA_SYSEX_ERROR, W
512E 0B7F 00745 andlw 0x7f
5130 EC24 F016 00746 call MIOS_MIDI_TxBufferPut
00747
00748 ;; send of SysEx footer
5134 0E01 00749 movlw 0x01 ; (independend from merger state)
5136 D95C 00750 rcall TIA_SYSEX_Send_SysExFooter
00751
00752 ;; finish Action
00753 rgoto TIA_SYSEX_ActionFinished
5138 D629 M bra label
00754
00755 ;; --------------------------------------------------------------------------
00756 ;; MIDI Action: Parameter Read
00757 ;; --------------------------------------------------------------------------
513A 00758 TIA_SYSEX_Init_PAR_Read
513A 0012 00759 return
00760
513C 00761 TIA_SYSEX_Action_PAR_Read
00762 ;; receive <AH> <AL> F7
513C 00763 TIA_SYSEX_Action_PAR_ReadAH
00764 BRA_IFSET TIA_SYSEX_STATE, TIA_SYSEX_STATE_AH_RECEIVED, ACCESS, TIA_SYSEX_Action_PAR_ReadAL
513C BA21 M btfsc reg, bit, reg_a
513E D005 M bra label
5140 8A21 00765 bsf TIA_SYSEX_STATE, TIA_SYSEX_STATE_AH_RECEIVED
5142 6A25 00766 clrf TIA_SYSEX_ADDRESS ; clear register and set TIA_SYSEX_ADDRESS[7] if IN[0] is set
5144 B023 00767 btfsc TIA_SYSEX_IN, 0
5146 8E25 00768 bsf TIA_SYSEX_ADDRESS, 7
00769 rgoto TIA_SYSEX_SysExCheck_End ; wait for next byte
5148 D616 M bra label
00770
514A 00771 TIA_SYSEX_Action_PAR_ReadAL
00772 BRA_IFSET TIA_SYSEX_STATE, TIA_SYSEX_STATE_AL_RECEIVED, ACCESS, TIA_SYSEX_Action_PAR_ReadStall
514A B821 M btfsc reg, bit, reg_a
514C D005 M bra label
514E 8821 00773 bsf TIA_SYSEX_STATE, TIA_SYSEX_STATE_AL_RECEIVED
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 165
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
5150 5023 00774 movf TIA_SYSEX_IN, W ; OR TIA_SYSEX_ADDRESS with low-byte
5152 0B7F 00775 andlw 0x7f
5154 1225 00776 iorwf TIA_SYSEX_ADDRESS, F
00777 rgoto TIA_SYSEX_SysExCheck_End ; wait for next byte
5156 D60F M bra label
00778
5158 00779 TIA_SYSEX_Action_PAR_ReadStall
00780 ;; do nothing until sysex footer (F7) has been received
00781 rgoto TIA_SYSEX_SysExCheck_End
5158 D60E M bra label
00782
515A 00783 TIA_SYSEX_End_PAR_Read
00784 ;; action invalid if low-byte of address has not been received
00785 BRA_IFCLR TIA_SYSEX_STATE, TIA_SYSEX_STATE_AL_RECEIVED, ACCESS, TIA_SYSEX_ActionInvalid
515A A821 M btfss reg, bit, reg_a
515C D617 M bra label
00786
00787 ;; send SysEx header
515E D935 00788 rcall TIA_SYSEX_Send_SysExHeader
00789
00790 ;; send PAR_Write ID
5160 0E06 00791 movlw 0x06
5162 EC24 F016 00792 call MIOS_MIDI_TxBufferPut
00793
00794 ;; send AH
5166 0E00 00795 movlw 0x00
5168 BE25 00796 btfsc TIA_SYSEX_ADDRESS, 7
516A 0E01 00797 movlw 0x01
516C EC24 F016 00798 call MIOS_MIDI_TxBufferPut
00799
00800 ;; send AL
5170 5025 00801 movf TIA_SYSEX_ADDRESS, W
5172 0B7F 00802 andlw 0x7f
5174 EC24 F016 00803 call MIOS_MIDI_TxBufferPut
00804
00805 ;; get corresponding CC parameter from address
5178 5025 00806 movf TIA_SYSEX_ADDRESS, W
517A ECF5 F02C 00807 call TIA_SYSEX_TABLE_Get
00808
00809 ;; branch if EEPROM value should be sent
00810 BRA_IFSET WREG, 7, ACCESS, TIA_SYSEX_Action_PAR_Read_EE
517E BEE8 M btfsc reg, bit, reg_a
5180 D003 M bra label
00811
5182 00812 TIA_SYSEX_Action_PAR_Read_RAM
00813 ;; get CC value from RAM
5182 EC20 F02C 00814 call TIA_CCOUT_Get
00815 rgoto TIA_SYSEX_Action_PAR_Read_Cont
5186 D004 M bra label
5188 00816 TIA_SYSEX_Action_PAR_Read_EE
00817 ;; read value from EEPROM
5188 C025 FFA9 00818 movff TIA_SYSEX_ADDRESS, EEADR
518C EC51 F01B 00819 call TIA_BANK_Read
5190 00820 TIA_SYSEX_Action_PAR_Read_Cont
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 166
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00821 ;; send value
5190 0B7F 00822 andlw 0x7f
5192 EC24 F016 00823 call MIOS_MIDI_TxBufferPut
00824
00825 ;; send of SysEx footer
5196 0E01 00826 movlw 0x01 ; (independend from merger state)
5198 D92B 00827 rcall TIA_SYSEX_Send_SysExFooter
00828
00829 ;; finish Action
00830 rgoto TIA_SYSEX_ActionFinished
519A D5F8 M bra label
00831
00832 ;; --------------------------------------------------------------------------
00833 ;; MIDI Action: Parameter Write
00834 ;; --------------------------------------------------------------------------
519C 00835 TIA_SYSEX_Init_PAR_Write
519C 0012 00836 return
00837
519E 00838 TIA_SYSEX_Action_PAR_Write
00839 ;; receive <AH> <AL> <value> F7
519E 00840 TIA_SYSEX_Action_PAR_WriteAH
00841 BRA_IFSET TIA_SYSEX_STATE, TIA_SYSEX_STATE_AH_RECEIVED, ACCESS, TIA_SYSEX_Action_PAR_WriteAL
519E BA21 M btfsc reg, bit, reg_a
51A0 D005 M bra label
51A2 8A21 00842 bsf TIA_SYSEX_STATE, TIA_SYSEX_STATE_AH_RECEIVED
51A4 6A25 00843 clrf TIA_SYSEX_ADDRESS ; clear register and set TIA_SYSEX_ADDRESS[7] if IN[0] is set
51A6 B023 00844 btfsc TIA_SYSEX_IN, 0
51A8 8E25 00845 bsf TIA_SYSEX_ADDRESS, 7
00846 rgoto TIA_SYSEX_SysExCheck_End ; wait for next byte
51AA D5E5 M bra label
00847
51AC 00848 TIA_SYSEX_Action_PAR_WriteAL
00849 BRA_IFSET TIA_SYSEX_STATE, TIA_SYSEX_STATE_AL_RECEIVED, ACCESS, TIA_SYSEX_Action_PAR_WriteD
51AC B821 M btfsc reg, bit, reg_a
51AE D005 M bra label
51B0 8821 00850 bsf TIA_SYSEX_STATE, TIA_SYSEX_STATE_AL_RECEIVED
51B2 5023 00851 movf TIA_SYSEX_IN, W ; OR TIA_SYSEX_ADDRESS with low-byte
51B4 0B7F 00852 andlw 0x7f
51B6 1225 00853 iorwf TIA_SYSEX_ADDRESS, F
00854 rgoto TIA_SYSEX_SysExCheck_End ; wait for next byte
51B8 D5DE M bra label
00855
51BA 00856 TIA_SYSEX_Action_PAR_WriteD
00857 BRA_IFSET TIA_SYSEX_STATE, TIA_SYSEX_STATE_D_RECEIVED, ACCESS, TIA_SYSEX_Action_PAR_WriteStall
51BA B621 M btfsc reg, bit, reg_a
51BC D004 M bra label
51BE 8621 00858 bsf TIA_SYSEX_STATE, TIA_SYSEX_STATE_D_RECEIVED
51C0 C023 F024 00859 movff TIA_SYSEX_IN, TIA_SYSEX_CHECKSUM; store byte in TIA_SYSEX_CHECKSUM (used as write buffer here)
00860 rgoto TIA_SYSEX_SysExCheck_End ; wait for next byte
51C4 D5D8 M bra label
00861
51C6 00862 TIA_SYSEX_Action_PAR_WriteStall
00863 ;; do nothing until sysex footer (F7) has been received
00864 rgoto TIA_SYSEX_SysExCheck_End
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 167
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
51C6 D5D7 M bra label
00865
51C8 00866 TIA_SYSEX_End_PAR_Write
00867 ;; action invalid if data has not been received
00868 BRA_IFCLR TIA_SYSEX_STATE, TIA_SYSEX_STATE_D_RECEIVED, ACCESS, TIA_SYSEX_ActionInvalid
51C8 A621 M btfss reg, bit, reg_a
51CA D5E0 M bra label
00869
00870 ;; get corresponding CC parameter from address
51CC 5025 00871 movf TIA_SYSEX_ADDRESS, W
51CE ECF5 F02C 00872 call TIA_SYSEX_TABLE_Get
51D2 6E06 00873 movwf TMP1
00874
00875 ;; branch if value should be saved in EEPROM
00876 BRA_IFSET TMP1, 7, ACCESS, TIA_SYSEX_Action_PAR_Write_EE
51D4 BE06 M btfsc reg, bit, reg_a
51D6 D005 M bra label
00877
51D8 00878 TIA_SYSEX_Action_PAR_Write_RAM
00879 ;; write CC value to RAM
51D8 C024 F003 00880 movff TIA_SYSEX_CHECKSUM, MIOS_PARAMETER1 ; byte has been stored in _CHECKSUM
51DC EC67 F02A 00881 call TIA_CCIN_Set
00882 rgoto TIA_SYSEX_Action_PAR_Write_Cont
51E0 D00F M bra label
51E2 00883 TIA_SYSEX_Action_PAR_Write_EE
00884 ;; if split parameter, redirect to TIA_Vx_SPLIT_xxx
51E2 5006 00885 movf TMP1, W
51E4 0BF0 00886 andlw 0xf0
51E6 0A90 00887 xorlw 0x90
51E8 E106 00888 bnz TIA_SYSEX_Action_PAR_Write_EEC
51EA 00889 TIA_SYSEX_Action_PAR_Write_EES
51EA 5006 00890 movf TMP1, W
51EC ECFA F01A 00891 call TIA_PATCH_GetSplitPointer
51F0 C024 FFE3 00892 movff TIA_SYSEX_CHECKSUM, PLUSW1
00893 rgoto TIA_SYSEX_Action_PAR_Write_Cont
51F4 D005 M bra label
00894
51F6 00895 TIA_SYSEX_Action_PAR_Write_EEC
00896 ;; write value to EEPROM
51F6 C025 FFA9 00897 movff TIA_SYSEX_ADDRESS, EEADR
51FA 5024 00898 movf TIA_SYSEX_CHECKSUM, W; byte has been stored in _CHECKSUM
51FC EC05 F01B 00899 call TIA_BANK_Write
5200 00900 TIA_SYSEX_Action_PAR_Write_Cont
00901
00902 ;; send acknowledge
5200 ECDF F029 00903 call TIA_SYSEX_Send_Acknowledge
00904
00905 ;; finish Action
00906 rgoto TIA_SYSEX_ActionFinished
5204 D5C3 M bra label
00907
00908 ;; --------------------------------------------------------------------------
00909 ;; MIDI Action: Switch Bank
00910 ;; --------------------------------------------------------------------------
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 168
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
5206 00911 TIA_SYSEX_Init_BANK_Sel
5206 6A25 00912 clrf TIA_SYSEX_ADDRESS
5208 0012 00913 return
00914
520A 00915 TIA_SYSEX_Action_BANK_Sel
00916 ;; store bank in TIA_SYSEX_ADDRESS
520A C023 F025 00917 movff TIA_SYSEX_IN, TIA_SYSEX_ADDRESS
00918 rgoto TIA_SYSEX_SysExCheck_End ; wait for next byte
520E D5B3 M bra label
00919
5210 00920 TIA_SYSEX_End_BANK_Sel
00921 ;; check if BankStick available
5210 0E0F 00922 movlw 0x0f
5212 6025 00923 cpfslt TIA_SYSEX_ADDRESS, ACCESS
00924 rgoto TIA_SYSEX_End_BANK_SelInv
5214 D008 M bra label
5216 5025 00925 movf TIA_SYSEX_ADDRESS, W
5218 ECC6 F016 00926 call MIOS_HLP_GetBitORMask
521C 141C 00927 andwf TIA_BANKSTICK_STAT, W
521E E003 00928 bz TIA_SYSEX_End_BANK_SelInv
00929
00930 ;; change to bank immediately
5220 C025 F014 00931 movff TIA_SYSEX_ADDRESS, TIA_PBANK
5224 D8EF 00932 rcall TIA_SYSEX_ChangeMPatch
00933
00934 ;; rgoto TIA_SYSEX_End_BANK_Cont
00935
00936 ;; don't select new bankstick
5226 00937 TIA_SYSEX_End_BANK_SelInv
00938
5226 00939 TIA_SYSEX_End_BANK_Cont
00940 ;; send acknowledge with bank number
5226 D8D1 00941 rcall TIA_SYSEX_Send_SysExHeader
00942
5228 0E0F 00943 movlw 0x0f ; (acknowledge ID)
522A EC24 F016 00944 call MIOS_MIDI_TxBufferPut
00945
522E 5014 00946 movf TIA_PBANK, W
5230 EC24 F016 00947 call MIOS_MIDI_TxBufferPut
00948
00949 ;; send of SysEx footer
5234 0E01 00950 movlw 0x01 ; (independend from merger state)
5236 D8DC 00951 rcall TIA_SYSEX_Send_SysExFooter
00952
00953 ;; finish Action
00954 rgoto TIA_SYSEX_ActionFinished
5238 D5A9 M bra label
00955
00956 ;; --------------------------------------------------------------------------
00957 ;; MIDI Action: Configuration Write
00958 ;; --------------------------------------------------------------------------
523A 00959 TIA_SYSEX_Init_CFG_Read
523A 0012 00960 return
523C 00961 TIA_SYSEX_Action_CFG_Read
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 169
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00962 ;; send <A> <DH> <DL> F7
523C 00963 TIA_SYSEX_Action_CFG_ReadA
00964 BRA_IFSET TIA_SYSEX_STATE, TIA_SYSEX_STATE_A_RECEIVED, ACCESS, TIA_SYSEX_Action_CFG_ReadStall
523C BA21 M btfsc reg, bit, reg_a
523E D004 M bra label
5240 8A21 00965 bsf TIA_SYSEX_STATE, TIA_SYSEX_STATE_A_RECEIVED
5242 C023 F025 00966 movff TIA_SYSEX_IN, TIA_SYSEX_ADDRESS ; store address in TIA_SYSEX_ADDRESS
00967 rgoto TIA_SYSEX_SysExCheck_End ; wait for next byte
5246 D597 M bra label
00968
5248 00969 TIA_SYSEX_Action_CFG_ReadStall
00970 ;; do nothing until sysex footer (F7) has been received
00971 rgoto TIA_SYSEX_SysExCheck_End
5248 D596 M bra label
00972
524A 00973 TIA_SYSEX_End_CFG_Read
00974 ;; action invalid if low-byte of address has not been received
00975 BRA_IFCLR TIA_SYSEX_STATE, TIA_SYSEX_STATE_A_RECEIVED, ACCESS, TIA_SYSEX_ActionInvalid
524A AA21 M btfss reg, bit, reg_a
524C D59F M bra label
524E 00976 _TIA_SYSEX_End_CFG_Read
00977 ;; send SysEx header
524E D8BD 00978 rcall TIA_SYSEX_Send_SysExHeader
00979
00980 ;; send CFG_Read ID
5250 0E0C 00981 movlw 0x0c
5252 EC24 F016 00982 call MIOS_MIDI_TxBufferPut
00983
00984 ;; send A
5256 5025 00985 movf TIA_SYSEX_ADDRESS, W
5258 EC24 F016 00986 call MIOS_MIDI_TxBufferPut
00987
00988 ;; branch depending on current action ID
525C 5025 00989 movf TIA_SYSEX_ADDRESS, W
00990 JUMPTABLE_2BYTES 16 ; 16 entries
525E 0FF0 M addlw -(max_value) ; ensure that jump index is not greater than (max_value-1)
5260 B0D8 M skpnc
5262 0EF0 M movlw -(max_value)
5264 0F10 M addlw max_value
5266 ECC8 F016 M call MIOS_HLP_GetIndex_2bytes
00991 rgoto TIA_SYSEX_End_CFG_Read_EEPROM
526A D00F M bra label
00992 rgoto TIA_SYSEX_End_CFG_Read_EEPROM
526C D00E M bra label
00993 rgoto TIA_SYSEX_End_CFG_Read_EEPROM
526E D00D M bra label
00994 rgoto TIA_SYSEX_End_CFG_Read_Bank
5270 D01D M bra label
00995 rgoto TIA_SYSEX_End_CFG_Read_Patch
5272 D02F M bra label
00996 rgoto TIA_SYSEX_End_CFG_Read_BSInfo
5274 D052 M bra label
00997 rgoto TIA_SYSEX_End_CFG_Read_All
5276 D031 M bra label
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 170
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00998 rgoto TIA_SYSEX_End_CFG_Read_All
5278 D030 M bra label
00999 rgoto TIA_SYSEX_End_CFG_Read_All
527A D02F M bra label
01000 rgoto TIA_SYSEX_End_CFG_Read_All
527C D02E M bra label
01001 rgoto TIA_SYSEX_End_CFG_Read_All
527E D02D M bra label
01002 rgoto TIA_SYSEX_End_CFG_Read_All
5280 D02C M bra label
01003 rgoto TIA_SYSEX_End_CFG_Read_All
5282 D02B M bra label
01004 rgoto TIA_SYSEX_End_CFG_Read_All
5284 D02A M bra label
01005 rgoto TIA_SYSEX_End_CFG_Read_All
5286 D029 M bra label
01006 rgoto TIA_SYSEX_End_CFG_Read_All
5288 D028 M bra label
01007
01008
01009 ;BRA_IFSET TIA_SYSEX_ADDRESS, 2, ACCESS, TIA_SYSEX_End_CFG_Read_All
01010
528A 01011 TIA_SYSEX_End_CFG_Read_EEPROM
01012 ;; calc resulting EEADR
528A 5025 01013 movf TIA_SYSEX_ADDRESS, W
528C 0B03 01014 andlw 0x03
528E 0F7C 01015 addlw EEPROM_CFG_BASE & 0xff
5290 6EA9 01016 movwf EEADR
01017
01018 ;; read value from EEPROM
5292 ECB0 F016 01019 call MIOS_EEPROM_Read
5296 6E24 01020 movwf TIA_SYSEX_CHECKSUM ; (value is stored in TIA_SYSEX_CHECKSUM)
01021
01022 ;; send DH
5298 0E00 01023 movlw 0x00
529A BE24 01024 btfsc TIA_SYSEX_CHECKSUM, 7
529C 0E01 01025 movlw 0x01
529E EC24 F016 01026 call MIOS_MIDI_TxBufferPut
01027
01028 ;; send DL
52A2 5024 01029 movf TIA_SYSEX_CHECKSUM, W
52A4 0B7F 01030 andlw 0x7f
52A6 EC24 F016 01031 call MIOS_MIDI_TxBufferPut
01032 rgoto TIA_SYSEX_End_CFG_Read_Cont
52AA D04C M bra label
01033
52AC 01034 TIA_SYSEX_End_CFG_Read_Bank
01035 ;; send current bank number
52AC 5014 01036 movf TIA_PBANK, W
52AE EC24 F016 01037 call MIOS_MIDI_TxBufferPut
01038
01039 #if 0
01040 ;; send bank type
01041 call TIA_BANK_SetBankStickAddressMagic
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 171
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
01042 incf MIOS_PARAMETER1, F
01043 call MIOS_BANKSTICK_Read
01044 movwf TIA_SYSEX_CHECKSUM
01045 movlw BANKSTICK_MAGIC1
01046 subwf TIA_SYSEX_CHECKSUM, W
01047 andlw 0x7f
01048 call MIOS_MIDI_TxBufferPut
01049 #endif
01050
01051 ;; send bank name
52B2 EC64 F01B 01052 call TIA_BANK_SetBankStickAddressMagic
52B6 0E10 01053 movlw 0x10
52B8 2603 01054 addwf MIOS_PARAMETER1, F
52BA 01055 TIA_SYSEX_End_CFG_Read_Bank_NameLoop
52BA ECB8 F016 01056 call MIOS_BANKSTICK_Read
52BE 6E24 01057 movwf TIA_SYSEX_CHECKSUM
52C0 0E20 01058 movlw 0x20
52C2 6024 01059 cpfslt TIA_SYSEX_CHECKSUM
52C4 5024 01060 movf TIA_SYSEX_CHECKSUM, W
52C6 0B7F 01061 andlw 0x7f
52C8 EC24 F016 01062 call MIOS_MIDI_TxBufferPut
52CC AA03 01063 btfss MIOS_PARAMETER1, 5
01064 rgoto TIA_SYSEX_End_CFG_Read_Bank_NameLoop
52CE D7F5 M bra label
01065 rgoto TIA_SYSEX_End_CFG_Read_Cont
52D0 D039 M bra label
01066
52D2 01067 TIA_SYSEX_End_CFG_Read_Patch
01068 ;; send current patch number
52D2 5013 01069 movf TIA_PATCH, W
52D4 EC24 F016 01070 call MIOS_MIDI_TxBufferPut
01071 rgoto TIA_SYSEX_End_CFG_Read_Cont
52D8 D035 M bra label
01072
01073
52DA 01074 TIA_SYSEX_End_CFG_Read_All
01075 ;; calc resulting EEADR
52DA 0E7C 01076 movlw EEPROM_CFG_BASE & 0xff
52DC 6EA9 01077 movwf EEADR
01078
01079 ;; read value from EEPROM
52DE ECB0 F016 01080 call MIOS_EEPROM_Read
52E2 6E24 01081 movwf TIA_SYSEX_CHECKSUM ; (v2 ch is stored in TIA_SYSEX_CHECKSUM)
01082
01083 ;; send v2 ch
52E4 5024 01084 movf TIA_SYSEX_CHECKSUM, W
52E6 EC24 F016 01085 call MIOS_MIDI_TxBufferPut
01086
01087 ;; read value from EEPROM
52EA ECB0 F016 01088 call MIOS_EEPROM_Read
52EE 6E24 01089 movwf TIA_SYSEX_CHECKSUM ; (v1 ch is stored in TIA_SYSEX_CHECKSUM)
01090
01091 ;; send v1 ch
52F0 5024 01092 movf TIA_SYSEX_CHECKSUM, W
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 172
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
52F2 EC24 F016 01093 call MIOS_MIDI_TxBufferPut
01094
01095 ;; read value from EEPROM
52F6 ECB0 F016 01096 call MIOS_EEPROM_Read
52FA 6E24 01097 movwf TIA_SYSEX_CHECKSUM ; (v1 ch is stored in TIA_SYSEX_CHECKSUM)
01098
01099 ;; send DH/DL (device ID)
52FC 0E00 01100 movlw 0x00
52FE BE24 01101 btfsc TIA_SYSEX_CHECKSUM, 7
5300 0E01 01102 movlw 0x01
5302 EC24 F016 01103 call MIOS_MIDI_TxBufferPut
5306 5024 01104 movf TIA_SYSEX_CHECKSUM, W
5308 0B7F 01105 andlw 0x7f
530A EC24 F016 01106 call MIOS_MIDI_TxBufferPut
01107
01108 ;; send current bank number
530E 5014 01109 movf TIA_PBANK, W
5310 EC24 F016 01110 call MIOS_MIDI_TxBufferPut
01111
01112 ;; send current patch number
5314 5013 01113 movf TIA_PATCH, W
5316 EC24 F016 01114 call MIOS_MIDI_TxBufferPut
01115
01116
531A 01117 TIA_SYSEX_End_CFG_Read_BSInfo
01118 ;; send DH/DL (bank status)
531A 0E00 01119 movlw 0x00
531C BE1B 01120 btfsc TIA_BANKSTICK_RDY, 7
531E 0E01 01121 movlw 0x01
5320 EC24 F016 01122 call MIOS_MIDI_TxBufferPut
5324 501B 01123 movf TIA_BANKSTICK_RDY, W
5326 0B7F 01124 andlw 0x7f
5328 EC24 F016 01125 call MIOS_MIDI_TxBufferPut
01126
01127 ;; send DH/DL (bank size)
532C 0E00 01128 movlw 0x00
532E BE1D 01129 btfsc TIA_BANKSTICK_SIZE, 7
5330 0E01 01130 movlw 0x01
5332 EC24 F016 01131 call MIOS_MIDI_TxBufferPut
5336 501D 01132 movf TIA_BANKSTICK_SIZE, W
5338 0B7F 01133 andlw 0x7f
533A EC24 F016 01134 call MIOS_MIDI_TxBufferPut
01135
01136 ;; send Kit/WT start Id
533E 0E05 01137 movlw DEFAULT_BS_KBANK_ID
5340 EC24 F016 01138 call MIOS_MIDI_TxBufferPut
01139
01140
5344 01141 TIA_SYSEX_End_CFG_Read_Cont
01142 ;; send of SysEx footer
5344 0E01 01143 movlw 0x01 ; (independend from merger state)
5346 D854 01144 rcall TIA_SYSEX_Send_SysExFooter
01145
01146 ;; finish Action
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 173
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
01147 rgoto TIA_SYSEX_ActionFinished
5348 D521 M bra label
01148
01149 ;; --------------------------------------------------------------------------
01150 ;; MIDI Action: Configuration Write
01151 ;; --------------------------------------------------------------------------
534A 01152 TIA_SYSEX_Init_CFG_Write
01153 ;; disable TIA engine until end of transfer (will be requested by ActionFinished)
534A 8010 01154 bsf TIA_STAT, TIA_STAT_ENGINE_DISABLE
534C 0012 01155 return
01156
534E 01157 TIA_SYSEX_Action_CFG_Write
01158 ;; receive <A> <DH> <DL> F7
534E 01159 TIA_SYSEX_Action_CFG_WriteA
01160 BRA_IFSET TIA_SYSEX_STATE, TIA_SYSEX_STATE_A_RECEIVED, ACCESS, TIA_SYSEX_Action_CFG_WriteDH
534E BA21 M btfsc reg, bit, reg_a
5350 D004 M bra label
5352 8A21 01161 bsf TIA_SYSEX_STATE, TIA_SYSEX_STATE_A_RECEIVED
5354 C023 F025 01162 movff TIA_SYSEX_IN, TIA_SYSEX_ADDRESS ; store address in TIA_SYSEX_ADDRESS
01163 rgoto TIA_SYSEX_SysExCheck_End ; wait for next byte
5358 D50E M bra label
01164
535A 01165 TIA_SYSEX_Action_CFG_WriteDH
01166 BRA_IFSET TIA_SYSEX_STATE, TIA_SYSEX_STATE_DH_RECEIVED, ACCESS, TIA_SYSEX_Action_CFG_WriteDL
535A B821 M btfsc reg, bit, reg_a
535C D005 M bra label
535E 8821 01167 bsf TIA_SYSEX_STATE, TIA_SYSEX_STATE_DH_RECEIVED
5360 3823 01168 swapf TIA_SYSEX_IN, W ; store high-nibble in TIA_SYSEX_CHECKSUM (used as data buffer here)
5362 0BF0 01169 andlw 0xf0
5364 6E24 01170 movwf TIA_SYSEX_CHECKSUM
01171 rgoto TIA_SYSEX_SysExCheck_End ; wait for next byte
5366 D507 M bra label
01172
5368 01173 TIA_SYSEX_Action_CFG_WriteDL
01174 BRA_IFSET TIA_SYSEX_STATE, TIA_SYSEX_STATE_DL_RECEIVED, ACCESS, TIA_SYSEX_Action_CFG_WriteStall
5368 B621 M btfsc reg, bit, reg_a
536A D004 M bra label
536C 8621 01175 bsf TIA_SYSEX_STATE, TIA_SYSEX_STATE_DL_RECEIVED
536E 5023 01176 movf TIA_SYSEX_IN, W ; store low-nibble in TIA_SYSEX_CHECKSUM (used as data buffer here)
5370 1224 01177 iorwf TIA_SYSEX_CHECKSUM, F
01178 rgoto TIA_SYSEX_SysExCheck_End ; wait for next byte
5372 D501 M bra label
01179
5374 01180 TIA_SYSEX_Action_CFG_WriteStall
01181 ;; do nothing until sysex footer (F7) has been received
01182 rgoto TIA_SYSEX_SysExCheck_End
5374 D500 M bra label
01183
5376 01184 TIA_SYSEX_End_CFG_Write
01185 ;; action invalid if data has not been received
01186 BRA_IFCLR TIA_SYSEX_STATE, TIA_SYSEX_STATE_DL_RECEIVED, ACCESS, TIA_SYSEX_ActionInvalid
5376 A621 M btfss reg, bit, reg_a
5378 D509 M bra label
01187
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 174
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
01188 ;; calc resulting EEADR
537A 5025 01189 movf TIA_SYSEX_ADDRESS, W
537C 0B03 01190 andlw 0x03
537E 0F7C 01191 addlw EEPROM_CFG_BASE & 0xff
5380 6EA9 01192 movwf EEADR
01193
01194 ;; write value to EEPROM
5382 5024 01195 movf TIA_SYSEX_CHECKSUM, W ; (value has been stored in TIA_SYSEX_CHECKSUM)
5384 ECB2 F016 01196 call MIOS_EEPROM_Write
01197
01198 ;; send response
5388 D820 01199 rcall TIA_SYSEX_Send_SysExHeader
01200
01201 ;; send CFG_Write ID
538A 0E0D 01202 movlw 0x0d
538C EC24 F016 01203 call MIOS_MIDI_TxBufferPut
01204
01205 ;; send A
5390 5025 01206 movf TIA_SYSEX_ADDRESS, W
5392 EC24 F016 01207 call MIOS_MIDI_TxBufferPut
01208
01209 ;; send DH
5396 0E00 01210 movlw 0x00
5398 BE24 01211 btfsc TIA_SYSEX_CHECKSUM, 7
539A 0E01 01212 movlw 0x01
539C EC24 F016 01213 call MIOS_MIDI_TxBufferPut
01214
01215 ;; send DL
53A0 5024 01216 movf TIA_SYSEX_CHECKSUM, W
53A2 0B7F 01217 andlw 0x7f
53A4 EC24 F016 01218 call MIOS_MIDI_TxBufferPut
01219
01220 ;; send of SysEx footer
53A8 0E01 01221 movlw 0x01 ; (independent from merger state)
01222 rgoto TIA_SYSEX_Send_SysExFooter
53AA D022 M bra label
01223
01224 ;; finish Action
01225 rgoto TIA_SYSEX_ActionFinished
53AC D4EF M bra label
01226
01227 ;; --------------------------------------------------------------------------
01228 ;; MIDI Action: CC Request
01229 ;; --------------------------------------------------------------------------
53AE 01230 TIA_SYSEX_Init_RequestCC
53AE 0012 01231 return
01232
53B0 01233 TIA_SYSEX_Action_RequestCC
01234 ;; do nothing until sysex footer (F7) has been received
01235 rgoto TIA_SYSEX_SysExCheck_End
53B0 D4E2 M bra label
01236
53B2 01237 TIA_SYSEX_End_RequestCC
01238 ;; request CC dump (handled by tia_ccout.inc)
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 175
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
53B2 8410 01239 bsf TIA_STAT, TIA_STAT_CC_DUMP_REQ
01240
01241 ;; finish Action
01242 rgoto TIA_SYSEX_ActionFinished
53B4 D4EB M bra label
01243
01244
01245 ;; --------------------------------------------------------------------------
01246 ;; MIDI Action: Ping
01247 ;; --------------------------------------------------------------------------
53B6 01248 TIA_SYSEX_Init_Ping
53B6 0012 01249 return
01250
53B8 01251 TIA_SYSEX_Action_Ping
01252 ;; do nothing until sysex footer (F7) has been received
01253 rgoto TIA_SYSEX_SysExCheck_End
53B8 D4DE M bra label
01254
53BA 01255 TIA_SYSEX_End_Ping
01256 ;; send Acknowledge
53BA D801 01257 rcall TIA_SYSEX_Send_Acknowledge
01258
01259 ;; finish Action
01260 rgoto TIA_SYSEX_ActionFinished
53BC D4E7 M bra label
01261
01262
01263
01264 ;; --------------------------------------------------------------------------
01265 ;; MIDI Send Acknowledge (Util function)
01266 ;; --------------------------------------------------------------------------
53BE 01267 TIA_SYSEX_Send_Acknowledge
53BE D805 01268 rcall TIA_SYSEX_Send_SysExHeader
01269
53C0 0E0F 01270 movlw 0x0f ; (acknowledge ID)
53C2 EC24 F016 01271 call MIOS_MIDI_TxBufferPut
01272
01273 ;; send of SysEx footer
53C6 0E01 01274 movlw 0x01 ; (independend from merger state)
01275 rgoto TIA_SYSEX_Send_SysExFooter
53C8 D013 M bra label
01276
01277 ;; --------------------------------------------------------------------------
01278 ;; Send TIA SysEx Header (Util function)
01279 ;; --------------------------------------------------------------------------
53CA 01280 TIA_SYSEX_Send_SysExHeader
01281 ;; if TIA_SYSEX_SYXSTATE > 0, check merger flag to allow propper sysex merging
01282 BRA_IFCLR TIA_SYSEX_STATE, TIA_SYSEX_STATE_MYSYSEX, ACCESS, TIA_SYSEX_Send_SysExHeader_Skp
53CA AE21 M btfss reg, bit, reg_a
53CC D007 M bra label
53CE EC12 F016 01283 call MIOS_MIDI_MergerGet
53D2 0B01 01284 andlw 0x01
53D4 E003 01285 bz TIA_SYSEX_Send_SysExHeader_Skp
53D6 0E05 01286 movlw 0x05 ; send only DEVICE_ID
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 176
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
53D8 6E06 01287 movwf TMP1
01288 rgoto TIA_SYSEX_Send_SysExHeaderLoop
53DA D001 M bra label
53DC 01289 TIA_SYSEX_Send_SysExHeader_Skp
01290
53DC 6A06 01291 clrf TMP1
53DE 01292 TIA_SYSEX_Send_SysExHeaderLoop
53DE 5006 01293 movf TMP1, W
53E0 DCCB 01294 rcall TIA_SYSEX_SysExHeaderGet
53E2 EC24 F016 01295 call MIOS_MIDI_TxBufferPut
53E6 2A06 01296 incf TMP1, F
53E8 0E06 01297 movlw 0x06
53EA 6206 01298 cpfseq TMP1, ACCESS
01299 rgoto TIA_SYSEX_Send_SysExHeaderLoop
53EC D7F8 M bra label
53EE 0012 01300 return
01301
01302 ;; --------------------------------------------------------------------------
01303 ;; MIDI Send SysEx Footer (Util function)
01304 ;; --------------------------------------------------------------------------
53F0 01305 TIA_SYSEX_Send_SysExFooter
01306 ;; if WREG[0]=1: send F7 regardless of the merger state
01307 BRA_IFSET WREG, 0, ACCESS, TIA_SYSEX_Send_SysExFooter_Force
53F0 B0E8 M btfsc reg, bit, reg_a
53F2 D005 M bra label
01308 ;; send footer only if merger has been enabled
01309 ;; to ensure a proper MIDI protocol
53F4 EC12 F016 01310 call MIOS_MIDI_MergerGet
53F8 0B01 01311 andlw 0x01
53FA B4D8 01312 skpnz
53FC 0012 01313 return
01314
53FE 01315 TIA_SYSEX_Send_SysExFooter_Force
53FE 0EF7 01316 movlw 0xf7
5400 EF24 F016 01317 goto MIOS_MIDI_TxBufferPut
01318
01319
01320 ;; --------------------------------------------------------------------------
01321 ;; Changes the TIA Master patch
01322 ;; IN: patch number in TIA_PATCH
01323 ;; bank number in TIA_PBANK
01324 ;; --------------------------------------------------------------------------
5404 01325 TIA_SYSEX_ChangeMPatch
5404 0012 01326 return
01327
01328
01329 ;; --------------------------------------------------------------------------
01330 ;; Sends a patch
01331 ;; IN: patch number in TIA_PRESET
01332 ;; bank number in TIA_BANK
01333 ;; TIA_SYSEX_CHECKSUM should be cleared if required
01334 ;; OUT: 128 bytes will be sent
01335 ;; checksum in TIA_SYSEX_CHECKSUM
01336 ;; --------------------------------------------------------------------------
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 177
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
5406 01337 TIA_SYSEX_Hlp_SendPreset
5406 0E00 01338 movlw (EEPROM_PATCH >> 8) & 0xff
5408 6EAA 01339 movwf EEADRH
540A 6AA9 01340 clrf EEADR ; 0x80 bytes to send, use EEADR as counter
01341 ;;rgoto TIA_SYSEX_Hlp_SendPresetLoop
540C 01342 TIA_SYSEX_Hlp_SendPresetLoop
540C EC51 F01B 01343 call TIA_BANK_Read ; read patch content (EEADR will be incremented)
5410 6EF5 01344 movwf TABLAT ; store data in TABLAT
01345
5412 0E11 01346 movlw 0x10+1 ; ensure that patch name doesn't contain characters < 0x20
5414 60A9 01347 cpfslt EEADR, ACCESS
01348 rgoto TIA_SYSEX_Hlp_SendPresetLoop_NoN
5416 D004 M bra label
5418 01349 TIA_SYSEX_Hlp_SendPresetLoop_N
5418 0E20 01350 movlw 0x20
541A 60F5 01351 cpfslt TABLAT, ACCESS
01352 rgoto TIA_SYSEX_Hlp_SendPresetLoop_NoN
541C D001 M bra label
541E 6EF5 01353 movwf TABLAT
5420 01354 TIA_SYSEX_Hlp_SendPresetLoop_NoN
5420 50F5 01355 movf TABLAT, W
5422 0B7F 01356 andlw 0x7f ; add to checksum
5424 2624 01357 addwf TIA_SYSEX_CHECKSUM, F
01358
5426 EC24 F016 01359 call MIOS_MIDI_TxBufferPut; send byte
01360
542A AEA9 01361 btfss EEADR, 7
01362 rgoto TIA_SYSEX_Hlp_SendPresetLoop ; loop 128 times
542C D7EF M bra label
01363
542E 0012 01364 return
01365
01366 ;; --------------------------------------------------------------------------
01367 ;; Sends a wavetable or a kit
01368 ;; IN: wt number in TIA_PRESET
01369 ;; bank number in TIA_BANK
01370 ;; TIA_SYSEX_CHECKSUM should be cleared if required
01371 ;; OUT: 256 bytes will be sent (128*2 DH+DL)
01372 ;; checksum in TIA_SYSEX_CHECKSUM
01373 ;; --------------------------------------------------------------------------
5430 01374 TIA_SYSEX_Hlp_SendWTKit
5430 0E02 01375 movlw (EEPROM_WAVETABLE >> 8) & 0xff
5432 6EAA 01376 movwf EEADRH
5434 6AA9 01377 clrf EEADR ; 0x80 bytes to send, use EEADR as counter
5436 01378 TIA_SYSEX_Hlp_SendWTKitLoop
5436 EC51 F01B 01379 call TIA_BANK_Read ; read patch content (EEADR will be incremented)
543A 6EF5 01380 movwf TABLAT ; store data in TABLAT
01381
543C 0E11 01382 movlw 0x10+1 ; ensure that patch name doesn't contain characters < 0x20
543E 60A9 01383 cpfslt EEADR, ACCESS
01384 rgoto TIA_SYSEX_Hlp_SendWTKitLoop_NoN
5440 D004 M bra label
5442 01385 TIA_SYSEX_Hlp_SendWTKitLoop_N
5442 0E20 01386 movlw 0x20
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 178
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
5444 60F5 01387 cpfslt TABLAT, ACCESS
01388 rgoto TIA_SYSEX_Hlp_SendWTKitLoop_NoN
5446 D001 M bra label
5448 6EF5 01389 movwf TABLAT
544A 01390 TIA_SYSEX_Hlp_SendWTKitLoop_NoN
01391 ;; DH
544A 0E00 01392 movlw 0x00
544C BEF5 01393 btfsc TABLAT, 7
544E 0E01 01394 movlw 0x01
5450 0B7F 01395 andlw 0x7f ; add to checksum
5452 2624 01396 addwf TIA_SYSEX_CHECKSUM, F
5454 EC24 F016 01397 call MIOS_MIDI_TxBufferPut; send DH byte
01398 ;; DL
5458 50F5 01399 movf TABLAT, W
545A 0B7F 01400 andlw 0x7f ; add to checksum
545C 2624 01401 addwf TIA_SYSEX_CHECKSUM, F
545E EC24 F016 01402 call MIOS_MIDI_TxBufferPut; send DL byte
01403
5462 AEA9 01404 btfss EEADR, 7
01405 rgoto TIA_SYSEX_Hlp_SendWTKitLoop ; loop 128 times
5464 D7E8 M bra label
01406
5466 0012 01407 return
01408
01409
01410 ;; --------------------------------------------------------------------------
01411 ;; This function returns the absolute BANK # from relative xBANK #
01412 ;; IN: Relative Bank in TIA_BANK, preset type in WREG
01413 ;; OUT: Abslolute Bank in TIA_BANK, Error in WREG
01414 ;; --------------------------------------------------------------------------
5468 01415 TIA_SYSEX_Hlp_GetAbsoluteBank
5468 6E06 01416 movwf TMP1
01417 BRA_IFCLR TMP1, 0, ACCESS, TIA_SYSEX_Hlp_GetAbsoluteBank_P
546A A006 M btfss reg, bit, reg_a
546C D012 M bra label
546E 01418 TIA_SYSEX_Hlp_GetAbsoluteBank_K
546E 0E06 01419 movlw 16-(DEFAULT_BS_KBANK_ID*2)
5470 6011 01420 cpfslt TIA_BANK, ACCESS
01421 rgoto TIA_SYSEX_Hlp_GetAbsoluteBank_Err
5472 D014 M bra label
5474 5011 01422 movf TIA_BANK, W
5476 0B06 01423 andlw 0x06
5478 44E8 01424 rlncf WREG, W
547A B011 01425 btfsc TIA_BANK, 0
547C 28E8 01426 incf WREG, W
547E 0F14 01427 addlw DEFAULT_BS_KBANK_ID*4
01428 BRA_IFSET TMP1, 1, ACCESS, TIA_SYSEX_Hlp_GetAbsoluteBank_WT
5480 B206 M btfsc reg, bit, reg_a
5482 D003 M bra label
5484 6E11 01429 movwf TIA_BANK
5486 0E00 01430 movlw 0x00
01431 rgoto TIA_SYSEX_Hlp_GetAbsoluteBank_End
5488 D00A M bra label
01432
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 179
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
548A 01433 TIA_SYSEX_Hlp_GetAbsoluteBank_WT
548A 0F02 01434 addlw 0x02
548C 6E11 01435 movwf TIA_BANK
548E 0E00 01436 movlw 0x00
01437 rgoto TIA_SYSEX_Hlp_GetAbsoluteBank_End
5490 D006 M bra label
01438
5492 01439 TIA_SYSEX_Hlp_GetAbsoluteBank_P
01440 ;; Saturate to max Patch banks (DEFAULT_BS_KBANK_ID*4-1)
5492 0E14 01441 movlw DEFAULT_BS_KBANK_ID*4
5494 6011 01442 cpfslt TIA_BANK, ACCESS
01443 rgoto TIA_SYSEX_Hlp_GetAbsoluteBank_Err
5496 D002 M bra label
5498 0E00 01444 movlw 0x00
01445 rgoto TIA_SYSEX_Hlp_GetAbsoluteBank_End
549A D001 M bra label
01446
549C 01447 TIA_SYSEX_Hlp_GetAbsoluteBank_Err
549C 0E06 01448 movlw 0x06 ;; not valid xBANK
01449
549E 01450 TIA_SYSEX_Hlp_GetAbsoluteBank_End
549E 0012 01451 return
01452
01453 ;; --------------------------------------------------------------------------
01454 ;; This function returns the absolute BANK # from relative xBANK #
01455 ;; IN: Abslolute Bank in TIA_BANK
01456 ;; OUT: Relative Bank in TIA_BANK, preset type in WREG
01457 ;; --------------------------------------------------------------------------
54A0 01458 TIA_SYSEX_Hlp_GetRelativeBank
01459 ;; Saturate to 32 absolute banks
54A0 0E1F 01460 movlw 0x1f
54A2 6011 01461 cpfslt TIA_BANK, ACCESS
54A4 6E11 01462 movwf TIA_BANK
54A6 0E14 01463 movlw DEFAULT_BS_KBANK_ID*4
54A8 5C11 01464 subwf TIA_BANK, W
54AA 6E06 01465 movwf TMP1
54AC E702 01466 bnn TIA_SYSEX_Hlp_GetRelativeBank_K
54AE 01467 TIA_SYSEX_Hlp_GetRelativeBank_P
54AE 0E00 01468 movlw 0x00
01469 rgoto TIA_SYSEX_Hlp_GetRelativeBank_End
54B0 D00D M bra label
54B2 01470 TIA_SYSEX_Hlp_GetRelativeBank_K
01471 BRA_IFSET TMP1, 1, ACCESS, TIA_SYSEX_Hlp_GetRelativeBank_WT
54B2 B206 M btfsc reg, bit, reg_a
54B4 D005 M bra label
54B6 28E8 01472 incf WREG, W
54B8 40E8 01473 rrncf WREG, W
54BA 6E11 01474 movwf TIA_BANK
54BC 0E01 01475 movlw 0x01
01476 rgoto TIA_SYSEX_Hlp_GetRelativeBank_End
54BE D006 M bra label
54C0 01477 TIA_SYSEX_Hlp_GetRelativeBank_WT
54C0 04E8 01478 decf WREG, W
54C2 BEE8 01479 btfsc WREG, 7
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 180
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
54C4 0E00 01480 movlw 0x00
54C6 40E8 01481 rrncf WREG, W
54C8 6E11 01482 movwf TIA_BANK
54CA 0E03 01483 movlw 0x03
54CC 01484 TIA_SYSEX_Hlp_GetRelativeBank_End
54CC 0012 01485 return
00375 #include "tia_ccin.inc"
00001 ; $Id: tia_ccin.inc bdupeyron.tech@gmail.com(Antichambre)
00002 ;
00003 ; MIDIbox TIA
00004 ; CC Input Handling
00005 ;
00006 ; ==========================================================================
00007 ;
00008 ; Copyright 1998-2006 Thorsten Klose (tk@midibox.org)
00009 ; Licensed for personal non-commercial use only.
00010 ; All other rights reserved.
00011 ;
00012 ; ==========================================================================
00013
00014 ;; --------------------------------------------------------------------------
00015 ;; IN: index of CC parameter in WREG, value in MIOS_PARAMETER1
00016 ;; --------------------------------------------------------------------------
54CE 00017 TIA_CCIN_Set
54CE D9FC 00018 rcall TIA_CC_TABLE_Get ; prepare a CC action
00019 ;; now:
00020 ;; value is in MIOS_PARAMETER1
00021 ;; command is in MIOS_PARAMETER2
00022 ;; parameter is in FSR1 (pointer)
00023
00024 ;; branch depending on command
54D0 5004 00025 movf MIOS_PARAMETER2, W
54D2 0B0F 00026 andlw 0x0f
00027 JUMPTABLE_2BYTES_UNSECURE
54D4 ECC8 F016 M call MIOS_HLP_GetIndex_2bytes
00028 rgoto TIA_CCIN_Cmd_NOP
54D8 D00F M bra label
00029 rgoto TIA_CCIN_Cmd_V12
54DA D00F M bra label
00030 rgoto TIA_CCIN_Cmd_7BIT
54DC D014 M bra label
00031 rgoto TIA_CCIN_Cmd_7BIT_W_PORTA
54DE D022 M bra label
00032 rgoto TIA_CCIN_Cmd_7BIT_4L
54E0 D02A M bra label
00033 rgoto TIA_CCIN_Cmd_7BIT_4U
54E2 D02F M bra label
00034 rgoto TIA_CCIN_Cmd_SUSKEY
54E4 D042 M bra label
00035 rgoto TIA_CCIN_Cmd_VEL
54E6 D046 M bra label
00036 rgoto TIA_CCIN_Cmd_AFTERTOUCH
54E8 D0B6 M bra label
00037 rgoto TIA_CCIN_Cmd_MODWHEEL
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 181
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
54EA D0ED M bra label
00038 rgoto TIA_CCIN_Cmd_WAVEFORM
54EC D127 M bra label
00039 rgoto TIA_CCIN_Cmd_NOP
54EE D004 M bra label
00040 rgoto TIA_CCIN_Cmd_NOP
54F0 D003 M bra label
00041 rgoto TIA_CCIN_Cmd_NOP
54F2 D002 M bra label
00042 rgoto TIA_CCIN_Cmd_NOP
54F4 D001 M bra label
00043 rgoto TIA_CCIN_Cmd_PlayNote
54F6 D135 M bra label
00044
00045 ; ==========================================================================
00046
00047 ;; --------------------------------------------------------------------------
54F8 00048 TIA_CCIN_Cmd_NOP
00049 ;; no jump to end, since no CS update is required
00050 ;; rgoto TIA_CCIN_Cmd_End
54F8 0012 00051 return
00052
00053 ;; --------------------------------------------------------------------------
54FA 00054 TIA_CCIN_Cmd_V12
54FA 50E1 00055 movf FSR1L, W ; parameter contains first CC, save it
54FC 6E05 00056 movwf MIOS_PARAMETER3
54FE DFE7 00057 rcall TIA_CCIN_Set ; set first voice
5500 2A05 00058 incf MIOS_PARAMETER3, F
5502 5005 00059 movf MIOS_PARAMETER3, W
00060 rgoto TIA_CCIN_Set ; set second voice
5504 D7E4 M bra label
00061
00062 ;; --------------------------------------------------------------------------
5506 00063 TIA_CCIN_Cmd_7BIT
00064 ;; special treatment, GSA falling -> Gate falls
5506 0E24 00065 movlw (TIA_V1_BASE + TIA_Vx_MODE) & 0xff ;; V1 MODE register
5508 18E1 00066 xorwf FSR1L, W
550A E003 00067 bz TIA_CCIN_Cmd_7BIT_GSA_Fall
550C 0E64 00068 movlw (TIA_V2_BASE + TIA_Vx_MODE) & 0xff ;; V2 MODE register
550E 18E1 00069 xorwf FSR1L, W
5510 E106 00070 bnz TIA_CCIN_Cmd_7BIT_End
5512 00071 TIA_CCIN_Cmd_7BIT_GSA_Fall ;; detect fall of GSA
5512 B0E7 00072 btfsc INDF1, Vx_MODE_GSA_ACTIVE
5514 B003 00073 btfsc MIOS_PARAMETER1, Vx_MODE_GSA_ACTIVE
5516 D003 00074 bra TIA_CCIN_Cmd_7BIT_End
00075 ;; clear gate
5518 06E1 00076 decf FSR1L, F ;; Vx STAT register
551A 96E7 00077 bcf INDF1, Vx_STAT_GATE_ACTIVE
551C 2AE1 00078 incf FSR1L, F ;; Vx MODE register
551E 00079 TIA_CCIN_Cmd_7BIT_End
00080 ;; normal treatment
551E C003 FFE7 00081 movff MIOS_PARAMETER1, INDF1
00082
00083 rgoto TIA_CCIN_Cmd_End
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 182
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
5522 D171 M bra label
00084
00085 ;; --------------------------------------------------------------------------
5524 00086 TIA_CCIN_Cmd_7BIT_W_PORTA
5524 9610 00087 bcf TIA_STAT, TIA_STAT_SAVED_GIE ; for nested IRQ disables
5526 BEF2 00088 btfsc INTCON, GIE
5528 8610 00089 bsf TIA_STAT, TIA_STAT_SAVED_GIE
00090 IRQ_DISABLE
552A 9EF2 M bcf INTCON, GIE
00091
00092 ;; works only with TIA_Vx_TRANSPOSE, _PITCHRANGE
552C C003 FFE7 00093 movff MIOS_PARAMETER1, INDF1
00094
00095 #if 0
00096 ;; enable portamento if rate is > 0
00097 ;; switch to TIA_Vx_PORTA_RATE
00098 movf FSR1L, W
00099 andlw 0x03
00100 iorlw TIA_V1_PORTA_RATE & 0xfc
00101 movwf FSR1L
00102 movf INDF1, W
00103 bz TIA_CCIN_Cmd_7BIT_W_PORTA_End
00104
00105 movf FSR1L, W
00106 andlw 0x03
00107 iorlw TIA_V1_MODE & 0xfc
00108 movwf FSR1L
00109 bsf INDF1, Vx_STAT_PORTA_ENABLE
00110 #endif
00111
5530 00112 TIA_CCIN_Cmd_7BIT_W_PORTA_End
00113 ;; IRQ_ENABLE
5530 B610 00114 btfsc TIA_STAT, TIA_STAT_SAVED_GIE ; nested IRQ enable
5532 8EF2 00115 bsf INTCON, GIE
00116
00117 rgoto TIA_CCIN_Cmd_End
5534 D168 M bra label
00118
00119
00120 ;; --------------------------------------------------------------------------
5536 00121 TIA_CCIN_Cmd_7BIT_4L
5536 0EF0 00122 movlw 0xf0
5538 16E7 00123 andwf INDF1, F
553A 5003 00124 movf MIOS_PARAMETER1, W
553C 0B0F 00125 andlw 0x0f
553E 12E7 00126 iorwf INDF1, F
00127 rgoto TIA_CCIN_Cmd_End
5540 D162 M bra label
00128
00129 ;; --------------------------------------------------------------------------
5542 00130 TIA_CCIN_Cmd_7BIT_4U
5542 0E0F 00131 movlw 0x0f
5544 16E7 00132 andwf INDF1, F
5546 3803 00133 swapf MIOS_PARAMETER1, W
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 183
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
5548 0BF0 00134 andlw 0xf0
554A 12E7 00135 iorwf INDF1, F
00136 rgoto TIA_CCIN_Cmd_End
554C D15C M bra label
00137
00138 ;; --------------------------------------------------------------------------
554E 00139 TIA_CCIN_Cmd_7BIT_TO_7_4
554E 0E0F 00140 movlw 0x0f
5550 16E7 00141 andwf INDF1, F
5552 3403 00142 rlf MIOS_PARAMETER1, W
5554 0BF0 00143 andlw 0xf0
5556 12E7 00144 iorwf INDF1, F
00145 rgoto TIA_CCIN_Cmd_End
5558 D156 M bra label
00146
00147 ;; --------------------------------------------------------------------------
555A 00148 TIA_CCIN_Cmd_7BIT_TO_3_0
555A 0EF0 00149 movlw 0xf0
555C 16E7 00150 andwf INDF1, F
555E 3003 00151 rrf MIOS_PARAMETER1, W
5560 32E8 00152 rrf WREG, F
5562 30E8 00153 rrf WREG, W
5564 0B0F 00154 andlw 0x0f
5566 12E7 00155 iorwf INDF1, F
00156 rgoto TIA_CCIN_Cmd_End
5568 D14E M bra label
00157
00158 ;; --------------------------------------------------------------------------
556A 00159 TIA_CCIN_Cmd_SUSKEY
556A 930C 00160 bcf TIA_PLAY_MODE, TIA_PLAY_MODE_SUS_KEY, BANKED
556C 5003 00161 movf MIOS_PARAMETER1, W
556E A4D8 00162 skpz
5570 830C 00163 bsf TIA_PLAY_MODE, TIA_PLAY_MODE_SUS_KEY, BANKED
00164
00165 ;rrf MIOS_PARAMETER1, W
00166 ;andlw 0x3f
00167 ;movwf TIA_KEYTRACKING, BANKED
00168
00169 rgoto TIA_CCIN_Cmd_End
5572 D149 M bra label
00170
00171 ; ==========================================================================
00172
00173 ;; ------------------------------------------------------------------
00174 ;; Controller Handler Macro
00175 ;; ------------------------------------------------------------------
00176 TIA_CCIN_SETHLP_MACRO_DO_CTRL MACRO BASE, LAST_VALUE, DEPTH_VALUE, INIT_VALUE, ASSIGN_VALUE
00177 LOCAL TIA_CCIN_CmdHlp_DoCtrl_Neg
00178 LOCAL TIA_CCIN_CmdHlp_DoCtrl_Pos
00179 LOCAL TIA_CCIN_CmdHlp_DoCtrl_NoDepth
00180 LOCAL TIA_CCIN_CmdHlp_DoCtrl_Cont
00181
00182 ;; Velocity calc
00183 movf BASE + DEPTH_VALUE, W, BANKED ; calc (DEPTH+1)*4 * LAST_VALUE
gpasm-0.13.7 beta setup_tia_cartridge.asm7-11-2013 10:44:07 PAGE 184
 
 
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00184 xorlw 0x40
00185 bz TIA_CCIN_CmdHlp_DoCtrl_NoDepth
00186
00187 movf BASE + DEPTH_VALUE, W, BANKED
00188 andlw 0x3f
00189 clrc
00190 rlf WREG, W
00191 ;movwf MIOS_PARAMETER1
00192
00193 btfss BASE + DEPTH_VALUE, 6, BANKED
00194 rgoto TIA_CCIN_CmdHlp_DoCtrl_Neg
00195
00196 TIA_CCIN_CmdHlp_DoCtrl_Pos
00197 addlw 2
00198 movwf MIOS_PARAMETER1
00199
00200 movf BASE + LAST_VALUE, W, BANKED
00201 mulwf MIOS_PARAMETER1
00202 clrc
00203 rlf PRODL, F
00204 rlf PRODH, W
00205 addlw 1
00206 movwf MIOS_PARAMETER1
00207
00208 movf BASE + INIT_VALUE, W, BANKED
00209 sublw 0x7f
00210 mulwf MIOS_PARAMETER1
00211 rlf PRODL, F