| 1 |
;;; ---------------------------------------- |
| 2 |
;;; CCUTTER 2.x musicplayer by abad |
| 3 |
;;; Based on JCH NP 21.G4 by Laxity/VIB |
| 4 |
;;; ---------------------------------------- |
| 5 |
!ifdef ZREG { |
| 6 |
} else { |
| 7 |
ZREG = $fb |
| 8 |
} |
| 9 |
FALSE = 0 |
| 10 |
TRUE = 1 |
| 11 |
EXPORT = FALSE ; if TRUE, editor specific code will be left out |
| 12 |
MULTISPEED = TRUE ; support for multispeed playback |
| 13 |
INSNO = 48 ; number of instruments used |
| 14 |
CIA_VALUE = $4cc7 ; for multispeed |
| 15 |
MULTIPLIER = 1 ; for multispeed |
| 16 |
BASEADDRESS = $1000 |
| 17 |
;;; ---------------------------------------- |
| 18 |
;;; instr table enums |
| 19 |
;;; ---------------------------------------- |
| 20 |
INS_AD = 0 ; |
| 21 |
INS_SR = 1 * INSNO |
| 22 |
INS_HR = 2 * INSNO ; $x0 = HR type, $0x arp delay count |
| 23 |
INS_4 = 3 * INSNO ; HR waveform |
| 24 |
INS_FLTP = 4 * INSNO ; |
| 25 |
INS_PULSP = 5 * INSNO ; |
| 26 |
INS_7 = 6 * INSNO ; |
| 27 |
INS_ARP = 7 * INSNO |
| 28 |
;;; ---------------------------------------- |
| 29 |
;;; assembly conditionals |
| 30 |
;;; ---------------------------------------- |
| 31 |
INCLUDE_CMD_SLUP = TRUE |
| 32 |
INCLUDE_CMD_SLDOWN = TRUE |
| 33 |
INCLUDE_CMD_VIBR = TRUE |
| 34 |
INCLUDE_CMD_PORTA = TRUE |
| 35 |
INCLUDE_CMD_SET_ADSR = TRUE |
| 36 |
INCLUDE_CMD_SET_OFFSET = TRUE |
| 37 |
INCLUDE_CMD_SET_LOVIB = TRUE |
| 38 |
INCLUDE_CMD_SET_WAVE = FALSE |
| 39 |
INCLUDE_SEQ_SET_PULSE = TRUE |
| 40 |
INCLUDE_SEQ_SET_CHORD = TRUE |
| 41 |
INCLUDE_SEQ_SET_ATT = TRUE |
| 42 |
INCLUDE_SEQ_SET_DEC = TRUE |
| 43 |
INCLUDE_SEQ_SET_SUS = TRUE |
| 44 |
INCLUDE_SEQ_SET_REL = TRUE |
| 45 |
INCLUDE_SEQ_SET_SPEED = TRUE |
| 46 |
INCLUDE_SEQ_SET_VOL = TRUE |
| 47 |
INCLUDE_DIRECT_PULSE = TRUE |
| 48 |
INCLUDE_VIBRAFEEL = TRUE |
| 49 |
INCLUDE_BREAKSPEED = TRUE |
| 50 |
INCLUDE_CHORD = TRUE |
| 51 |
INCLUDE_FILTER = TRUE |
| 52 |
INCLUDE_SYNC = TRUE |
| 53 |
USE_MDRIVER = FALSE |
| 54 |
;;; ---------------------------------------- |
| 55 |
;;; new effect commands |
| 56 |
;;; ---------------------------------------- |
| 57 |
CMD_SLIDE_UP = $00 |
| 58 |
CMD_SLIDE_DOWN = $01 |
| 59 |
CMD_VIBRATO = $02 |
| 60 |
CMD_SET_OFFSET = $03 |
| 61 |
CMD_SET_ADSR = $04 |
| 62 |
CMD_SET_LOVIB = $05 |
| 63 |
CMD_SET_WAVE = $06 |
| 64 |
CMD_PORTAMENTO = $07 |
| 65 |
CMD_STOP = $08 ;stop portamento/slide |
| 66 |
;;; ---------------------------------------- |
| 67 |
SUPERHIGH = CMD_SET_OFFSET |
| 68 |
;;; ---------------------------------------- |
| 69 |
;;; the following data describes the player features |
| 70 |
;;; for the editor |
| 71 |
;;; ---------------------------------------- |
| 72 |
!if EXPORT = FALSE { |
| 73 |
*=$e00 |
| 74 |
features = * |
| 75 |
requestedTables !8 %00001111 |
| 76 |
;;; 1 = points to wave table |
| 77 |
;;; 2 = points to cmd table (NOT IMPLEMENTED) |
| 78 |
;;; 3 = points to pulse table |
| 79 |
;;; 4 = points to filter table |
| 80 |
;;; ... |
| 81 |
instrumentFlags !8 0,0,0,0,4,3,0,1 |
| 82 |
;;; 1 = points to wave table |
| 83 |
;;; 3 = points to pulse table |
| 84 |
;;; 4 = points to filter table |
| 85 |
cmdFlags !8 0,0,0,0,0,0,0,0 |
| 86 |
!8 0,0,0,0,0,0,0,0 |
| 87 |
|
| 88 |
instrumentDescriptionsHeader |
| 89 |
!16 idescr0,idescr1,idescr2,idescr3,idescr4,idescr5,idescr6,idescr7 |
| 90 |
pulseDescriptionsHeader |
| 91 |
!16 pdescr0,pdescr1,pdescr2,pdescr3 |
| 92 |
filterDescriptionsHeader |
| 93 |
!16 fdescr0,fdescr1,fdescr2,fdescr3 |
| 94 |
waveDescriptionsHeader |
| 95 |
!16 wdescr0,wdescr1 |
| 96 |
cmdDescriptionsHeader |
| 97 |
!16 mdescr0,mdescr1 |
| 98 |
} |
| 99 |
|
| 100 |
;;; ---------------------------------------- |
| 101 |
;;; some pointers for the editor |
| 102 |
;;; ---------------------------------------- |
| 103 |
!if EXPORT = FALSE { |
| 104 |
*= $0fa0 |
| 105 |
ofa0 !16 features |
| 106 |
ofa2 !16 volume |
| 107 |
ofa4 !16 editorflag |
| 108 |
ofa6 !16 songsets |
| 109 |
ofa8 !16 playspeed |
| 110 |
ofaa !16 subnoteplay |
| 111 |
ofac !16 submplayplay |
| 112 |
ofae !16 instrumentDescriptionsHeader |
| 113 |
ofb0 !16 pulseDescriptionsHeader |
| 114 |
ofb2 !16 filterDescriptionsHeader |
| 115 |
ofb4 !16 waveDescriptionsHeader |
| 116 |
ofb6 !16 cmdDescriptionsHeader |
| 117 |
ofb8 !16 dummy |
| 118 |
ofba !16 dummy |
| 119 |
ofbc !16 arp1 |
| 120 |
ofbe !16 arp2 |
| 121 |
ofc0 !16 filttab |
| 122 |
ofc2 !16 pulstab |
| 123 |
ofc4 !16 inst |
| 124 |
ofc6 !16 track1 |
| 125 |
ofc8 !16 track2 |
| 126 |
ofca !16 track3 |
| 127 |
ofcc !16 seqlo |
| 128 |
ofce !16 seqhi |
| 129 |
ofd0 !16 cmd1 |
| 130 |
ofd2 !16 s0 |
| 131 |
ofd4 !16 speed |
| 132 |
ofd6 !16 tracklo |
| 133 |
ofd8 !16 voice ;voice 1c X, for voice on/of flagging |
| 134 |
ofda !16 gate |
| 135 |
ofdc !16 chord |
| 136 |
ofde !16 trans |
| 137 |
ofe0 !16 chordindex |
| 138 |
ofe2 !16 shtrans |
| 139 |
ofe6 !16 dummy |
| 140 |
ofe8 !16 dummy |
| 141 |
ofea !16 dummy |
| 142 |
ofec !16 dummy |
| 143 |
ofee !16 newseq |
| 144 |
version !pet "cc4.07" |
| 145 |
} |
| 146 |
;;; ---------------------------------------- |
| 147 |
;;; editor specific player routines, will be |
| 148 |
;;; left out from a finalized tune |
| 149 |
;;; ---------------------------------------- |
| 150 |
!if EXPORT = FALSE { |
| 151 |
*=$f000 |
| 152 |
idescr0 !raw "Attack / Decay.",0 |
| 153 |
idescr1 !raw "Sustain / Release.",0 |
| 154 |
idescr2 !raw "Restart type / arpeggio speed.&$00 = 3 Frame Restart.&$40 = Soft restart.&$80 = Hard Restart. &$00-$0F = Arpeggio delay value.",0 |
| 155 |
idescr3 !raw "Hard Restart waveform.",0 |
| 156 |
idescr4 !raw "Filter Table pointer.",0 |
| 157 |
idescr5 !raw "Pulse Table pointer $00-$3f.",0 |
| 158 |
idescr6 !raw "Hard restart SR envelope value.",0 |
| 159 |
idescr7 !raw "Wave Table pointer.",0 |
| 160 |
|
| 161 |
pdescr0 !raw "Duration and direction.&$00-$7F = Add n frames.&$80-$FF = Subtract n frames.",0 |
| 162 |
pdescr1 !raw "Add value.",0 |
| 163 |
pdescr2 !raw "Initial pulse value.&Note: Nibbles are reversed! $48 = $8400",0 |
| 164 |
pdescr3 !raw "Pointer to next set ($00-$3F) or $7F = stop pulse program.",0 |
| 165 |
|
| 166 |
fdescr0 !raw "Duration or filter type.&$00-$7f = Duration or $90-$F0 select filter type.",0 |
| 167 |
fdescr1 !raw "Add value or filter resonance and channel mask.",0 |
| 168 |
fdescr2 !raw "Initial filter value or $FF = skip.",0 |
| 169 |
fdescr3 !raw "Pointer to next set ($00-$3F) or $7F = stop filter program.",0 |
| 170 |
|
| 171 |
;;; wave table help |
| 172 |
wdescr0 !raw "Transpose value / Loop.&$00-$5F = Relative transpose up,&" |
| 173 |
!raw "$80-$DF = Absolute tuning (unaffected by note/transpose value).&" |
| 174 |
!raw "$7E = loop to previous row, $7F = loop to row",0 |
| 175 |
wdescr1 !raw "Waveform / Wave delay / Loop pointer&" |
| 176 |
!raw "$00 = Do nothing.&" |
| 177 |
!raw "$01 - $0F = Override instrument's Wave Delay value for this row.&" |
| 178 |
!raw "$10 - $DF = Waveform; SID Control Register value.&" |
| 179 |
!raw "$E0 - $EF = SID Control Register value $00 - $0F.&" |
| 180 |
!raw "$00 - $FF = Loop pointer, if Byte 1 = $7F.",0 |
| 181 |
|
| 182 |
|
| 183 |
;;; Command table help |
| 184 |
mdescr0 !raw "Command number.&" |
| 185 |
!raw "$0 = Slide up.&" |
| 186 |
!raw "$1 = Slide down.&" |
| 187 |
!raw "$2 = Hi-fi Vibrato.&" |
| 188 |
!raw "$3 = Detune current note.&" |
| 189 |
!raw "$4 = Set ADSR for the current note.&" |
| 190 |
!raw "$5 = Lo-fi vibrato.&" |
| 191 |
!raw "$6 = Set wave.&" |
| 192 |
!raw "$7 = Portamento a tie note.&" |
| 193 |
!raw "$8 = Stop portamento",0 |
| 194 |
mdescr1 !raw "Parameter values.&" |
| 195 |
!raw "Slide up/down: Slide speed (signed 16-bit).&" |
| 196 |
!raw "Vibrato: 1st byte, lonibble: vibrato 'feel'&" |
| 197 |
!raw " 2nd byte, hinibble: Speed.&" |
| 198 |
!raw " lonibble: Depth divider (bigger value = narrower vibrato).&" |
| 199 |
!raw "Detune: (signed 16-bit).&" |
| 200 |
!raw "ADSR: (self-explanatory).&" |
| 201 |
!raw "Lo-fi vibrato: Speed / Depth." |
| 202 |
!raw "&Set waveform (in the last parameter byte).&" |
| 203 |
;;; !raw "Portamento: (Portamento must be applied to tie notes only and reset with e.g. No command 8-00 00).",0 |
| 204 |
!raw "Portamento: Portamento speed. Runs until a command 8-00 00 is given).",0 |
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
*=$f800 |
| 209 |
submplayplay lda #$80 |
| 210 |
sta state |
| 211 |
ldx #2 |
| 212 |
jmp updsound |
| 213 |
|
| 214 |
;;; ---------------------------------------- |
| 215 |
;;; used for triggering a note from th editor |
| 216 |
;;; ---------------------------------------- |
| 217 |
subnoteplay |
| 218 |
sta shnote,x |
| 219 |
cmp #3 |
| 220 |
lda #0 |
| 221 |
rol |
| 222 |
eor #1 |
| 223 |
sta tienote,x |
| 224 |
tya |
| 225 |
sta shinst,x |
| 226 |
|
| 227 |
lda #3 |
| 228 |
sta tsync,x |
| 229 |
lda #0 |
| 230 |
sta synccnt,x |
| 231 |
lda #1 |
| 232 |
sta newinsflag,x |
| 233 |
lda #0 |
| 234 |
sta effstate,x |
| 235 |
sta chordvalue,x |
| 236 |
lda #$80 |
| 237 |
sta state |
| 238 |
sta chordtpos,x |
| 239 |
|
| 240 |
jmp updsound |
| 241 |
} |
| 242 |
|
| 243 |
|
| 244 |
*= BASEADDRESS |
| 245 |
|
| 246 |
init |
| 247 |
!if USE_MDRIVER = TRUE { |
| 248 |
jmp cinit |
| 249 |
} else { |
| 250 |
jmp subinit |
| 251 |
} |
| 252 |
play |
| 253 |
!if USE_MDRIVER = TRUE { |
| 254 |
jmp cplay |
| 255 |
} else { |
| 256 |
jmp subplay |
| 257 |
} |
| 258 |
!if MULTISPEED = TRUE { |
| 259 |
mplay jmp submplay |
| 260 |
} |
| 261 |
sync !8 0 |
| 262 |
;--------------------------------------- |
| 263 |
subinit asl |
| 264 |
asl |
| 265 |
asl |
| 266 |
tay |
| 267 |
ldx #0 |
| 268 |
!if INCLUDE_BREAKSPEED = TRUE { |
| 269 |
stx speedsub |
| 270 |
} |
| 271 |
!if INCLUDE_SYNC = TRUE { |
| 272 |
stx sync |
| 273 |
} |
| 274 |
subinit0 lda songsets,y |
| 275 |
sta twraplo,x |
| 276 |
iny |
| 277 |
lda songsets,y |
| 278 |
sta twraphi,x |
| 279 |
iny |
| 280 |
inx |
| 281 |
cpx #3 |
| 282 |
bne subinit0 |
| 283 |
lda songsets,y ;set song speed |
| 284 |
sta speed |
| 285 |
!if EXPORT = FALSE { |
| 286 |
cmp #2 |
| 287 |
bcs subinit00 |
| 288 |
lda chord |
| 289 |
subinit00 sta playspeed |
| 290 |
|
| 291 |
lda editorflag |
| 292 |
beq subinit3 |
| 293 |
} |
| 294 |
ldx #2 |
| 295 |
subinit1 lda songsets+1,y |
| 296 |
and bits,x |
| 297 |
sta voicon,x |
| 298 |
lda twraplo,x ; trackpointers not set from the editor |
| 299 |
sta tracklo,x |
| 300 |
lda twraphi,x |
| 301 |
sta trackhi,x |
| 302 |
lda #1 ; newseq not set from the editor |
| 303 |
sta newseq,x |
| 304 |
dex |
| 305 |
bpl subinit1 |
| 306 |
|
| 307 |
subinit3 lda #1 |
| 308 |
sta state |
| 309 |
rts |
| 310 |
|
| 311 |
;;; ---------------------------------------- |
| 312 |
;;; do only sound work, used for multispeed |
| 313 |
;;; playback frames |
| 314 |
;;; ---------------------------------------- |
| 315 |
!if MULTISPEED = TRUE { |
| 316 |
submplay lda #$40 |
| 317 |
sta state |
| 318 |
ldx #2 |
| 319 |
jmp syncskip |
| 320 |
} |
| 321 |
;;; ---------------------------------------- |
| 322 |
;;; regular play call |
| 323 |
;;; ---------------------------------------- |
| 324 |
subplay |
| 325 |
lda state |
| 326 |
beq run |
| 327 |
|
| 328 |
lda #2 |
| 329 |
sta speedcnt |
| 330 |
|
| 331 |
ldx #(clrlast-clrfirst) |
| 332 |
lda #0 |
| 333 |
subinit4 dex |
| 334 |
sta clrfirst,x |
| 335 |
bne subinit4 |
| 336 |
|
| 337 |
;; reset synchonization |
| 338 |
|
| 339 |
ldx #2 |
| 340 |
subinit5 lda #2 |
| 341 |
sta synccnt,x ; HR allowed |
| 342 |
lda #$fe |
| 343 |
sta tsync,x ; sync done |
| 344 |
dex |
| 345 |
bpl subinit5 |
| 346 |
lda #$0f |
| 347 |
sta volume |
| 348 |
!if INCLUDE_FILTER = TRUE { |
| 349 |
lda #0 |
| 350 |
sta filter |
| 351 |
sta bandpass |
| 352 |
} |
| 353 |
lda #$f0 |
| 354 |
sta $d417 |
| 355 |
lda #0 |
| 356 |
sta state |
| 357 |
rts |
| 358 |
|
| 359 |
run dec speedcnt |
| 360 |
bpl speeddone |
| 361 |
lda speed |
| 362 |
!if INCLUDE_BREAKSPEED = TRUE { |
| 363 |
cmp #2 |
| 364 |
bpl speedok |
| 365 |
speedalt ldy speedsub |
| 366 |
lda chord,y |
| 367 |
bpl nowrap |
| 368 |
ldy #0 |
| 369 |
sty speedsub |
| 370 |
lda chord,y |
| 371 |
nowrap inc speedsub |
| 372 |
sta playspeed |
| 373 |
cmp #2 |
| 374 |
bpl speedok |
| 375 |
lda #2 |
| 376 |
} |
| 377 |
speedok sta speedcnt |
| 378 |
speeddone |
| 379 |
;--------------------------------------- |
| 380 |
ldx #2 |
| 381 |
main0 lda voicon,x |
| 382 |
bne trackon |
| 383 |
jmp next |
| 384 |
trackon inc synccnt,x |
| 385 |
lda speedcnt |
| 386 |
beq jupdseq |
| 387 |
cmp #1 |
| 388 |
beq updtrack |
| 389 |
jmp updsound |
| 390 |
jupdseq jmp updseq |
| 391 |
;--------------------------------------- |
| 392 |
updtrack lda newseq,x |
| 393 |
beq skiptrack |
| 394 |
sec |
| 395 |
sbc #1 |
| 396 |
sta seqcnt,x |
| 397 |
lda #0 |
| 398 |
sta newseq,x |
| 399 |
tay |
| 400 |
lda tracklo,x |
| 401 |
sta ZREG |
| 402 |
lda trackhi,x |
| 403 |
sta ZREG+1 |
| 404 |
lda (ZREG),y |
| 405 |
bpl trk02 |
| 406 |
|
| 407 |
cmp #$80 ; get transpose value |
| 408 |
beq skiptrans |
| 409 |
sbc #$a0 |
| 410 |
sta shtrans2,x |
| 411 |
skiptrans inc tracklo,x |
| 412 |
bne trk01 |
| 413 |
inc trackhi,x |
| 414 |
trk01 iny |
| 415 |
lda (ZREG),y |
| 416 |
trk02 sta curseq,x |
| 417 |
iny |
| 418 |
lda (ZREG),y |
| 419 |
cmp #$f0 |
| 420 |
bcc trk03 |
| 421 |
|
| 422 |
pha |
| 423 |
iny |
| 424 |
lda (ZREG),y |
| 425 |
clc |
| 426 |
adc twraplo,x |
| 427 |
sta tracklo,x |
| 428 |
|
| 429 |
pla |
| 430 |
and #$07 |
| 431 |
adc twraphi,x ; song wrap |
| 432 |
sta trackhi,x |
| 433 |
jmp updsound |
| 434 |
|
| 435 |
trk03 inc tracklo,x |
| 436 |
bne skiptrack |
| 437 |
inc trackhi,x |
| 438 |
skiptrack jmp updsound |
| 439 |
;--------------------------------------- |
| 440 |
updseq dec durcnt,x |
| 441 |
bmi nextnote |
| 442 |
jmp updsound |
| 443 |
nextnote ldy curseq,x |
| 444 |
lda seqlo,y |
| 445 |
sta ZREG |
| 446 |
lda seqhi,y |
| 447 |
sta ZREG+1 |
| 448 |
lda #2 |
| 449 |
sta tsync,x |
| 450 |
getseq ldy seqcnt,x |
| 451 |
seqnext lda (ZREG),y |
| 452 |
cmp #$c0 |
| 453 |
bcs command |
| 454 |
cmp #$60-1 ; command coming up? |
| 455 |
bcc nocmdbyt |
| 456 |
sbc #$60 |
| 457 |
bpl nottie |
| 458 |
inc tienote,x ; $5f = flag tienote |
| 459 |
iny |
| 460 |
jmp seqnext |
| 461 |
|
| 462 |
nottie pha ; store note value |
| 463 |
iny |
| 464 |
lda (ZREG),y ; fetch sequence command |
| 465 |
beq skipcmd |
| 466 |
sta shsuper,x |
| 467 |
|
| 468 |
inc newcmdflag,x |
| 469 |
skipcmd pla |
| 470 |
|
| 471 |
nocmdbyt sta shnote,x ; check for rest & gate flags |
| 472 |
cmp #3 |
| 473 |
bcs sequpdtrans |
| 474 |
settie inc tienote,x |
| 475 |
jmp seqdone |
| 476 |
|
| 477 |
command cmp #$f0 |
| 478 |
bmi notdur |
| 479 |
setdur and #$0f |
| 480 |
sta duration,x |
| 481 |
iny |
| 482 |
jmp seqnext |
| 483 |
|
| 484 |
notdur sbc #$c0-1 |
| 485 |
sta shinst,x |
| 486 |
|
| 487 |
inc newinsflag,x |
| 488 |
iny |
| 489 |
jmp seqnext |
| 490 |
|
| 491 |
sequpdtrans lda shtrans2,x |
| 492 |
sta shtrans,x |
| 493 |
seqdone iny |
| 494 |
beq seqsetflag ; new seq automatically if seqcnt wrapped |
| 495 |
tya |
| 496 |
sta seqcnt,x |
| 497 |
|
| 498 |
lda (ZREG),y |
| 499 |
cmp #$bf ;seq end mark |
| 500 |
bne noteos |
| 501 |
seqsetflag inc newseq,x |
| 502 |
noteos |
| 503 |
lda duration,x |
| 504 |
sta durcnt,x |
| 505 |
!if INCLUDE_CMD_PORTA = TRUE { |
| 506 |
lda newcmdflag,x |
| 507 |
beq snotporta ; ! |
| 508 |
|
| 509 |
;; Check for super commands that |
| 510 |
;; ;should be parsed immidiately |
| 511 |
|
| 512 |
ldy shsuper,x ;cmd byte? |
| 513 |
cpy #$40 |
| 514 |
bpl updsound |
| 515 |
|
| 516 |
lda cmd1,y |
| 517 |
cmp #CMD_PORTAMENTO |
| 518 |
bne snotporta |
| 519 |
|
| 520 |
lda cmd2,y |
| 521 |
and #$0f |
| 522 |
sta portahi,x |
| 523 |
lda cmd3,y |
| 524 |
sta portalo,x |
| 525 |
|
| 526 |
lda #$81 |
| 527 |
sta effstate,x |
| 528 |
;; formerly clrsuper |
| 529 |
lda #0 |
| 530 |
sta newcmdflag,x |
| 531 |
|
| 532 |
jmp updsound |
| 533 |
snotporta |
| 534 |
} |
| 535 |
|
| 536 |
;;; ---------------------------------------- |
| 537 |
;;; sound work |
| 538 |
;;; ---------------------------------------- |
| 539 |
updsound lda #0 |
| 540 |
sta hardon,x |
| 541 |
lda tsync,x |
| 542 |
bpl dosync |
| 543 |
jmp syncskip |
| 544 |
|
| 545 |
dosync dec tsync,x |
| 546 |
|
| 547 |
lda tienote,x |
| 548 |
beq syncnottied |
| 549 |
jmp syncskip |
| 550 |
|
| 551 |
syncnottied lda tsync,x |
| 552 |
cmp #1 |
| 553 |
bne syncgate |
| 554 |
|
| 555 |
lda synccnt,x ; hard restart possible? |
| 556 |
cmp #2 |
| 557 |
bmi syncnohr |
| 558 |
|
| 559 |
ldy shinst,x ; use hard restart? |
| 560 |
lda inst+INS_HR,y |
| 561 |
bpl syncnohr |
| 562 |
and #$20 |
| 563 |
bne laxhr |
| 564 |
|
| 565 |
;; Hard restart |
| 566 |
|
| 567 |
lda cmd2 ;Set adsr for HR |
| 568 |
sta ad,x |
| 569 |
laxhr lda inst+INS_7,y |
| 570 |
sta sr,x |
| 571 |
syncnohr lda #$fe |
| 572 |
sta gate,x |
| 573 |
jmp dowave ;only update wavetable |
| 574 |
|
| 575 |
syncgate cmp #$ff |
| 576 |
beq syncgateon |
| 577 |
jmp syncskip |
| 578 |
|
| 579 |
syncgateon lda newinsflag,x |
| 580 |
beq checknote |
| 581 |
|
| 582 |
ldy shinst,x |
| 583 |
lda inst,y ;Store ADSR of insturmen in shadow |
| 584 |
sta shad,x ;ADSR regs |
| 585 |
lda inst+INS_SR,y |
| 586 |
sta shsr,x |
| 587 |
|
| 588 |
lda effstate,x ;don't reset porta |
| 589 |
bmi checknote |
| 590 |
|
| 591 |
lda #0 |
| 592 |
sta effstate,x |
| 593 |
|
| 594 |
checknote lda shtrans,x ;set transpose to current |
| 595 |
sta trans,x |
| 596 |
|
| 597 |
lda shnote,x |
| 598 |
clc ;get real (transposed) value of the note |
| 599 |
adc trans,x |
| 600 |
sta notereal,x |
| 601 |
|
| 602 |
ldy effstate,x ;skip if portamento |
| 603 |
bmi skipsetfrq |
| 604 |
!if INCLUDE_CMD_PORTA = TRUE { |
| 605 |
tay |
| 606 |
lda freqtable_lo,y |
| 607 |
sta plo,x |
| 608 |
lda freqtable_hi,y |
| 609 |
sta phi,x |
| 610 |
} |
| 611 |
|
| 612 |
txa |
| 613 |
sta shfreqlo,x |
| 614 |
lda #0 |
| 615 |
sta shfreqhi,x |
| 616 |
skipsetfrq ldy shinst,x |
| 617 |
lda inst+INS_ARP,y ;set wave pos |
| 618 |
sta wavepos,x |
| 619 |
lda shad,x ;set ADSR |
| 620 |
sta ad,x |
| 621 |
lda shsr,x |
| 622 |
sta sr,x |
| 623 |
|
| 624 |
lda inst+INS_PULSP,y ;set the pulse |
| 625 |
beq setflt |
| 626 |
!if INCLUDE_DIRECT_PULSE = TRUE { |
| 627 |
bpl skippdirect |
| 628 |
|
| 629 |
and #$0f |
| 630 |
sta pulsehi,x |
| 631 |
lda #0 |
| 632 |
sta pulselo,x |
| 633 |
jmp pulsdirset |
| 634 |
} |
| 635 |
skippdirect asl |
| 636 |
asl |
| 637 |
pulsdirset sta pulsenxt,x ;pointer |
| 638 |
lda #0 |
| 639 |
sta pulsecnt,x |
| 640 |
|
| 641 |
setflt |
| 642 |
!if INCLUDE_FILTER = TRUE { |
| 643 |
lda inst+INS_FLTP,y |
| 644 |
beq filterdone ;no filter reset |
| 645 |
skipcutdirect asl |
| 646 |
asl |
| 647 |
sta filtnxt |
| 648 |
lda #0 |
| 649 |
sta filtcnt |
| 650 |
filterdone |
| 651 |
} |
| 652 |
|
| 653 |
scmddone lda #0 |
| 654 |
sta newinsflag,x |
| 655 |
!if INCLUDE_CHORD = TRUE { |
| 656 |
sta chordvalue,x |
| 657 |
lda #$80 |
| 658 |
sta chordtpos,x |
| 659 |
} |
| 660 |
|
| 661 |
lda inst+INS_HR,y ;set wave timer |
| 662 |
and #$0f |
| 663 |
sta wavetime,x |
| 664 |
lda #0 |
| 665 |
sta wavecnt,x |
| 666 |
|
| 667 |
lda inst+INS_HR,y |
| 668 |
and #$c0 ;Check for soft |
| 669 |
cmp #$40 ;restart |
| 670 |
beq wavenotoff |
| 671 |
|
| 672 |
lda inst+INS_4,y |
| 673 |
ora #1 |
| 674 |
sta waveform,x |
| 675 |
inc hardon,x |
| 676 |
wavenotoff lda #$ff ;Gate on |
| 677 |
sta gate,x |
| 678 |
|
| 679 |
lda #$00 ;Reset sync |
| 680 |
sta synccnt,x |
| 681 |
ldy effstate,x |
| 682 |
bmi noeffreset |
| 683 |
sta effstate,x |
| 684 |
noeffreset jmp checksuper |
| 685 |
|
| 686 |
syncskip |
| 687 |
;;; ---------------------------------------- |
| 688 |
;;; pulsework |
| 689 |
;;; ---------------------------------------- |
| 690 |
updatepulse ldy pulsecur,x |
| 691 |
dec pulsecnt,x |
| 692 |
bpl pulsenotnew |
| 693 |
|
| 694 |
lda pulsenxt,x |
| 695 |
sta pulsecur,x |
| 696 |
tay |
| 697 |
lda pulstab+2,y |
| 698 |
cmp #$ff |
| 699 |
beq pulseskipset |
| 700 |
|
| 701 |
sta ZREG |
| 702 |
and #$f0 |
| 703 |
sta pulselo,x |
| 704 |
lda ZREG |
| 705 |
and #$0f |
| 706 |
sta pulsehi,x |
| 707 |
|
| 708 |
pulseskipset lda pulstab+0,y |
| 709 |
and #$7f |
| 710 |
sta pulsecnt,x |
| 711 |
|
| 712 |
lda pulstab+3,y |
| 713 |
bne pulsenotnxt |
| 714 |
lda pulsenxt,x |
| 715 |
clc |
| 716 |
adc #4 |
| 717 |
jmp pulsesetnxt |
| 718 |
pulsenotnxt cmp #$7f |
| 719 |
bne pulsenotstop |
| 720 |
lda #0 |
| 721 |
jmp pulsesetnxt |
| 722 |
pulsenotstop asl |
| 723 |
asl |
| 724 |
pulsesetnxt sta pulsenxt,x |
| 725 |
|
| 726 |
|
| 727 |
|
| 728 |
pulsenotnew lda pulstab,y |
| 729 |
bmi pulsesub |
| 730 |
|
| 731 |
lda pulselo,x |
| 732 |
clc |
| 733 |
adc pulstab+1,y |
| 734 |
sta pulselo,x |
| 735 |
bcc pulsedone |
| 736 |
inc pulsehi,x |
| 737 |
|
| 738 |
jmp pulsedone |
| 739 |
|
| 740 |
pulsesub lda pulselo,x |
| 741 |
sec |
| 742 |
sbc pulstab+1,y |
| 743 |
sta pulselo,x |
| 744 |
bcs pulsedone |
| 745 |
dec pulsehi,x |
| 746 |
pulsedone |
| 747 |
;;; ---------------------------------------- |
| 748 |
;;; sfx |
| 749 |
;;; ---------------------------------------- |
| 750 |
lda effstate,x |
| 751 |
bne effdo1 |
| 752 |
jmp effdone |
| 753 |
effdo1 |
| 754 |
!if INCLUDE_CMD_SLUP { |
| 755 |
cmp #$01 |
| 756 |
bne effdo2 |
| 757 |
|
| 758 |
effslideup lda shfreqlo,x |
| 759 |
clc |
| 760 |
adc slidelo,x |
| 761 |
sta shfreqlo,x |
| 762 |
lda shfreqhi,x |
| 763 |
adc slidehi,x |
| 764 |
sta shfreqhi,x |
| 765 |
|
| 766 |
jmp effdone |
| 767 |
} |
| 768 |
effdo2 |
| 769 |
!if INCLUDE_CMD_SLDOWN { |
| 770 |
cmp #$02 |
| 771 |
bne effdo3 |
| 772 |
|
| 773 |
effslidedown lda shfreqlo,x |
| 774 |
sec |
| 775 |
sbc slidelo,x |
| 776 |
sta shfreqlo,x |
| 777 |
lda shfreqhi,x |
| 778 |
sbc slidehi,x |
| 779 |
sta shfreqhi,x |
| 780 |
jmp effdone |
| 781 |
} |
| 782 |
effdo3 |
| 783 |
!if INCLUDE_CMD_SET_LOVIB = TRUE { |
| 784 |
cmp #$04 |
| 785 |
bne effdo3a |
| 786 |
|
| 787 |
lda vibraamp,x |
| 788 |
sta ZREG |
| 789 |
lda #0 |
| 790 |
asl ZREG |
| 791 |
rol |
| 792 |
asl ZREG |
| 793 |
rol |
| 794 |
sta ZREG+1 |
| 795 |
jmp vibrealadd |
| 796 |
} |
| 797 |
effdo3a |
| 798 |
!if INCLUDE_CMD_VIBR = FALSE { |
| 799 |
jmp effdo4 |
| 800 |
} else { |
| 801 |
|
| 802 |
;;; !if INCLUDE_CMD_VIBR = TRUE | INCLUDE_CMD_SET_LOVIB = TRUE { |
| 803 |
cmp #$03 |
| 804 |
beq effvibrato |
| 805 |
jmp effdo4 |
| 806 |
|
| 807 |
effvibrato ldy notereal,x |
| 808 |
sec |
| 809 |
lda freqtable_lo+1,y |
| 810 |
sbc freqtable_lo,y |
| 811 |
sta ZREG |
| 812 |
lda freqtable_hi+1,y |
| 813 |
sbc freqtable_hi+0,y |
| 814 |
sta ZREG+1 |
| 815 |
|
| 816 |
lda vibracor,x |
| 817 |
clc |
| 818 |
adc vibraamp,x |
| 819 |
tay |
| 820 |
lda #0 |
| 821 |
sta vibracor,x |
| 822 |
viblessamp dey |
| 823 |
bmi vibadd |
| 824 |
lsr ZREG+1 |
| 825 |
ror ZREG |
| 826 |
jmp viblessamp |
| 827 |
|
| 828 |
vibadd |
| 829 |
lda ZREG |
| 830 |
clc |
| 831 |
adc vibrafl,x |
| 832 |
sta ZREG |
| 833 |
lda ZREG+1 |
| 834 |
adc vibrafh,x |
| 835 |
sta ZREG+1 |
| 836 |
|
| 837 |
lda vibrafl,x |
| 838 |
clc |
| 839 |
adc vibraflv,x |
| 840 |
sta vibrafl,x |
| 841 |
lda vibrafh,x |
| 842 |
adc #0 |
| 843 |
sta vibrafh,x |
| 844 |
} |
| 845 |
|
| 846 |
!if INCLUDE_CMD_VIBR = TRUE | INCLUDE_CMD_SET_LOVIB = TRUE { |
| 847 |
vibrealadd lda vibradir,x |
| 848 |
and #1 |
| 849 |
bne vibradown |
| 850 |
|
| 851 |
lda shfreqlo,x |
| 852 |
clc |
| 853 |
adc ZREG |
| 854 |
sta shfreqlo,x |
| 855 |
lda shfreqhi,x |
| 856 |
adc ZREG+1 |
| 857 |
sta shfreqhi,x |
| 858 |
jmp vibrapost |
| 859 |
|
| 860 |
vibradown lda shfreqlo,x |
| 861 |
sec |
| 862 |
sbc ZREG |
| 863 |
sta shfreqlo,x |
| 864 |
lda shfreqhi,x |
| 865 |
sbc ZREG+1 |
| 866 |
sta shfreqhi,x |
| 867 |
|
| 868 |
vibrapost clc |
| 869 |
lda vibracnt,x |
| 870 |
adc #1 |
| 871 |
cmp vibrafrq,x |
| 872 |
bcc vibradirok |
| 873 |
|
| 874 |
inc vibradir,x |
| 875 |
lda #0 |
| 876 |
vibradirok sta vibracnt,x |
| 877 |
vibradone |
| 878 |
} |
| 879 |
effdo4 |
| 880 |
!if INCLUDE_CMD_PORTA = TRUE { |
| 881 |
cmp #$81 ; Portamento |
| 882 |
beq effporta |
| 883 |
jmp effdone |
| 884 |
|
| 885 |
effporta |
| 886 |
ldy notereal,x |
| 887 |
lda freqtable_lo,y |
| 888 |
sta ZREG |
| 889 |
lda freqtable_hi,y |
| 890 |
sta ZREG+1 |
| 891 |
|
| 892 |
lda plo,x |
| 893 |
sec |
| 894 |
sbc ZREG |
| 895 |
sta plo,x |
| 896 |
|
| 897 |
lda phi,x |
| 898 |
sbc ZREG+1 |
| 899 |
sta phi,x |
| 900 |
|
| 901 |
bmi portaup |
| 902 |
|
| 903 |
lda plo,x |
| 904 |
sec |
| 905 |
sbc portalo,x |
| 906 |
sta plo,x |
| 907 |
lda phi,x |
| 908 |
sbc portahi,x |
| 909 |
sta phi,x |
| 910 |
|
| 911 |
bpl portaclc |
| 912 |
|
| 913 |
jmp portaset |
| 914 |
|
| 915 |
portaup lda plo,x |
| 916 |
clc |
| 917 |
adc portalo,x |
| 918 |
sta plo,x |
| 919 |
lda phi,x |
| 920 |
adc portahi,x |
| 921 |
sta phi,x |
| 922 |
|
| 923 |
bmi portaclc |
| 924 |
|
| 925 |
portaset lda ZREG |
| 926 |
sta plo,x |
| 927 |
lda ZREG+1 |
| 928 |
sta phi,x |
| 929 |
jmp portadone |
| 930 |
portaclc lda plo,x |
| 931 |
clc |
| 932 |
adc ZREG |
| 933 |
sta plo,x |
| 934 |
lda phi,x |
| 935 |
adc ZREG+1 |
| 936 |
sta phi,x |
| 937 |
|
| 938 |
portadone ldy notereal,x |
| 939 |
lda plo,x |
| 940 |
sec |
| 941 |
sbc freqtable_lo,y |
| 942 |
sta shfreqlo,x |
| 943 |
lda phi,x |
| 944 |
sbc freqtable_hi,y |
| 945 |
sta shfreqhi,x |
| 946 |
} |
| 947 |
effdone |
| 948 |
;;; ---------------------------------------- |
| 949 |
;;; update wavetable |
| 950 |
;;; ---------------------------------------- |
| 951 |
dowave lda hardon,x |
| 952 |
beq waveok |
| 953 |
jmp wavedone |
| 954 |
|
| 955 |
waveok dec wavecnt,x |
| 956 |
bpl waveprocess |
| 957 |
|
| 958 |
lda wavetime,x |
| 959 |
sta wavecnt,x |
| 960 |
|
| 961 |
ldy wavepos,x |
| 962 |
lda arp1,y |
| 963 |
sta wavetrans,x |
| 964 |
lda arp2,y |
| 965 |
cmp #$10 |
| 966 |
bcc waveskip |
| 967 |
cmp #$e0 |
| 968 |
bcc wavereg |
| 969 |
and #$0f |
| 970 |
wavereg sta waveform,x |
| 971 |
waveskip lda arp1+1,y |
| 972 |
cmp #$7e |
| 973 |
beq wavestore |
| 974 |
iny |
| 975 |
wavenotend cmp #$7f |
| 976 |
bne wavenotend2 |
| 977 |
lda arp2,y |
| 978 |
tay |
| 979 |
wavenotend2 lda arp2,y |
| 980 |
beq wavestore |
| 981 |
cmp #$10 |
| 982 |
bcs wavestore |
| 983 |
sta wavecnt,x |
| 984 |
wavestore tya |
| 985 |
sta wavepos,x |
| 986 |
|
| 987 |
!if INCLUDE_CHORD = TRUE { |
| 988 |
ldy chordtpos,x |
| 989 |
bmi chorddone |
| 990 |
chordinit lda chord,y |
| 991 |
cmp #$40 |
| 992 |
bcc chordnotneg |
| 993 |
ora #$80 |
| 994 |
chordnotneg sta chordvalue,x |
| 995 |
inc chordtpos,x |
| 996 |
lda chord+1,y |
| 997 |
bpl chorddone |
| 998 |
and #$7f |
| 999 |
sta chordtpos,x |
| 1000 |
chorddone |
| 1001 |
} |
| 1002 |
|
| 1003 |
waveprocess lda wavetrans,x |
| 1004 |
bpl wavenotabs |
| 1005 |
waveabs and #$7f |
| 1006 |
tay |
| 1007 |
lda freqtable_lo,y |
| 1008 |
sta freqlo,x |
| 1009 |
lda freqtable_hi,y |
| 1010 |
sta freqhi,x |
| 1011 |
jmp wavedone |
| 1012 |
wavenotabs clc |
| 1013 |
adc notereal,x |
| 1014 |
!if INCLUDE_CHORD = TRUE { |
| 1015 |
adc chordvalue,x |
| 1016 |
} |
| 1017 |
tay |
| 1018 |
lda freqtable_lo,y |
| 1019 |
clc |
| 1020 |
adc shfreqlo,x |
| 1021 |
sta freqlo,x |
| 1022 |
lda freqtable_hi,y |
| 1023 |
adc shfreqhi,x |
| 1024 |
sta freqhi,x |
| 1025 |
|
| 1026 |
wavedone |
| 1027 |
;;; ------------------------------------------------------------ |
| 1028 |
checksuper lda tsync,x |
| 1029 |
cmp #$ff |
| 1030 |
beq supersync |
| 1031 |
jmp superdone |
| 1032 |
supersync lda newcmdflag,x |
| 1033 |
bne superparse |
| 1034 |
jmp superdone |
| 1035 |
|
| 1036 |
superparse lda #0 |
| 1037 |
sta newcmdflag,x |
| 1038 |
|
| 1039 |
superparse2 ldy shsuper,x |
| 1040 |
cpy #$40 |
| 1041 |
bcs *+5 |
| 1042 |
jmp iscmd |
| 1043 |
tya |
| 1044 |
cmp #$60 |
| 1045 |
bcs notpulse |
| 1046 |
|
| 1047 |
and #$1f |
| 1048 |
asl |
| 1049 |
asl |
| 1050 |
sta pulsenxt,x |
| 1051 |
lda #0 |
| 1052 |
sta pulsecnt,x |
| 1053 |
jmp superdone |
| 1054 |
|
| 1055 |
notpulse |
| 1056 |
!if INCLUDE_FILTER = TRUE { |
| 1057 |
cmp #$80 |
| 1058 |
bcs notfilt |
| 1059 |
|
| 1060 |
and #$1f |
| 1061 |
asl |
| 1062 |
asl |
| 1063 |
sta filtnxt |
| 1064 |
lda #0 |
| 1065 |
sta filtcnt |
| 1066 |
jmp superdone |
| 1067 |
|
| 1068 |
|
| 1069 |
notfilt |
| 1070 |
} |
| 1071 |
!if INCLUDE_CHORD = TRUE { |
| 1072 |
cmp #$a0 |
| 1073 |
bcs notchord |
| 1074 |
and #$1f |
| 1075 |
tay |
| 1076 |
lda chordindex,y |
| 1077 |
sta chordtpos,x |
| 1078 |
jmp superdone |
| 1079 |
} |
| 1080 |
notchord |
| 1081 |
!if INCLUDE_SEQ_SET_ATT = TRUE { |
| 1082 |
cmp #$b0 |
| 1083 |
bcs notatt |
| 1084 |
|
| 1085 |
asl |
| 1086 |
asl |
| 1087 |
asl |
| 1088 |
asl |
| 1089 |
sta ZREG |
| 1090 |
lda ad,x |
| 1091 |
and #$0f |
| 1092 |
ora ZREG |
| 1093 |
sta ad,x |
| 1094 |
jmp superdone |
| 1095 |
} |
| 1096 |
notatt |
| 1097 |
!if INCLUDE_SEQ_SET_DEC = TRUE { |
| 1098 |
cmp #$c0 |
| 1099 |
bcs notdec |
| 1100 |
|
| 1101 |
and #$0f |
| 1102 |
sta ZREG |
| 1103 |
lda ad,x |
| 1104 |
and #$f0 |
| 1105 |
ora ZREG |
| 1106 |
sta ad,x |
| 1107 |
|
| 1108 |
jmp superdone |
| 1109 |
} |
| 1110 |
notdec |
| 1111 |
!if INCLUDE_SEQ_SET_SUS = TRUE { |
| 1112 |
cmp #$d0 |
| 1113 |
bcs notsus |
| 1114 |
|
| 1115 |
asl |
| 1116 |
asl |
| 1117 |
asl |
| 1118 |
asl |
| 1119 |
sta ZREG |
| 1120 |
lda sr,x |
| 1121 |
and #$0f |
| 1122 |
ora ZREG |
| 1123 |
sta sr,x |
| 1124 |
jmp superdone |
| 1125 |
} |
| 1126 |
|
| 1127 |
notsus |
| 1128 |
!if INCLUDE_SEQ_SET_REL = TRUE { |
| 1129 |
cmp #$e0 |
| 1130 |
bcs notrel |
| 1131 |
|
| 1132 |
and #$0f |
| 1133 |
sta ZREG |
| 1134 |
lda sr,x |
| 1135 |
and #$f0 |
| 1136 |
ora ZREG |
| 1137 |
sta sr,x |
| 1138 |
jmp superdone |
| 1139 |
} |
| 1140 |
notrel |
| 1141 |
!if INCLUDE_SEQ_SET_VOL = TRUE { |
| 1142 |
cmp #$f0 |
| 1143 |
bcs notvol |
| 1144 |
|
| 1145 |
and #$0f |
| 1146 |
sta volume |
| 1147 |
jmp superdone |
| 1148 |
} |
| 1149 |
notvol |
| 1150 |
!if INCLUDE_SEQ_SET_SPEED = TRUE { |
| 1151 |
and #$0f |
| 1152 |
!if INCLUDE_SYNC = TRUE { |
| 1153 |
bne notsync |
| 1154 |
inc sync |
| 1155 |
jmp superdone |
| 1156 |
notsync |
| 1157 |
} |
| 1158 |
sta speed |
| 1159 |
!if INCLUDE_BREAKSPEED = TRUE { |
| 1160 |
cmp #2 |
| 1161 |
bcs notvol2 |
| 1162 |
lda #1 |
| 1163 |
sta speedsub |
| 1164 |
lda chord |
| 1165 |
} |
| 1166 |
notvol2 sta playspeed |
| 1167 |
sta speedcnt |
| 1168 |
dec speedcnt |
| 1169 |
} |
| 1170 |
jmp superdone |
| 1171 |
;;; ---------------------------------------- |
| 1172 |
;;; process a command table entry |
| 1173 |
;;; ---------------------------------------- |
| 1174 |
iscmd lda cmd2,y |
| 1175 |
sta ZREG |
| 1176 |
lda cmd1,y |
| 1177 |
; and #$0f |
| 1178 |
sta ZREG+1 |
| 1179 |
cmp #SUPERHIGH |
| 1180 |
bcc superlow |
| 1181 |
jmp superhigh |
| 1182 |
|
| 1183 |
;SLIDE UP |
| 1184 |
superlow |
| 1185 |
!if INCLUDE_CMD_SLUP = TRUE { |
| 1186 |
cmp #0 |
| 1187 |
bne snotslide1 |
| 1188 |
lda ZREG |
| 1189 |
sta slidehi,x |
| 1190 |
lda cmd3,y |
| 1191 |
sta slidelo,x |
| 1192 |
lda #1 |
| 1193 |
sta effstate,x |
| 1194 |
jmp superdone |
| 1195 |
|
| 1196 |
} ;SLIDE DOWN |
| 1197 |
|
| 1198 |
snotslide1 |
| 1199 |
!if INCLUDE_CMD_SLDOWN = TRUE { |
| 1200 |
cmp #CMD_SLIDE_DOWN |
| 1201 |
bne snotslide2 |
| 1202 |
lda ZREG |
| 1203 |
sta slidehi,x |
| 1204 |
lda cmd3,y |
| 1205 |
sta slidelo,x |
| 1206 |
|
| 1207 |
lda #2 |
| 1208 |
sta effstate,x |
| 1209 |
|
| 1210 |
jmp superdone |
| 1211 |
} |
| 1212 |
;VIBRATO |
| 1213 |
|
| 1214 |
snotslide2 |
| 1215 |
!if INCLUDE_CMD_VIBR = TRUE { |
| 1216 |
cmp #CMD_VIBRATO |
| 1217 |
bne snotvibrato |
| 1218 |
|
| 1219 |
lda #3 |
| 1220 |
sta effstate,x |
| 1221 |
|
| 1222 |
lda ZREG |
| 1223 |
and #$0f |
| 1224 |
sta vibraflv,x |
| 1225 |
lda cmd3,y |
| 1226 |
and #$0f |
| 1227 |
sta vibraamp,x |
| 1228 |
lda cmd3,y |
| 1229 |
lsr |
| 1230 |
lsr |
| 1231 |
lsr |
| 1232 |
lsr |
| 1233 |
clc |
| 1234 |
adc #1 |
| 1235 |
sta vibrafrq,x |
| 1236 |
lsr |
| 1237 |
bcc novibcor |
| 1238 |
|
| 1239 |
inc vibracor,x ;Correction |
| 1240 |
novibcor sta vibracnt,x |
| 1241 |
lda #0 |
| 1242 |
sta vibradir,x |
| 1243 |
sta vibrafl,x |
| 1244 |
sta vibrafh,x |
| 1245 |
} |
| 1246 |
snotvibrato jmp superdone |
| 1247 |
|
| 1248 |
superhigh |
| 1249 |
!if INCLUDE_CMD_SET_OFFSET = TRUE { |
| 1250 |
cmp #CMD_SET_OFFSET |
| 1251 |
bne snotoffset |
| 1252 |
|
| 1253 |
lda cmd2,y |
| 1254 |
sta shfreqhi,x |
| 1255 |
lda cmd3,y |
| 1256 |
sta shfreqlo,x |
| 1257 |
|
| 1258 |
jmp superdone |
| 1259 |
snotoffset |
| 1260 |
} |
| 1261 |
!if INCLUDE_CMD_SET_ADSR = TRUE { |
| 1262 |
cmp #CMD_SET_ADSR |
| 1263 |
bne snotattdec |
| 1264 |
|
| 1265 |
lda cmd2,y |
| 1266 |
sta ad,x |
| 1267 |
lda cmd3,y |
| 1268 |
sta sr,x |
| 1269 |
|
| 1270 |
jmp superdone |
| 1271 |
snotattdec |
| 1272 |
} |
| 1273 |
!if INCLUDE_CMD_SET_LOVIB { |
| 1274 |
cmp #CMD_SET_LOVIB |
| 1275 |
bne snotlovib |
| 1276 |
lda #4 |
| 1277 |
sta effstate,x |
| 1278 |
lda cmd2,y |
| 1279 |
sta vibrafrq,x |
| 1280 |
lsr |
| 1281 |
;; adc #0 |
| 1282 |
sta vibracnt,x |
| 1283 |
lda cmd3,y |
| 1284 |
sta vibraamp,x |
| 1285 |
lda #0 |
| 1286 |
sta vibradir,x |
| 1287 |
|
| 1288 |
snotlovib |
| 1289 |
} |
| 1290 |
!if INCLUDE_CMD_SET_WAVE { |
| 1291 |
cmp #CMD_SET_WAVE |
| 1292 |
bne snotwave |
| 1293 |
|
| 1294 |
lda cmd3,y |
| 1295 |
sta waveform,x |
| 1296 |
|
| 1297 |
snotwave |
| 1298 |
} |
| 1299 |
!if INCLUDE_CMD_PORTA { |
| 1300 |
cmp #CMD_STOP |
| 1301 |
bne snotstop |
| 1302 |
lda #0 |
| 1303 |
sta effstate,x |
| 1304 |
snotstop |
| 1305 |
} |
| 1306 |
superdone |
| 1307 |
;;; ---------------------------------------- |
| 1308 |
setsid ldy voice,x |
| 1309 |
lda freqlo,x |
| 1310 |
sta $d400,y |
| 1311 |
lda freqhi,x |
| 1312 |
sta $d401,y |
| 1313 |
lda sr,x |
| 1314 |
sta $d406,y |
| 1315 |
lda ad,x |
| 1316 |
sta $d405,y |
| 1317 |
lda pulselo,x |
| 1318 |
sta $d402,y |
| 1319 |
lda pulsehi,x |
| 1320 |
sta $d403,y |
| 1321 |
lda waveform,x |
| 1322 |
and gate,x |
| 1323 |
sta $d404,y |
| 1324 |
;;; ---------------------------------------- |
| 1325 |
!if MULTISPEED = TRUE { |
| 1326 |
bit state |
| 1327 |
bvc *+5 |
| 1328 |
jmp next |
| 1329 |
} |
| 1330 |
|
| 1331 |
;; check tie & super |
| 1332 |
lda tsync,x |
| 1333 |
cmp #$ff |
| 1334 |
beq postsync |
| 1335 |
jmp skippostsync |
| 1336 |
postsync dec tsync,x |
| 1337 |
|
| 1338 |
lda tienote,x |
| 1339 |
bne tiednote |
| 1340 |
jmp next |
| 1341 |
|
| 1342 |
tiednote lda shtrans,x ;check the note |
| 1343 |
sta trans,x |
| 1344 |
|
| 1345 |
lda shnote,x |
| 1346 |
beq tiestore |
| 1347 |
cmp #3 |
| 1348 |
bcc setgatestat |
| 1349 |
|
| 1350 |
clc |
| 1351 |
adc trans,x |
| 1352 |
sta notereal,x |
| 1353 |
|
| 1354 |
ldy effstate,x |
| 1355 |
bmi tieclear |
| 1356 |
|
| 1357 |
lda #0 |
| 1358 |
sta shfreqlo,x |
| 1359 |
sta shfreqhi,x |
| 1360 |
sta effstate,x |
| 1361 |
skiptiefrq jmp tiestore |
| 1362 |
|
| 1363 |
setgatestat tay |
| 1364 |
lda gatestat-1,y |
| 1365 |
sta gate,x |
| 1366 |
tieclear lda #0 |
| 1367 |
tiestore sta tienote,x |
| 1368 |
|
| 1369 |
skippostsync |
| 1370 |
|
| 1371 |
;--------------------------------------- |
| 1372 |
next dex |
| 1373 |
bmi maindone |
| 1374 |
!if EXPORT = FALSE { |
| 1375 |
bit state ; 7th bit, keyjam call |
| 1376 |
bpl *+5 |
| 1377 |
jmp updsound |
| 1378 |
|
| 1379 |
bvs *+5 ; 6th bit, multiplay call |
| 1380 |
jmp main0 |
| 1381 |
jmp syncskip |
| 1382 |
} else { |
| 1383 |
!if MULTISPEED = TRUE { |
| 1384 |
bit state |
| 1385 |
bvs *+5 |
| 1386 |
jmp main0 |
| 1387 |
jmp syncskip |
| 1388 |
} else { |
| 1389 |
|
| 1390 |
jmp main0 |
| 1391 |
} |
| 1392 |
|
| 1393 |
} |
| 1394 |
|
| 1395 |
maindone |
| 1396 |
!if MULTISPEED = TRUE | EXPORT = TRUE { |
| 1397 |
lda #0 |
| 1398 |
sta state |
| 1399 |
} |
| 1400 |
;;; ---------------------------------------- |
| 1401 |
;;; filter routine |
| 1402 |
;;; ---------------------------------------- |
| 1403 |
;;; feb '12: sweeps now in 10 bits res to allow faster sweeps |
| 1404 |
;;; ($80 in 10 bits corresponds to $20 in 8 bits) |
| 1405 |
!if INCLUDE_FILTER = TRUE { |
| 1406 |
dec filtcnt |
| 1407 |
bpl filtnotnew |
| 1408 |
lda filtnxt |
| 1409 |
filtstart sta filtcur |
| 1410 |
tay |
| 1411 |
lda filttab,y ;byte A = duration or bandpass |
| 1412 |
bpl filtsetcnt |
| 1413 |
and #$70 |
| 1414 |
sta bandpass |
| 1415 |
lda filttab+1,y |
| 1416 |
sta $d417 |
| 1417 |
lda #0 |
| 1418 |
filtsetcnt sta filtcnt |
| 1419 |
|
| 1420 |
lda filttab+1,y |
| 1421 |
and #3 |
| 1422 |
asl |
| 1423 |
sta filtadd+1 |
| 1424 |
lda filttab+1,y |
| 1425 |
cmp #$80 |
| 1426 |
ror |
| 1427 |
cmp #$80 |
| 1428 |
ror |
| 1429 |
; cmp #$80 |
| 1430 |
; ror |
| 1431 |
sta filtadd |
| 1432 |
|
| 1433 |
filtjump lda filttab+3,y ; check jump value |
| 1434 |
bne filtnotnxt |
| 1435 |
lda filtnxt |
| 1436 |
clc |
| 1437 |
adc #4 |
| 1438 |
jmp filtsetnxt |
| 1439 |
filtnotnxt cmp #$7f |
| 1440 |
bne filtnotstop |
| 1441 |
lda #0 |
| 1442 |
jmp filtsetnxt |
| 1443 |
filtnotstop asl |
| 1444 |
asl |
| 1445 |
filtsetnxt sta filtnxt |
| 1446 |
|
| 1447 |
lda filttab+2,y |
| 1448 |
cmp #$ff |
| 1449 |
beq filtnotset |
| 1450 |
sta filter |
| 1451 |
lda #0 |
| 1452 |
sta filtlo |
| 1453 |
|
| 1454 |
filtnotset |
| 1455 |
jmp filterskip |
| 1456 |
|
| 1457 |
filtnotnew lda filtadd+1 |
| 1458 |
clc |
| 1459 |
adc filtlo |
| 1460 |
cmp #8 |
| 1461 |
and #7 |
| 1462 |
sta filtlo |
| 1463 |
lda filter |
| 1464 |
adc filtadd |
| 1465 |
sta filter |
| 1466 |
|
| 1467 |
filterskip lda filtlo |
| 1468 |
sta $d415 |
| 1469 |
lda filter |
| 1470 |
sta $d416 |
| 1471 |
} |
| 1472 |
lda volume |
| 1473 |
!if INCLUDE_FILTER = TRUE { |
| 1474 |
ora bandpass |
| 1475 |
} |
| 1476 |
sta $d418 |
| 1477 |
|
| 1478 |
rts |
| 1479 |
|
| 1480 |
!if USE_MDRIVER = TRUE { |
| 1481 |
cplay dec cntr |
| 1482 |
bmi *+5 |
| 1483 |
jmp submplay |
| 1484 |
lda #MULTIPLIER |
| 1485 |
sta cntr |
| 1486 |
jmp subplay |
| 1487 |
cinit ldx #0 |
| 1488 |
stx cntr |
| 1489 |
timerlo = *+1 |
| 1490 |
ldx #<CIA_VALUE |
| 1491 |
timerhi = *+1 |
| 1492 |
ldy #>CIA_VALUE |
| 1493 |
sty $dc05 |
| 1494 |
stx $dc04 |
| 1495 |
jmp subinit |
| 1496 |
cntr !8 0 |
| 1497 |
} |
| 1498 |
|
| 1499 |
!if EXPORT = FALSE { |
| 1500 |
dummy !8 0 |
| 1501 |
} |
| 1502 |
;--------------------------------------- |
| 1503 |
freqtable_lo |
| 1504 |
!8 $16,$27,$38,$4b,$5f,$73 |
| 1505 |
!8 $8a,$a1,$ba,$d4,$f0,$0e |
| 1506 |
!8 $2d,$4e,$71,$96,$bd,$e7 |
| 1507 |
!8 $13,$42,$74,$a9,$e0,$1b |
| 1508 |
!8 $5a,$9b,$e2,$2c,$7b,$ce |
| 1509 |
!8 $27,$85,$e8,$51,$c1,$37 |
| 1510 |
!8 $b4,$37,$c4,$57,$f5,$9c |
| 1511 |
!8 $4e,$09,$d0,$a3,$82,$6e |
| 1512 |
!8 $68,$6e,$88,$af,$eb,$39 |
| 1513 |
!8 $9c,$13,$a1,$46,$04,$dc |
| 1514 |
!8 $d0,$dc,$10,$5e,$d6,$72 |
| 1515 |
!8 $38,$26,$42,$8c,$08,$b8 |
| 1516 |
!8 $a0,$b8,$20,$bc,$ac,$e4 |
| 1517 |
!8 $70,$4c,$84,$18,$10,$70 |
| 1518 |
!8 $40,$70,$40,$78,$58,$c8 |
| 1519 |
!8 $e0,$98,$08,$30,$20,$2e |
| 1520 |
freqtable_hi |
| 1521 |
!8 $01,$01,$01,$01,$01,$01 |
| 1522 |
!8 $01,$01,$01,$01,$01,$02 |
| 1523 |
!8 $02,$02,$02,$02,$02,$02 |
| 1524 |
!8 $03,$03,$03,$03,$03,$04 |
| 1525 |
!8 $04,$04,$04,$05,$05,$05 |
| 1526 |
!8 $06,$06,$06,$07,$07,$08 |
| 1527 |
!8 $08,$09,$09,$0a,$0a,$0b |
| 1528 |
!8 $0c,$0d,$0d,$0e,$0f,$10 |
| 1529 |
!8 $11,$12,$13,$14,$15,$17 |
| 1530 |
!8 $18,$1a,$1b,$1d,$1f,$20 |
| 1531 |
!8 $22,$24,$27,$29,$2b,$2e |
| 1532 |
!8 $31,$34,$37,$3a,$3e,$41 |
| 1533 |
!8 $45,$49,$4e,$52,$57,$5c |
| 1534 |
!8 $62,$68,$6e,$75,$7c,$83 |
| 1535 |
!8 $8b,$93,$9c,$a5,$af,$b9 |
| 1536 |
!8 $c4,$d0,$dd,$ea,$f8,$fd |
| 1537 |
;--------------------------------------- |
| 1538 |
;Registers |
| 1539 |
voicon !8 1,1,1 ;flags channels on and off |
| 1540 |
!if EXPORT = FALSE { |
| 1541 |
editorflag !8 0 ; set to >0 from packer |
| 1542 |
} |
| 1543 |
state !8 0 |
| 1544 |
|
| 1545 |
bits !8 %00000001 |
| 1546 |
!8 %00000010 |
| 1547 |
!8 %00000100 |
| 1548 |
|
| 1549 |
gatestat !8 $fe,$ff |
| 1550 |
voice !8 0,7,14 |
| 1551 |
|
| 1552 |
tracklo !8 0,0,0 ;track pointers low |
| 1553 |
trackhi !8 0,0,0 ;track pointers hig |
| 1554 |
twraplo !8 0,0,0 ;track wrap low |
| 1555 |
twraphi !8 0,0,0 ;track wrap high |
| 1556 |
|
| 1557 |
speed !8 0 |
| 1558 |
speedcnt !8 0 |
| 1559 |
playspeed !8 0 |
| 1560 |
|
| 1561 |
!if INCLUDE_BREAKSPEED = TRUE { |
| 1562 |
speedsub !8 0 |
| 1563 |
} |
| 1564 |
newseq !8 0,0,0 |
| 1565 |
|
| 1566 |
volume !8 $0f |
| 1567 |
|
| 1568 |
shtrans2 !8 0,0,0 |
| 1569 |
|
| 1570 |
|
| 1571 |
clrfirst ;Clear variables from here |
| 1572 |
|
| 1573 |
;;; ---------------------------------------- |
| 1574 |
;;; State variables |
| 1575 |
;;; ---------------------------------------- |
| 1576 |
newinsflag !8 0,0,0 |
| 1577 |
newcmdflag !8 0,0,0 |
| 1578 |
hardon !fi 3,0 |
| 1579 |
duration !8 0,0,0 |
| 1580 |
durcnt !8 0,0,0 |
| 1581 |
tsync !8 0,0,0 |
| 1582 |
synccnt !8 0,0,0 |
| 1583 |
tienote !8 0,0,0 |
| 1584 |
notereal !8 0,0,0 |
| 1585 |
effstate !8 0,0,0 |
| 1586 |
;; 0 = no effect |
| 1587 |
;; 1 = slide up |
| 1588 |
;; 2 = slide down |
| 1589 |
;; 3 = vibrato |
| 1590 |
;; 0x80 = portamento |
| 1591 |
|
| 1592 |
;;; ---------------------------------------- |
| 1593 |
;;; Shadow variables |
| 1594 |
;;; ---------------------------------------- |
| 1595 |
;; bit 0 = instrument was set |
| 1596 |
;; bit 1 = cmd was set |
| 1597 |
shtrans !8 0,0,0 |
| 1598 |
shnote !8 0,0,0 |
| 1599 |
shinst !8 0,0,0 |
| 1600 |
shsuper !8 0,0,0 |
| 1601 |
shad !8 0,0,0 |
| 1602 |
shsr !8 0,0,0 |
| 1603 |
shfreqlo !8 0,0,0 |
| 1604 |
shfreqhi !8 0,0,0 |
| 1605 |
freqlo !8 0,0,0 |
| 1606 |
freqhi !8 0,0,0 |
| 1607 |
trans !8 0,0,0 |
| 1608 |
gate !8 0,0,0 |
| 1609 |
|
| 1610 |
;Sequence |
| 1611 |
|
| 1612 |
curseq !8 0,0,0 |
| 1613 |
seqcnt !8 0,0,0 |
| 1614 |
|
| 1615 |
;Filter |
| 1616 |
!if INCLUDE_FILTER = TRUE { |
| 1617 |
bandpass !8 0 |
| 1618 |
filter !8 0 |
| 1619 |
filtcnt !8 0 |
| 1620 |
filtcur !8 0 |
| 1621 |
filtnxt !8 0 |
| 1622 |
filtadd !8 0,0 |
| 1623 |
filtlo !8 0 |
| 1624 |
} |
| 1625 |
;Vibration variables |
| 1626 |
!if INCLUDE_CMD_VIBR = TRUE | INCLUDE_CMD_SET_LOVIB = TRUE { |
| 1627 |
vibracnt !8 0,0,0 ;Count |
| 1628 |
vibradir !8 0,0,0 ;Direction |
| 1629 |
vibraamp !8 0,0,0 ;Amplitude |
| 1630 |
vibrafrq !8 0,0,0 ;Frequency |
| 1631 |
} |
| 1632 |
!if INCLUDE_CMD_VIBR = TRUE { |
| 1633 |
vibracor !8 0,0,0 ;Tune correction |
| 1634 |
vibrafl !8 0,0,0 ;Vibrato feel low |
| 1635 |
vibrafh !8 0,0,0 ;Vibrato feel high |
| 1636 |
vibraflv !8 0,0,0 ;Vibrato feel add |
| 1637 |
} |
| 1638 |
;Slide variables |
| 1639 |
!if INCLUDE_CMD_SLUP = TRUE | INCLUDE_CMD_SLDOWN = TRUE { |
| 1640 |
slidelo !8 0,0,0 ;Low fraction |
| 1641 |
slidehi !8 0,0,0 ;High fraction |
| 1642 |
} |
| 1643 |
;Pulse |
| 1644 |
|
| 1645 |
pulsecur !8 0,0,0 |
| 1646 |
pulsenxt !8 0,0,0 |
| 1647 |
pulsecnt !8 0,0,0 |
| 1648 |
pulselo !8 0,0,0 ;-->d402 |
| 1649 |
pulsehi !8 0,0,0 ;-->d403 |
| 1650 |
|
| 1651 |
;ADSR |
| 1652 |
|
| 1653 |
ad !8 0,0,0 ;-->d405 |
| 1654 |
sr !8 0,0,0 ;-->d406 |
| 1655 |
|
| 1656 |
;Waveform |
| 1657 |
|
| 1658 |
waveform !8 0,0,0 ;-->d404 |
| 1659 |
|
| 1660 |
;Wavetable |
| 1661 |
|
| 1662 |
wavetrans !8 0,0,0 |
| 1663 |
wavecnt !8 0,0,0 |
| 1664 |
wavepos !8 0,0,0 |
| 1665 |
wavetime !8 0,0,0 |
| 1666 |
!if INCLUDE_CHORD = TRUE { |
| 1667 |
chordtpos !8 0,0,0 |
| 1668 |
chordvalue !8 0,0,0 |
| 1669 |
} |
| 1670 |
;Portamento |
| 1671 |
!if INCLUDE_CMD_PORTA = TRUE { |
| 1672 |
portahi !8 0,0,0 |
| 1673 |
portalo !8 0,0,0 |
| 1674 |
plo !8 0,0,0 |
| 1675 |
phi !8 0,0,0 |
| 1676 |
} |
| 1677 |
clrlast ;Clear variables to here |
| 1678 |
!if EXPORT = FALSE { |
| 1679 |
*=$2000 |
| 1680 |
;--------------------------------------- |
| 1681 |
songsets !16 track1,track2,track3 |
| 1682 |
!8 5,7 |
| 1683 |
|
| 1684 |
;--------------------------------------- |
| 1685 |
*= songsets + $200 |
| 1686 |
track1 !8 $a0,$00,$f0,0 |
| 1687 |
!for .v, $1fe { |
| 1688 |
!8 $f0,00 |
| 1689 |
} |
| 1690 |
|
| 1691 |
*= track1+$0400 |
| 1692 |
track2 !8 $a0,$00,$f0,0 |
| 1693 |
!for .v, $1fe { |
| 1694 |
!8 $f0,00 |
| 1695 |
} |
| 1696 |
|
| 1697 |
*= track2+$0400 |
| 1698 |
track3 !8 $a0,$00,$f0,0 |
| 1699 |
!for .v, $1fe { |
| 1700 |
!8 $f0,00 |
| 1701 |
} |
| 1702 |
|
| 1703 |
|
| 1704 |
;--------------------------------------- |
| 1705 |
*= track3 + $400 |
| 1706 |
seqlo !fi 128, <s0 |
| 1707 |
seqhi !for .v, 128 { |
| 1708 |
!8 >s0+((.v-1)*256) |
| 1709 |
} |
| 1710 |
|
| 1711 |
;--------------------------------------- |
| 1712 |
*= seqlo+$0100 |
| 1713 |
|
| 1714 |
!macro emptyseq { |
| 1715 |
!8 $f0,$f0,$60,$00 |
| 1716 |
!8 $bf |
| 1717 |
} |
| 1718 |
|
| 1719 |
s0 +emptyseq |
| 1720 |
!set curPC = s0 |
| 1721 |
!for .v, 128-1 { |
| 1722 |
*= curPC + $100 |
| 1723 |
!set curPC = * |
| 1724 |
+emptyseq |
| 1725 |
} |
| 1726 |
;--------------------------------------- |
| 1727 |
*= curPC + $100 |
| 1728 |
arp1 !8 0 |
| 1729 |
|
| 1730 |
;--------------------------------------- |
| 1731 |
*= arp1+$0100 |
| 1732 |
arp2 !8 0 |
| 1733 |
|
| 1734 |
;--------------------------------------- |
| 1735 |
*= arp2+$0100 |
| 1736 |
inst !fi 48*8,0 |
| 1737 |
|
| 1738 |
|
| 1739 |
;;; (more or less) dynamic tables follow...... |
| 1740 |
*= inst+$0200 |
| 1741 |
supertab |
| 1742 |
cmd1 !8 $00 |
| 1743 |
*= cmd1+$40 |
| 1744 |
cmd2 !8 $0f |
| 1745 |
*= cmd2+$40 |
| 1746 |
cmd3 !8 $00 |
| 1747 |
*= cmd3+$40 |
| 1748 |
|
| 1749 |
;--------------------------------------- |
| 1750 |
|
| 1751 |
;--------------------------------------- |
| 1752 |
*= supertab+$0100 |
| 1753 |
filttab !8 $7f,$00,$ff,$7f |
| 1754 |
|
| 1755 |
;--------------------------------------- |
| 1756 |
*= filttab+$0100 |
| 1757 |
pulstab !8 $7f,$00,$ff,$7f |
| 1758 |
|
| 1759 |
*= pulstab+$0100 |
| 1760 |
chord !fi 128,0 |
| 1761 |
chordindex !fi 32,0 |
| 1762 |
} |
| 1763 |
|