rbs: re-acquire lock

This commit is contained in:
Vince Weaver 2019-06-19 13:33:02 -04:00
parent c590879d08
commit 9e49a0e0e2
5 changed files with 227 additions and 543 deletions

View File

@ -45,7 +45,7 @@ RASTERBARS_SOUND: rasterbars_sound.o
rasterbars_sound.o: rasterbars_sound.s gr_copy.s \
rasterbars_screen.s rasterbars_table.s movement_table.s rb_bg.inc \
pt3_lib_ci.s interrupt_handler.s mockingboard_a.s
pt3_lib_ci.s mockingboard_a.s
ca65 -o rasterbars_sound.o rasterbars_sound.s -l rasterbars_sound.lst

View File

@ -1,172 +0,0 @@
;================================
;================================
; mockingboard interrupt handler
;================================
;================================
; On Apple II/6502 the interrupt handler jumps to address in 0xfffe
; This is in the ROM, which saves the registers
; on older IIe it saved A to $45 (which could mess with DISK II)
; newer IIe doesn't do that.
; It then calculates if it is a BRK or not (which trashes A)
; Then it sets up the stack like an interrupt and calls 0x3fe
; Note: the IIc is much more complicated
; its firmware tries to decode the proper source
; based on various things, including screen hole values
; we bypass that by switching out ROM and replacing the
; $fffe vector with this, but that does mean we have
; to be sure status flag and accumulator set properly
interrupt_handler:
php
pha ; save A ; 3
; A is saved in $45 by firmware
txa
pha ; save X
tya
pha ; save Y
; inc $0404 ; debug (flashes char onscreen)
bit $C404 ; clear 6522 interrupt by reading T1C-L ; 4
lda DONE_PLAYING ; 3
beq pt3_play_music ; if song done, don't play music ; 3/2nt
jmp exit_interrupt ; 3
pt3_play_music:
; decode a frame of music
jsr pt3_make_frame
; handle song over condition
lda DONE_SONG
beq mb_write_frame ; if not done, continue
lda LOOP ; see if looping
beq move_to_next
pt3_loop_smc:
lda #$d1 ; looping, move to loop location
; non-zero to avoid the temptation
; to merge with following lda #$0
sta current_pattern_smc+1
lda #$0
sta current_line_smc+1
sta current_subframe_smc+1
sta DONE_SONG ; undo the next song
beq done_interrupt ; branch always
move_to_next:
; same as "press right"
ldx #$20
jmp quiet_exit
;======================================
; Write frames to Mockingboard
;======================================
; for speed could merge this into
; the decode code
mb_write_frame:
tax ; set up reg count ; 2
;============
; 2
;==================================
; loop through the 14 registers
; reading the value, then write out
;==================================
mb_write_loop:
lda AY_REGISTERS,X ; load register value ; 4
; special case R13. If it is 0xff, then don't update
; otherwise might spuriously reset the envelope settings
cpx #13 ; 2
bne mb_not_13 ; 3/2nt
cmp #$ff ; 2
beq mb_skip_13 ; 3/2nt
;============
; typ 5
mb_not_13:
; address
stx MOCK_6522_ORA1 ; put address on PA1 ; 4
stx MOCK_6522_ORA2 ; put address on PA2 ; 4
ldy #MOCK_AY_LATCH_ADDR ; latch_address for PB1 ; 2
sty MOCK_6522_ORB1 ; latch_address on PB1 ; 4
sty MOCK_6522_ORB2 ; latch_address on PB2 ; 4
ldy #MOCK_AY_INACTIVE ; go inactive ; 2
sty MOCK_6522_ORB1 ; 4
sty MOCK_6522_ORB2 ; 4
; value
sta MOCK_6522_ORA1 ; put value on PA1 ; 4
sta MOCK_6522_ORA2 ; put value on PA2 ; 4
lda #MOCK_AY_WRITE ; ; 2
sta MOCK_6522_ORB1 ; write on PB1 ; 4
sta MOCK_6522_ORB2 ; write on PB2 ; 4
sty MOCK_6522_ORB1 ; 4
sty MOCK_6522_ORB2 ; 4
;===========
; 56
mb_no_write:
inx ; point to next register ; 2
cpx #14 ; if 14 we're done ; 2
bmi mb_write_loop ; otherwise, loop ; 3/2nt
;============
; 7
mb_skip_13:
;=================================
; Finally done with this interrupt
;=================================
done_interrupt:
exit_interrupt:
pla
tay ; restore Y
pla
tax ; restore X
pla ; restore a ; 4
; this is needed on II+/IIe not not IIc
interrupt_smc:
lda $45 ; restore A
plp
rti ; return from interrupt ; 6
;============
; typical
; ???? cycles
; stop playing for now
; quiet down the Mockingboard
; (otherwise will be stuck on last note)
quiet_exit:
stx DONE_PLAYING
jsr clear_ay_both
;ldx #$ff ; also mute the channel
stx AY_REGISTERS+7 ; just in case
jmp done_interrupt

