mirror of
https://github.com/deater/dos33fsprogs.git
synced 2024-10-10 08:23:49 +00:00
mockingboard: interrupt playing works now
This commit is contained in:
parent
e591dc84ea
commit
cbae19e92f
@ -95,13 +95,15 @@ forever_loop:
|
|||||||
;=============================
|
;=============================
|
||||||
; simple interrupt handler
|
; simple interrupt handler
|
||||||
;=============================
|
;=============================
|
||||||
interrupt_handler:
|
; On Apple II/6502 the interrupt handler jumps to address in 0xfffe
|
||||||
lda $45 ; the Apple II firmware messes with A when
|
; This is in the ROM, which saves the registers
|
||||||
; detecting BRK, so the value in $45 is the real one?
|
; on older IIe it saved A to $45 (which could mess with DISK II)
|
||||||
; also DISK II support uses this so you should disable
|
; newer IIe doesn't do that.
|
||||||
; interrupts if messing with the disk?
|
; 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
|
||||||
|
|
||||||
pha ; save A (hardware saved Pflags for us)
|
interrupt_handler:
|
||||||
|
pha ; save A
|
||||||
|
|
||||||
bit $C404 ; can clear interrupt by reading T1C-L
|
bit $C404 ; can clear interrupt by reading T1C-L
|
||||||
|
|
||||||
|
@ -14,6 +14,11 @@
|
|||||||
sta DRAW_PAGE
|
sta DRAW_PAGE
|
||||||
sta CH
|
sta CH
|
||||||
sta CV
|
sta CV
|
||||||
|
sta DONE_PLAYING
|
||||||
|
|
||||||
|
lda #1
|
||||||
|
sta MB_FRAME_DIFF
|
||||||
|
|
||||||
lda #<mocking_message
|
lda #<mocking_message
|
||||||
sta OUTL
|
sta OUTL
|
||||||
lda #>mocking_message
|
lda #>mocking_message
|
||||||
@ -61,21 +66,108 @@ mockingboard_found:
|
|||||||
lda #>ksptheme
|
lda #>ksptheme
|
||||||
sta INH
|
sta INH
|
||||||
|
|
||||||
new_frame:
|
|
||||||
ldy #0
|
|
||||||
lda (INL),Y ; read in frame delay
|
lda (INL),Y ; read in frame delay
|
||||||
cmp #$ff ; see if end
|
sta MB_FRAME_DIFF
|
||||||
beq done_play ; if so, done
|
inc INL ; FIXME: should check if we oflowed
|
||||||
|
|
||||||
tax
|
;=========================
|
||||||
old_frame:
|
; Setup Interrupt Handler
|
||||||
dex ; decrement the frame diff
|
;=========================
|
||||||
beq bottom_regs ; if not there yet, delay
|
; Vector address goes to 0x3fe/0x3ff
|
||||||
jsr delay_50Hz
|
; FIXME: should chain any existing handler
|
||||||
jmp old_frame
|
|
||||||
|
|
||||||
|
lda #<interrupt_handler
|
||||||
|
sta $03fe
|
||||||
|
lda #>interrupt_handler
|
||||||
|
sta $03ff
|
||||||
|
|
||||||
|
;============================
|
||||||
|
; Enable 50Hz clock on 6522
|
||||||
|
;============================
|
||||||
|
|
||||||
|
lda #$40 ; Generate 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
|
||||||
|
|
||||||
|
;============================
|
||||||
|
; Enable 6502 interrupts
|
||||||
|
;============================
|
||||||
|
;
|
||||||
|
cli ; clear interrupt mask
|
||||||
|
|
||||||
|
|
||||||
|
;============================
|
||||||
|
; Loop forever
|
||||||
|
;============================
|
||||||
|
playing_loop:
|
||||||
|
lda DONE_PLAYING
|
||||||
|
beq playing_loop
|
||||||
|
|
||||||
|
done_play:
|
||||||
|
|
||||||
|
; FIXME: disable timer on 6522
|
||||||
|
; FIXME: unhook interrupt handler
|
||||||
|
|
||||||
|
sei ; disable interrupts
|
||||||
|
|
||||||
|
jsr clear_ay_left
|
||||||
|
jsr clear_ay_right
|
||||||
|
|
||||||
|
lda #0
|
||||||
|
sta CH
|
||||||
|
lda #3
|
||||||
|
sta CV
|
||||||
|
lda #<done_message
|
||||||
|
sta OUTL
|
||||||
|
lda #>done_message
|
||||||
|
sta OUTH
|
||||||
|
jsr move_and_print
|
||||||
|
|
||||||
|
forever_loop:
|
||||||
|
jmp forever_loop
|
||||||
|
|
||||||
|
;=============================
|
||||||
|
;=============================
|
||||||
|
; simple 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
|
||||||
|
|
||||||
|
interrupt_handler:
|
||||||
|
pha ; save A
|
||||||
|
; Should we save X and Y too?
|
||||||
|
|
||||||
|
bit $C404 ; can clear 6522 interrupt by reading T1C-L
|
||||||
|
|
||||||
|
inc $0401 ; DEBUG: increment text char
|
||||||
|
|
||||||
|
dec MB_FRAME_DIFF
|
||||||
|
bne done_interrupt
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ldy #0
|
||||||
bottom_regs:
|
bottom_regs:
|
||||||
iny
|
|
||||||
lda (INL),Y ; load low reg bitmask
|
lda (INL),Y ; load low reg bitmask
|
||||||
sta MASK
|
sta MASK
|
||||||
ldx #$ff ; init to -1
|
ldx #$ff ; init to -1
|
||||||
@ -139,6 +231,16 @@ top_regs_loop:
|
|||||||
jmp top_regs_loop
|
jmp top_regs_loop
|
||||||
|
|
||||||
done_with_masks:
|
done_with_masks:
|
||||||
|
new_frame_diff:
|
||||||
|
iny
|
||||||
|
lda (INL),Y ; read in frame delay
|
||||||
|
cmp #$ff ; see if end
|
||||||
|
bne not_done ; if so, done
|
||||||
|
inc DONE_PLAYING ; set done playing flag
|
||||||
|
jmp done_interrupt
|
||||||
|
not_done:
|
||||||
|
sta MB_FRAME_DIFF
|
||||||
|
|
||||||
iny
|
iny
|
||||||
clc
|
clc
|
||||||
tya
|
tya
|
||||||
@ -148,40 +250,12 @@ done_with_masks:
|
|||||||
adc INH
|
adc INH
|
||||||
sta INH
|
sta INH
|
||||||
|
|
||||||
jsr delay_50Hz
|
done_interrupt:
|
||||||
|
pla
|
||||||
jmp new_frame
|
rti
|
||||||
|
|
||||||
done_play:
|
|
||||||
|
|
||||||
jsr clear_ay_left
|
|
||||||
jsr clear_ay_right
|
|
||||||
|
|
||||||
lda #0
|
|
||||||
sta CH
|
|
||||||
lda #3
|
|
||||||
sta CV
|
|
||||||
lda #<done_message
|
|
||||||
sta OUTL
|
|
||||||
lda #>done_message
|
|
||||||
sta OUTH
|
|
||||||
jsr move_and_print
|
|
||||||
|
|
||||||
|
|
||||||
forever_loop:
|
|
||||||
jmp forever_loop
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
delay_50Hz:
|
|
||||||
|
|
||||||
lda #86
|
|
||||||
jsr WAIT ; delay 1/2(26+27A+5A^2) us
|
|
||||||
; 50Hz = 20ms = 20000us
|
|
||||||
; 40000 = 26+27A+5A^2
|
|
||||||
; 5a^2+27a-39974 = 0
|
|
||||||
; A = 86.75
|
|
||||||
rts
|
|
||||||
|
|
||||||
|
|
||||||
;=========
|
;=========
|
||||||
@ -199,7 +273,7 @@ delay_50Hz:
|
|||||||
;=========
|
;=========
|
||||||
; strings
|
; strings
|
||||||
;=========
|
;=========
|
||||||
mocking_message: .asciiz "ASSUMING MOCKINGBOARD IN SLOT #4"
|
mocking_message: .asciiz "LOOKING FOR MOCKINGBOARD IN SLOT #4"
|
||||||
not_message: .byte "NOT "
|
not_message: .byte "NOT "
|
||||||
found_message: .asciiz "FOUND"
|
found_message: .asciiz "FOUND"
|
||||||
done_message: .asciiz "DONE PLAYING"
|
done_message: .asciiz "DONE PLAYING"
|
||||||
|
Binary file not shown.
@ -102,6 +102,8 @@ RANDOM_POINTER EQU $8F
|
|||||||
FRAME_COUNT EQU $90
|
FRAME_COUNT EQU $90
|
||||||
MB_ADDRL EQU $91
|
MB_ADDRL EQU $91
|
||||||
MB_ADDRH EQU $92
|
MB_ADDRH EQU $92
|
||||||
|
DONE_PLAYING EQU $93
|
||||||
|
MB_FRAME_DIFF EQU $94
|
||||||
|
|
||||||
SHIPY EQU $E4
|
SHIPY EQU $E4
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user