2019-05-07 00:31:10 +00:00
|
|
|
;================================
|
|
|
|
;================================
|
|
|
|
; 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
|
|
|
|
|
2019-06-07 20:56:41 +00:00
|
|
|
; 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
|
|
|
|
|
|
|
|
|
2019-06-09 04:58:00 +00:00
|
|
|
TIME_OFFSET = 13
|
2019-05-07 00:31:10 +00:00
|
|
|
|
|
|
|
interrupt_handler:
|
2019-06-07 20:52:31 +00:00
|
|
|
php
|
|
|
|
pha ; save A ; 3
|
2019-05-07 00:31:10 +00:00
|
|
|
; A is saved in $45 by firmware
|
|
|
|
txa
|
|
|
|
pha ; save X
|
|
|
|
tya
|
|
|
|
pha ; save Y
|
|
|
|
|
2019-09-11 20:08:36 +00:00
|
|
|
; inc $0404 ; debug (flashes char onscreen)
|
2019-05-07 00:31:10 +00:00
|
|
|
|
|
|
|
|
2019-09-11 20:08:36 +00:00
|
|
|
.include "pt3_lib_irq_handler.s"
|
2019-05-07 00:31:10 +00:00
|
|
|
|
2019-09-11 20:08:36 +00:00
|
|
|
;==============================================
|
|
|
|
; only update time counter if not done playing
|
|
|
|
;==============================================
|
2019-05-07 00:31:10 +00:00
|
|
|
|
2019-05-07 15:51:47 +00:00
|
|
|
lda DONE_PLAYING ; 3
|
2019-09-11 20:08:36 +00:00
|
|
|
bne check_keyboard
|
2019-05-07 00:31:10 +00:00
|
|
|
|
|
|
|
;=====================
|
|
|
|
; Update time counter
|
|
|
|
;=====================
|
2019-05-17 16:25:37 +00:00
|
|
|
; self-modifying version via qkumba
|
2019-05-07 00:31:10 +00:00
|
|
|
update_time:
|
2019-05-17 16:25:37 +00:00
|
|
|
inc frame_count_smc+1 ; 5
|
|
|
|
frame_count_smc:
|
|
|
|
lda #$0 ; 2
|
2019-06-01 04:03:14 +00:00
|
|
|
eor #50 ; 3
|
2019-05-07 00:31:10 +00:00
|
|
|
bne done_time ; 3/2nt
|
|
|
|
|
2019-05-17 16:25:37 +00:00
|
|
|
sta frame_count_smc+1 ; 3
|
2019-05-07 00:31:10 +00:00
|
|
|
|
2019-06-09 04:53:49 +00:00
|
|
|
ldx $7d0+TIME_OFFSET+3 ; 4
|
|
|
|
cpx #'9'+$80 ; 2
|
|
|
|
bne update_second_ones ; 3/2nt
|
|
|
|
|
|
|
|
ldx $7d0+TIME_OFFSET+2 ; 4
|
|
|
|
cpx #'5'+$80 ; 6-1 (for 60 seconds) ; 2
|
|
|
|
bne update_second_tens ; 3/2nt
|
|
|
|
|
2019-05-07 00:31:10 +00:00
|
|
|
update_minutes:
|
|
|
|
inc $7d0+TIME_OFFSET ; 6
|
|
|
|
inc $bd0+TIME_OFFSET ; 6
|
2019-06-09 04:53:49 +00:00
|
|
|
|
|
|
|
ldx #'0'+$80-1 ; 2
|
|
|
|
|
|
|
|
update_second_tens:
|
|
|
|
inx ; 2
|
|
|
|
stx $7d0+TIME_OFFSET+2 ; 4
|
|
|
|
stx $bd0+TIME_OFFSET+2 ; 4
|
|
|
|
|
|
|
|
ldx #'0'+$80-1 ; 2
|
|
|
|
|
|
|
|
update_second_ones:
|
|
|
|
inx ; 2
|
|
|
|
stx $7d0+TIME_OFFSET+3 ; 4
|
|
|
|
stx $bd0+TIME_OFFSET+3 ; 4
|
2019-05-07 00:31:10 +00:00
|
|
|
; we don't handle > 9:59 songs yet
|
|
|
|
done_time:
|
|
|
|
;=============
|
2019-06-09 04:53:49 +00:00
|
|
|
; 52 worst
|
2019-05-07 00:31:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
;=================================
|
2019-05-17 16:29:28 +00:00
|
|
|
; Handle keyboard
|
2019-05-07 00:31:10 +00:00
|
|
|
;=================================
|
|
|
|
|
|
|
|
check_keyboard:
|
|
|
|
|
|
|
|
jsr get_key
|
2019-06-09 04:53:49 +00:00
|
|
|
tax
|
2019-05-07 00:31:10 +00:00
|
|
|
beq exit_interrupt
|
|
|
|
|
2019-05-17 16:29:28 +00:00
|
|
|
;====================
|
|
|
|
; space pauses
|
|
|
|
|
2019-06-01 04:03:14 +00:00
|
|
|
cmp #(' '+$80) ; set carry if true
|
2019-05-17 02:16:50 +00:00
|
|
|
bne key_M
|
2019-05-07 00:31:10 +00:00
|
|
|
key_space:
|
|
|
|
lda #$80
|
|
|
|
eor DONE_PLAYING
|
2019-05-16 20:42:01 +00:00
|
|
|
|
2019-05-17 16:29:28 +00:00
|
|
|
; disable fire when paused
|
|
|
|
|
2019-05-16 20:42:01 +00:00
|
|
|
sta DONE_PLAYING
|
|
|
|
beq yes_bar
|
|
|
|
lda #0
|
2019-06-01 04:03:14 +00:00
|
|
|
beq lowbar ; branch always
|
2019-05-16 20:42:01 +00:00
|
|
|
yes_bar:
|
|
|
|
lda #7
|
|
|
|
lowbar:
|
|
|
|
jsr fire_setline
|
|
|
|
|
2019-06-02 02:09:41 +00:00
|
|
|
ldx DONE_PLAYING
|
2019-05-16 20:42:01 +00:00
|
|
|
|
2019-06-01 04:03:14 +00:00
|
|
|
bcs quiet_exit ; branch always
|
2019-05-07 00:31:10 +00:00
|
|
|
|
2019-05-17 16:29:28 +00:00
|
|
|
;===========================
|
|
|
|
; M key switches MHz mode
|
|
|
|
|
2019-05-17 02:16:50 +00:00
|
|
|
key_M:
|
|
|
|
cmp #'M'
|
2019-06-02 02:09:41 +00:00
|
|
|
bne key_L ; set carry if true
|
2019-05-07 00:31:10 +00:00
|
|
|
|
2019-06-02 02:09:41 +00:00
|
|
|
ldx #'0'+$80
|
2019-06-03 02:57:21 +00:00
|
|
|
lda convert_177_smc1
|
|
|
|
eor #$20
|
|
|
|
sta convert_177_smc1
|
|
|
|
sta convert_177_smc2
|
|
|
|
sta convert_177_smc3
|
|
|
|
sta convert_177_smc4
|
|
|
|
sta convert_177_smc5
|
|
|
|
cmp #$18
|
2019-06-02 02:09:41 +00:00
|
|
|
beq at_MHz
|
2019-05-17 02:16:50 +00:00
|
|
|
|
2019-05-17 16:29:28 +00:00
|
|
|
; update text on screen
|
|
|
|
|
2019-06-02 02:09:41 +00:00
|
|
|
ldx #'7'+$80
|
2019-05-17 02:16:50 +00:00
|
|
|
|
2019-06-02 02:09:41 +00:00
|
|
|
at_MHz:
|
|
|
|
stx $7F4
|
|
|
|
stx $BF4
|
2019-05-17 02:16:50 +00:00
|
|
|
|
2019-06-02 02:09:41 +00:00
|
|
|
bcs done_key ; branch always
|
2019-05-07 00:31:10 +00:00
|
|
|
|
2019-05-17 17:19:04 +00:00
|
|
|
|
|
|
|
;===========================
|
|
|
|
; L enables loop mode
|
|
|
|
|
|
|
|
key_L:
|
|
|
|
cmp #'L'
|
2019-06-02 02:09:41 +00:00
|
|
|
bne key_left ; set carry if true
|
2019-05-17 17:19:04 +00:00
|
|
|
|
2019-06-02 02:09:41 +00:00
|
|
|
ldx #'/'+$80
|
2019-05-17 17:19:04 +00:00
|
|
|
lda LOOP
|
|
|
|
eor #$1
|
|
|
|
sta LOOP
|
|
|
|
beq music_looping
|
|
|
|
|
|
|
|
; update text on screen
|
|
|
|
|
2019-06-02 02:09:41 +00:00
|
|
|
ldx #'L'+$80
|
2019-05-17 17:19:04 +00:00
|
|
|
|
|
|
|
music_looping:
|
2019-06-02 04:51:34 +00:00
|
|
|
stx $7D0+18
|
|
|
|
stx $BD0+18
|
2019-05-17 17:19:04 +00:00
|
|
|
|
2019-06-02 02:09:41 +00:00
|
|
|
bcs done_key ; branch always
|
2019-05-17 17:19:04 +00:00
|
|
|
|
|
|
|
|
2019-05-17 16:29:28 +00:00
|
|
|
;======================
|
2019-05-17 17:21:45 +00:00
|
|
|
; left key, to prev song
|
2019-05-17 16:29:28 +00:00
|
|
|
|
2019-05-07 00:31:10 +00:00
|
|
|
key_left:
|
2019-06-02 02:09:41 +00:00
|
|
|
ldx #$40
|
2019-05-07 00:31:10 +00:00
|
|
|
cmp #'A'
|
2019-06-02 02:09:41 +00:00
|
|
|
beq quiet_exit
|
2019-05-07 00:31:10 +00:00
|
|
|
|
2019-05-17 16:29:28 +00:00
|
|
|
;========================
|
2019-05-17 17:21:45 +00:00
|
|
|
; right key, to next song
|
2019-05-17 16:29:28 +00:00
|
|
|
|
2019-05-07 00:31:10 +00:00
|
|
|
key_right:
|
2019-06-02 02:09:41 +00:00
|
|
|
ldx #$20
|
2019-05-07 00:31:10 +00:00
|
|
|
cmp #'D'
|
|
|
|
bne done_key
|
|
|
|
|
2019-05-17 16:29:28 +00:00
|
|
|
;========================
|
|
|
|
; stop playing for now
|
|
|
|
; quiet down the Mockingboard
|
|
|
|
; (otherwise will be stuck on last note)
|
|
|
|
|
2019-05-07 00:31:10 +00:00
|
|
|
quiet_exit:
|
2019-06-02 02:09:41 +00:00
|
|
|
stx DONE_PLAYING
|
2019-05-07 00:31:10 +00:00
|
|
|
jsr clear_ay_both
|
|
|
|
|
2019-06-02 02:09:41 +00:00
|
|
|
;ldx #$ff ; also mute the channel
|
|
|
|
stx AY_REGISTERS+7 ; just in case
|
2019-05-17 17:19:04 +00:00
|
|
|
|
2019-06-01 04:03:14 +00:00
|
|
|
done_key:
|
2019-05-07 00:31:10 +00:00
|
|
|
exit_interrupt:
|
|
|
|
|
|
|
|
pla
|
|
|
|
tay ; restore Y
|
|
|
|
pla
|
|
|
|
tax ; restore X
|
2019-06-07 20:52:31 +00:00
|
|
|
|
|
|
|
pla ; restore a ; 4
|
|
|
|
|
|
|
|
; this is needed on II+/IIe not not IIc
|
|
|
|
interrupt_smc:
|
2019-05-07 00:31:10 +00:00
|
|
|
lda $45 ; restore A
|
2019-06-07 20:52:31 +00:00
|
|
|
plp
|
2019-05-07 00:31:10 +00:00
|
|
|
|
|
|
|
rti ; return from interrupt ; 6
|
|
|
|
|
|
|
|
;============
|
|
|
|
; typical
|
|
|
|
; ???? cycles
|
|
|
|
|
|
|
|
|