View File

@ -242,7 +242,7 @@ mb4_not_in_this_slot:
.align $100

View File

@ -65,6 +65,8 @@ NOTE_TONE_SLIDE_TO_STEP =39
NOTE_STRUCT_SIZE=40
; All vars in zero page or SMC
note_a = $80
note_b = $80+(NOTE_STRUCT_SIZE*1)
note_c = $80+(NOTE_STRUCT_SIZE*2)
@ -72,288 +74,7 @@ note_c = $80+(NOTE_STRUCT_SIZE*2)
begin_vars=$80
end_vars=$80+(NOTE_STRUCT_SIZE*3)
.if 0
begin_vars:
note_a: ; reset?
.byte $0 ; NOTE_VOLUME ; 0 ; Y
.byte $0 ; NOTE_TONE_SLIDING_L ; 1 ; Y
.byte $0 ; NOTE_TONE_SLIDING_H ; 2 ; Y
.byte $0 ; NOTE_ENABLED ; 3 ; Y
.byte $0 ; NOTE_ENVELOPE_ENABLED ; 4 ; Y
.byte $0 ; NOTE_SAMPLE_POINTER_L ; 5 ; Y
.byte $0 ; NOTE_SAMPLE_POINTER_H ; 6 ; Y
.byte $0 ; NOTE_SAMPLE_LOOP ; 7 ; Y
.byte $0 ; NOTE_SAMPLE_LENGTH ; 8 ; Y
.byte $0 ; NOTE_TONE_L ; 9
.byte $0 ; NOTE_TONE_H ; 10
.byte $0 ; NOTE_AMPLITUDE ; 11
.byte $0 ; NOTE_NOTE ; 12
.byte $0 ; NOTE_LEN ; 13
.byte $0 ; NOTE_LEN_COUNT ; 14
.byte $0 ; NOTE_ADDR_L ; 15
.byte $0 ; NOTE_ADDR_H ; 16
.byte $0 ; NOTE_ORNAMENT_POINTER_L ; 17 ; Y
.byte $0 ; NOTE_ORNAMENT_POINTER_H ; 18 ; Y
.byte $0 ; NOTE_ORNAMENT_LOOP ; 19 ; Y
.byte $0 ; NOTE_ORNAMENT_LENGTH ; 20 ; Y
.byte $0 ; NOTE_ONOFF ; 21
.byte $0 ; NOTE_TONE_ACCUMULATOR_L ; 22
.byte $0 ; NOTE_TONE_ACCUMULATOR_H ; 23
.byte $0 ; NOTE_TONE_SLIDE_COUNT ; 24
.byte $0 ; NOTE_ORNAMENT_POSITION ; 25 ; Y
.byte $0 ; NOTE_SAMPLE_POSITION ; 26 ; Y
.byte $0 ; NOTE_ENVELOPE_SLIDING ; 27
.byte $0 ; NOTE_NOISE_SLIDING ; 28
.byte $0 ; NOTE_AMPLITUDE_SLIDING ; 29
.byte $0 ; NOTE_ONOFF_DELAY ; 30
.byte $0 ; NOTE_OFFON_DELAY ; 31
.byte $0 ; NOTE_TONE_SLIDE_STEP_L ; 32
.byte $0 ; NOTE_TONE_SLIDE_STEP_H ; 33
.byte $0 ; NOTE_TONE_SLIDE_DELAY ; 34
.byte $0 ; NOTE_SIMPLE_GLISS ; 35
.byte $0 ; NOTE_SLIDE_TO_NOTE ; 36
.byte $0 ; NOTE_TONE_DELTA_L ; 37
.byte $0 ; NOTE_TONE_DELTA_H ; 38
.byte $0 ; NOTE_TONE_SLIDE_TO_STEP ; 39
note_b:
.byte $0 ; NOTE_VOLUME
.byte $0 ; NOTE_TONE_SLIDING_L
.byte $0 ; NOTE_TONE_SLIDING_H
.byte $0 ; NOTE_ENABLED
.byte $0 ; NOTE_ENVELOPE_ENABLED
.byte $0 ; NOTE_SAMPLE_POINTER_L
.byte $0 ; NOTE_SAMPLE_POINTER_H
.byte $0 ; NOTE_SAMPLE_LOOP
.byte $0 ; NOTE_SAMPLE_LENGTH
.byte $0 ; NOTE_TONE_L
.byte $0 ; NOTE_TONE_H
.byte $0 ; NOTE_AMPLITUDE
.byte $0 ; NOTE_NOTE
.byte $0 ; NOTE_LEN
.byte $0 ; NOTE_LEN_COUNT
.byte $0 ; NOTE_ADDR_L
.byte $0 ; NOTE_ADDR_H
.byte $0 ; NOTE_ORNAMENT_POINTER_L
.byte $0 ; NOTE_ORNAMENT_POINTER_H
.byte $0 ; NOTE_ORNAMENT_LOOP
.byte $0 ; NOTE_ORNAMENT_LENGTH
.byte $0 ; NOTE_ONOFF
.byte $0 ; NOTE_TONE_ACCUMULATOR_L
.byte $0 ; NOTE_TONE_ACCUMULATOR_H
.byte $0 ; NOTE_TONE_SLIDE_COUNT
.byte $0 ; NOTE_ORNAMENT_POSITION
.byte $0 ; NOTE_SAMPLE_POSITION
.byte $0 ; NOTE_ENVELOPE_SLIDING
.byte $0 ; NOTE_NOISE_SLIDING
.byte $0 ; NOTE_AMPLITUDE_SLIDING
.byte $0 ; NOTE_ONOFF_DELAY
.byte $0 ; NOTE_OFFON_DELAY
.byte $0 ; NOTE_TONE_SLIDE_STEP_L
.byte $0 ; NOTE_TONE_SLIDE_STEP_H
.byte $0 ; NOTE_TONE_SLIDE_DELAY
.byte $0 ; NOTE_SIMPLE_GLISS
.byte $0 ; NOTE_SLIDE_TO_NOTE
.byte $0 ; NOTE_TONE_DELTA_L
.byte $0 ; NOTE_TONE_DELTA_H
.byte $0 ; NOTE_TONE_SLIDE_TO_STEP
note_c:
.byte $0 ; NOTE_VOLUME
.byte $0 ; NOTE_TONE_SLIDING_L
.byte $0 ; NOTE_TONE_SLIDING_H
.byte $0 ; NOTE_ENABLED
.byte $0 ; NOTE_ENVELOPE_ENABLED
.byte $0 ; NOTE_SAMPLE_POINTER_L
.byte $0 ; NOTE_SAMPLE_POINTER_H
.byte $0 ; NOTE_SAMPLE_LOOP
.byte $0 ; NOTE_SAMPLE_LENGTH
.byte $0 ; NOTE_TONE_L
.byte $0 ; NOTE_TONE_H
.byte $0 ; NOTE_AMPLITUDE
.byte $0 ; NOTE_NOTE
.byte $0 ; NOTE_LEN
.byte $0 ; NOTE_LEN_COUNT
.byte $0 ; NOTE_ADDR_L
.byte $0 ; NOTE_ADDR_H
.byte $0 ; NOTE_ORNAMENT_POINTER_L
.byte $0 ; NOTE_ORNAMENT_POINTER_H
.byte $0 ; NOTE_ORNAMENT_LOOP
.byte $0 ; NOTE_ORNAMENT_LENGTH
.byte $0 ; NOTE_ONOFF
.byte $0 ; NOTE_TONE_ACCUMULATOR_L
.byte $0 ; NOTE_TONE_ACCUMULATOR_H
.byte $0 ; NOTE_TONE_SLIDE_COUNT
.byte $0 ; NOTE_ORNAMENT_POSITION
.byte $0 ; NOTE_SAMPLE_POSITION
.byte $0 ; NOTE_ENVELOPE_SLIDING
.byte $0 ; NOTE_NOISE_SLIDING
.byte $0 ; NOTE_AMPLITUDE_SLIDING
.byte $0 ; NOTE_ONOFF_DELAY
.byte $0 ; NOTE_OFFON_DELAY
.byte $0 ; NOTE_TONE_SLIDE_STEP_L
.byte $0 ; NOTE_TONE_SLIDE_STEP_H
.byte $0 ; NOTE_TONE_SLIDE_DELAY
.byte $0 ; NOTE_SIMPLE_GLISS
.byte $0 ; NOTE_SLIDE_TO_NOTE
.byte $0 ; NOTE_TONE_DELTA_L
.byte $0 ; NOTE_TONE_DELTA_H
.byte $0 ; NOTE_TONE_SLIDE_TO_STEP
end_vars:
.endif
load_ornament0_sample1:
lda #0 ; 2
jsr load_ornament ; 6
; fall through
;===========================
; Load Sample
;===========================
; sample in A
; which note offset in X
; Sample table pointers are 16-bits little endian
; There are 32 of these pointers starting at $6a:$69
; Our sample starts at address (A*2)+that pointer
; We point SAMPLE_H:SAMPLE_L to this
; then we load the length/data values
; and then leave SAMPLE_H:SAMPLE_L pointing to begnning of
; the sample data
; Optimization:
; see comments on ornament setting
load_sample1:
lda #1 ; 2
load_sample:
sty TEMP ; 3
;pt3->ornament_patterns[i]=
; (pt3->data[0x6a+(i*2)]<<8)|pt3->data[0x69+(i*2)];
asl ; A*2 ; 2
tay ; 2
; Set the initial sample pointer
; a->sample_pointer=pt3->sample_patterns[a->sample];
lda PT3_LOC+PT3_SAMPLE_LOC_L,Y ; 4+
sta SAMPLE_L ; 3
lda PT3_LOC+PT3_SAMPLE_LOC_L+1,Y ; 4+
; assume pt3 file is at page boundary
adc #>PT3_LOC ; 2
sta SAMPLE_H ; 3
; Set the loop value
; a->sample_loop=pt3->data[a->sample_pointer];
ldy #0 ; 2
lda (SAMPLE_L),Y ; 5+
sta note_a+NOTE_SAMPLE_LOOP,X ; 5
; Set the length value
; a->sample_length=pt3->data[a->sample_pointer];
iny ; 2
lda (SAMPLE_L),Y ; 5+
sta note_a+NOTE_SAMPLE_LENGTH,X ; 5
; Set pointer to beginning of samples
lda SAMPLE_L ; 3
adc #$2 ; 2
sta note_a+NOTE_SAMPLE_POINTER_L,X ; 5
lda SAMPLE_H ; 3
adc #$0 ; 2
sta note_a+NOTE_SAMPLE_POINTER_H,X ; 5
ldy TEMP ; 3
rts ; 6
;============
; 76
;===========================
; Load Ornament
;===========================
; ornament value in A
; note offset in X
; Ornament table pointers are 16-bits little endian
; There are 16 of these pointers starting at $aa:$a9
; Our ornament starts at address (A*2)+that pointer
; We point ORNAMENT_H:ORNAMENT_L to this
; then we load the length/data values
; and then leave ORNAMENT_H:ORNAMENT_L pointing to begnning of
; the ornament data
; Optimization:
; Loop and length only used once, can be located negative
; from the pointer, but 6502 doesn't make addressing like that
; easy. Can't self modify as channels A/B/C have own copies
; of the var.
load_ornament:
sty TEMP ; save Y value ; 3
;pt3->ornament_patterns[i]=
; (pt3->data[0xaa+(i*2)]<<8)|pt3->data[0xa9+(i*2)];
asl ; A*2 ; 2
tay ; 2
; a->ornament_pointer=pt3->ornament_patterns[a->ornament];
lda PT3_LOC+PT3_ORNAMENT_LOC_L,Y ; 4+
sta ORNAMENT_L ; 3
lda PT3_LOC+PT3_ORNAMENT_LOC_L+1,Y ; 4+
; we're assuming PT3 is loaded to a page boundary
adc #>PT3_LOC ; 2
sta ORNAMENT_H ; 3
lda #0 ; 2
sta note_a+NOTE_ORNAMENT_POSITION,X ; 5
tay ; 2
; Set the loop value
; a->ornament_loop=pt3->data[a->ornament_pointer];
lda (ORNAMENT_L),Y ; 5+
sta note_a+NOTE_ORNAMENT_LOOP,X ; 5
; Set the length value
; a->ornament_length=pt3->data[a->ornament_pointer];
iny ; 2
lda (ORNAMENT_L),Y ; 5+
sta note_a+NOTE_ORNAMENT_LENGTH,X ; 5
; Set the pointer to the value past the length
lda ORNAMENT_L ; 3
adc #$2 ; 2
sta note_a+NOTE_ORNAMENT_POINTER_L,X ; 5
lda ORNAMENT_H ; 3
adc #$0 ; 2
sta note_a+NOTE_ORNAMENT_POINTER_H,X ; 5
ldy TEMP ; restore Y value ; 3
rts ; 6
;============
; 83
@ -570,6 +291,184 @@ vol_done:
;========================================================================
;========================================================================
;========================================================================
;========================================================================
;========================================================================
; EVERYTHING AFTER THIS IS CYCLE COUNTED
;========================================================================
;========================================================================
;========================================================================
;========================================================================
;========================================================================
.align $100
;===========================
; Load Ornament 0/Sample 1
;===========================
load_ornament0_sample1:
lda #0 ; 2
jsr load_ornament ; 6
; fall through
;===========================
; Load Sample
;===========================
; sample in A
; which note offset in X
; Sample table pointers are 16-bits little endian
; There are 32 of these pointers starting at $6a:$69
; Our sample starts at address (A*2)+that pointer
; We point SAMPLE_H:SAMPLE_L to this
; then we load the length/data values
; and then leave SAMPLE_H:SAMPLE_L pointing to begnning of
; the sample data
; Optimization:
; see comments on ornament setting
load_sample1:
lda #1 ; 2
load_sample:
sty TEMP ; 3
;pt3->ornament_patterns[i]=
; (pt3->data[0x6a+(i*2)]<<8)|pt3->data[0x69+(i*2)];
asl ; A*2 ; 2
tay ; 2
; Set the initial sample pointer
; a->sample_pointer=pt3->sample_patterns[a->sample];
lda PT3_LOC+PT3_SAMPLE_LOC_L,Y ; 4+
sta SAMPLE_L ; 3
lda PT3_LOC+PT3_SAMPLE_LOC_L+1,Y ; 4+
; assume pt3 file is at page boundary
adc #>PT3_LOC ; 2
sta SAMPLE_H ; 3
; Set the loop value
; a->sample_loop=pt3->data[a->sample_pointer];
ldy #0 ; 2
lda (SAMPLE_L),Y ; 5+
sta note_a+NOTE_SAMPLE_LOOP,X ; 5
; Set the length value
; a->sample_length=pt3->data[a->sample_pointer];
iny ; 2
lda (SAMPLE_L),Y ; 5+
sta note_a+NOTE_SAMPLE_LENGTH,X ; 5
; Set pointer to beginning of samples
lda SAMPLE_L ; 3
adc #$2 ; 2
sta note_a+NOTE_SAMPLE_POINTER_L,X ; 5
lda SAMPLE_H ; 3
adc #$0 ; 2
sta note_a+NOTE_SAMPLE_POINTER_H,X ; 5
ldy TEMP ; 3
rts ; 6
;============
; 76
;===========================
; Load Ornament
;===========================
; ornament value in A
; note offset in X
; Ornament table pointers are 16-bits little endian
; There are 16 of these pointers starting at $aa:$a9
; Our ornament starts at address (A*2)+that pointer
; We point ORNAMENT_H:ORNAMENT_L to this
; then we load the length/data values
; and then leave ORNAMENT_H:ORNAMENT_L pointing to begnning of
; the ornament data
; Optimization:
; Loop and length only used once, can be located negative
; from the pointer, but 6502 doesn't make addressing like that
; easy. Can't self modify as channels A/B/C have own copies
; of the var.
load_ornament:
sty TEMP ; save Y value ; 3
;pt3->ornament_patterns[i]=
; (pt3->data[0xaa+(i*2)]<<8)|pt3->data[0xa9+(i*2)];
asl ; A*2 ; 2
tay ; 2
; a->ornament_pointer=pt3->ornament_patterns[a->ornament];
lda PT3_LOC+PT3_ORNAMENT_LOC_L,Y ; 4+
sta ORNAMENT_L ; 3
lda PT3_LOC+PT3_ORNAMENT_LOC_L+1,Y ; 4+
; we're assuming PT3 is loaded to a page boundary
adc #>PT3_LOC ; 2
sta ORNAMENT_H ; 3
lda #0 ; 2
sta note_a+NOTE_ORNAMENT_POSITION,X ; 5
tay ; 2
; Set the loop value
; a->ornament_loop=pt3->data[a->ornament_pointer];
lda (ORNAMENT_L),Y ; 5+
sta note_a+NOTE_ORNAMENT_LOOP,X ; 5
; Set the length value
; a->ornament_length=pt3->data[a->ornament_pointer];
iny ; 2
lda (ORNAMENT_L),Y ; 5+
sta note_a+NOTE_ORNAMENT_LENGTH,X ; 5
; Set the pointer to the value past the length
lda ORNAMENT_L ; 3
adc #$2 ; 2
sta note_a+NOTE_ORNAMENT_POINTER_L,X ; 5
lda ORNAMENT_H ; 3
adc #$0 ; 2
sta note_a+NOTE_ORNAMENT_POINTER_H,X ; 5
ldy TEMP ; restore Y value ; 3
rts ; 6
;============
; 83
@ -579,8 +478,11 @@ vol_done:
;=====================================
; note offset in X
; 6+48 = 54
calculate_note:
.if 0
lda note_a+NOTE_ENABLED,X ; 4+
bne note_enabled ; 2/3
@ -664,32 +566,35 @@ note_not_too_high:
; w = GetNoteFreq(j,pt3->frequency_table);
jsr GetNoteFreq
.endif
; a->tone = (a->tone + a->tone_sliding + w) & 0xfff;
clc
ldy note_a+NOTE_TONE_SLIDING_L,X
tya
adc note_a+NOTE_TONE_L,X
clc ; 2
ldy note_a+NOTE_TONE_SLIDING_L,X ; 4
tya ; 2
adc note_a+NOTE_TONE_L,X ; 4
sta temp_word_l1_smc+1
lda note_a+NOTE_TONE_H,X
adc note_a+NOTE_TONE_SLIDING_H,X
sta temp_word_h1_smc+1
sta temp_word_l1_smc+1 ; 4
lda note_a+NOTE_TONE_H,X ; 4
adc note_a+NOTE_TONE_SLIDING_H,X ; 4
sta temp_word_h1_smc+1 ; 4
clc ;;can be removed if ADC SLIDING_H cannot overflow
clc ;;can be removed if ADC SLIDING_H cannot overflow ; 2
temp_word_l1_smc:
lda #$d1
lda #$d1 ; 2
freq_l_smc:
adc #$d1
sta note_a+NOTE_TONE_L,X
adc #$d1 ; 2
sta note_a+NOTE_TONE_L,X ; 4
temp_word_h1_smc:
lda #$d1
lda #$d1 ; 2
freq_h_smc:
adc #$d1
and #$0f
sta note_a+NOTE_TONE_H,X
adc #$d1 ; 2
and #$0f ; 2
sta note_a+NOTE_TONE_H,X ; 4
;===========
; 48
.if 0
;=====================
; handle tone sliding
@ -1023,6 +928,8 @@ do_offon:
put_offon:
sty note_a+NOTE_ONOFF,X
.endif
done_onoff:
rts ; 6
@ -1783,7 +1690,7 @@ not_done:
; update pattern or line if necessary
; then calculate the values for the next frame
; 8+???
; 8+355=363
;==========================
; pattern done early!
@ -1869,7 +1776,7 @@ next_pattern:
; ????? FIXME/calculate note
;
; 9+36+11+18+30+18+49 = 171
; 9+ 184 + 36+11+18+30+18+49 = 355
do_frame:
; AY-3-8910 register summary
@ -1889,16 +1796,16 @@ do_frame:
stx pt3_envelope_add_smc+1 ; 4
;===========
; 9
.if 0
;;ldx #(NOTE_STRUCT_SIZE*0) ; Note A ; 2
jsr calculate_note ; 6+?
;;ldx #(NOTE_STRUCT_SIZE*0) ; Note A
jsr calculate_note ; 6+54
ldx #(NOTE_STRUCT_SIZE*1) ; Note B ; 2
jsr calculate_note ; 6+?
jsr calculate_note ; 6+54
ldx #(NOTE_STRUCT_SIZE*2) ; Note C ; 2
jsr calculate_note ; 6+?
jsr calculate_note ; 6+54
;=============
; FIXME
.endif
; FIXME 184
; Note, we assume 1MHz timings, adjust pt3 as needed
; Load up the Frequency Registers

View File

@ -57,21 +57,6 @@ apple_iic:
sta $C403
sta $C404
; bypass the firmware interrupt handler
; should we do this on IIe too? probably faster
; sei ; disable interrupts
; lda $c08b ; disable ROM (enable language card)
; lda $c08b
; lda #<interrupt_handler
; sta $fffe
; lda #>interrupt_handler
; sta $ffff
; lda #$EA ; nop out the "lda $45" in the irq hand
; sta interrupt_smc
; sta interrupt_smc+1
done_apple_detect:
;=======================
@ -120,42 +105,6 @@ mockingboard_found:
jsr reset_ay_both
jsr clear_ay_both
;=========================
; Setup Interrupt Handler
;=========================
; Vector address goes to 0x3fe/0x3ff
; FIXME: should chain any existing handler
; lda #<interrupt_handler
; sta $03fe
; lda #>interrupt_handler
; sta $03ff
;============================
; Enable 50Hz clock on 6522
;============================
sei ; disable interrupts just in case
lda #$40 ; Continuous interrupts, don't touch PB7
sta $C40B ; ACR register
lda #$7F ; clear all interrupt flags
sta $C40E ; IER register (interrupt enable)
lda #$C0
sta $C40D ; IFR: 1100, enable interrupt on timer one oflow
sta $C40E ; IER: 1100, enable timer one interrupt
lda #$E7
sta $C404 ; write into low-order latch
lda #$4f
sta $C405 ; write into high-order latch,
; load both values into counter
; clear interrupt and start counting
; 4fe7 / 1e6 = .020s, 50Hz
;==================
; init song
;==================
@ -288,10 +237,10 @@ display_loop:
; -582 -- erase 22+4*(8+6+126) = 582
; -696 -- move+draw 4*(16+26+6+126) = 696
; -10 -- keypress
; -185 -- calc values
; -369 -- calc values
; -997 -- mockingboard out
;=======
; 2080
; 1896
pad_time:
@ -464,23 +413,25 @@ pad_time:
;============================
jsr pt3_make_frame ; 6+179
jsr mb_write_frame ; 6+921
jsr pt3_make_frame ; 6+363 = 369
jsr mb_write_frame ; 6+991 = 997
;============================
; WAIT for VBLANK to finish
;============================
; Try X=45 Y=9 cycles=2080
; Try X=125 Y=3 cycles=1894R2
ldy #9 ; 2
loop1: ldx #45 ; 2
nop
ldy #3 ; 2
loop1: ldx #125 ; 2
loop2: dex ; 2
bne loop2 ; 2nt/3
dey ; 2
bne loop1 ; 2nt/3
wait_loop_end:
lda KEYPRESS ; 4
bpl no_keypress ; 3
@ -489,7 +440,7 @@ no_keypress:
jmp display_loop ; 3
.assert >loop1 = >(wait_loop_end-1), error, "wait_loop crosses page"
@ -586,7 +537,6 @@ yellow_x: .byte $20
green_x: .byte $30
blue_x: .byte $40
;.include "interrupt_handler.s"
.include "pt3_lib_ci.s"
.include "mockingboard_a.s"
@ -598,4 +548,3 @@ blue_x: .byte $40
; to be made throughout the player code
song:
.incbin "../pt3_player/music/EA.PT3"