mirror of
https://github.com/deater/dos33fsprogs.git
synced 2024-10-10 08:23:49 +00:00
mockingboard: add interrupt test code
This commit is contained in:
parent
bd1e2a1ffe
commit
e591dc84ea
@ -6,10 +6,11 @@ PNG2GR = ../gr-utils/png2gr
|
|||||||
all: dump_ed mock.dsk lzss_compress
|
all: dump_ed mock.dsk lzss_compress
|
||||||
|
|
||||||
mock.dsk: KSP_THEME_UNCOMPRESSED KSP_THEME_COMPRESSED \
|
mock.dsk: KSP_THEME_UNCOMPRESSED KSP_THEME_COMPRESSED \
|
||||||
KSP_THEME_INTERRUPT
|
KSP_THEME_INTERRUPT INTERRUPT_TEST
|
||||||
$(DOS33) -y mock_test.dsk BSAVE -a 0x1000 KSP_THEME_UNCOMPRESSED
|
$(DOS33) -y mock_test.dsk BSAVE -a 0x1000 KSP_THEME_UNCOMPRESSED
|
||||||
$(DOS33) -y mock_test.dsk BSAVE -a 0x1000 KSP_THEME_COMPRESSED
|
$(DOS33) -y mock_test.dsk BSAVE -a 0x1000 KSP_THEME_COMPRESSED
|
||||||
$(DOS33) -y mock_test.dsk BSAVE -a 0x1000 KSP_THEME_INTERRUPT
|
$(DOS33) -y mock_test.dsk BSAVE -a 0x1000 KSP_THEME_INTERRUPT
|
||||||
|
$(DOS33) -y mock_test.dsk BSAVE -a 0x1000 INTERRUPT_TEST
|
||||||
|
|
||||||
KSP_THEME_COMPRESSED: ksp_theme_compressed.o
|
KSP_THEME_COMPRESSED: ksp_theme_compressed.o
|
||||||
ld65 -o KSP_THEME_COMPRESSED ksp_theme_compressed.o -C ./apple2_1000.inc
|
ld65 -o KSP_THEME_COMPRESSED ksp_theme_compressed.o -C ./apple2_1000.inc
|
||||||
@ -35,6 +36,16 @@ ksp_theme_uncompressed.o: ksp_theme_uncompressed.s \
|
|||||||
../asm_routines/mockingboard.s
|
../asm_routines/mockingboard.s
|
||||||
ca65 -o ksp_theme_uncompressed.o ksp_theme_uncompressed.s -l ksp_theme_uncompressed.lst
|
ca65 -o ksp_theme_uncompressed.o ksp_theme_uncompressed.s -l ksp_theme_uncompressed.lst
|
||||||
|
|
||||||
|
|
||||||
|
INTERRUPT_TEST: interrupt_test.o
|
||||||
|
ld65 -o INTERRUPT_TEST interrupt_test.o -C ./apple2_1000.inc
|
||||||
|
|
||||||
|
interrupt_test.o: interrupt_test.s \
|
||||||
|
../asm_routines/mockingboard.s
|
||||||
|
ca65 -o interrupt_test.o interrupt_test.s -l interrupt_test.lst
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ED: duet.o
|
ED: duet.o
|
||||||
ld65 -o ED duet.o -C ./apple2_900.inc
|
ld65 -o ED duet.o -C ./apple2_900.inc
|
||||||
|
|
||||||
@ -58,5 +69,6 @@ lzss_compress: lzss_compress.o
|
|||||||
$(CC) $(LFLAGS) -o lzss_compress lzss_compress.o
|
$(CC) $(LFLAGS) -o lzss_compress lzss_compress.o
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *~ TITLE.GR *.o *.lst ED KSP_THEME_UNCOMPRESSED dump_ed
|
rm -f *~ TITLE.GR *.o *.lst ED KSP_THEME_UNCOMPRESSED \
|
||||||
|
KSP_THEME_COMPRESSED KSP_THEME_INTERRUPT INTERRUPT_TEST dump_ed
|
||||||
|
|
||||||
|
129
mockingboard/interrupt_test.s
Normal file
129
mockingboard/interrupt_test.s
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
; Test the 6522 on a Mockingboard running in interrupt mode
|
||||||
|
; Trying to set it to 50Hz
|
||||||
|
|
||||||
|
.include "zp.inc"
|
||||||
|
|
||||||
|
;=============================
|
||||||
|
; Print message
|
||||||
|
;=============================
|
||||||
|
jsr HOME
|
||||||
|
jsr TEXT
|
||||||
|
|
||||||
|
lda #0
|
||||||
|
sta DRAW_PAGE
|
||||||
|
sta CH
|
||||||
|
sta CV
|
||||||
|
lda #<mocking_message
|
||||||
|
sta OUTL
|
||||||
|
lda #>mocking_message
|
||||||
|
sta OUTH
|
||||||
|
jsr move_and_print
|
||||||
|
|
||||||
|
jsr mockingboard_detect_slot4
|
||||||
|
cpx #$1
|
||||||
|
beq mockingboard_found
|
||||||
|
|
||||||
|
lda #<not_message
|
||||||
|
sta OUTL
|
||||||
|
lda #>not_message
|
||||||
|
sta OUTH
|
||||||
|
inc CV
|
||||||
|
jsr move_and_print
|
||||||
|
|
||||||
|
jmp forever_loop
|
||||||
|
|
||||||
|
mockingboard_found:
|
||||||
|
lda #<found_message
|
||||||
|
sta OUTL
|
||||||
|
lda #>found_message
|
||||||
|
sta OUTH
|
||||||
|
inc CV
|
||||||
|
jsr move_and_print
|
||||||
|
|
||||||
|
;=========================
|
||||||
|
; 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
|
||||||
|
;============================
|
||||||
|
|
||||||
|
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
|
||||||
|
;============================
|
||||||
|
lda #64
|
||||||
|
forever_loop:
|
||||||
|
; clc
|
||||||
|
; adc #1
|
||||||
|
sta $0401
|
||||||
|
jmp forever_loop
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;=============================
|
||||||
|
; simple interrupt handler
|
||||||
|
;=============================
|
||||||
|
interrupt_handler:
|
||||||
|
lda $45 ; the Apple II firmware messes with A when
|
||||||
|
; detecting BRK, so the value in $45 is the real one?
|
||||||
|
; also DISK II support uses this so you should disable
|
||||||
|
; interrupts if messing with the disk?
|
||||||
|
|
||||||
|
pha ; save A (hardware saved Pflags for us)
|
||||||
|
|
||||||
|
bit $C404 ; can clear interrupt by reading T1C-L
|
||||||
|
|
||||||
|
|
||||||
|
inc $0410 ; increment text char on screen
|
||||||
|
|
||||||
|
pla ; restore A
|
||||||
|
rti
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;=========
|
||||||
|
;routines
|
||||||
|
;=========
|
||||||
|
.include "../asm_routines/gr_offsets.s"
|
||||||
|
.include "../asm_routines/text_print.s"
|
||||||
|
.include "../asm_routines/mockingboard.s"
|
||||||
|
|
||||||
|
;=========
|
||||||
|
; strings
|
||||||
|
;=========
|
||||||
|
mocking_message: .asciiz "LOOKING FOR MOCKINGBOARD IN SLOT #4"
|
||||||
|
not_message: .byte "NOT "
|
||||||
|
found_message: .asciiz "FOUND"
|
||||||
|
done_message: .asciiz "DONE PLAYING"
|
@ -34,14 +34,12 @@
|
|||||||
jmp forever_loop
|
jmp forever_loop
|
||||||
|
|
||||||
mockingboard_found:
|
mockingboard_found:
|
||||||
|
lda #<found_message
|
||||||
lda #<found_message
|
sta OUTL
|
||||||
sta OUTL
|
lda #>found_message
|
||||||
lda #>found_message
|
sta OUTH
|
||||||
sta OUTH
|
inc CV
|
||||||
inc CV
|
jsr move_and_print
|
||||||
jsr move_and_print
|
|
||||||
|
|
||||||
|
|
||||||
;============================
|
;============================
|
||||||
; Init the Mockingboard
|
; Init the Mockingboard
|
||||||
@ -63,8 +61,8 @@ mockingboard_found:
|
|||||||
lda #>ksptheme
|
lda #>ksptheme
|
||||||
sta INH
|
sta INH
|
||||||
|
|
||||||
ldy #0
|
|
||||||
new_frame:
|
new_frame:
|
||||||
|
ldy #0
|
||||||
lda (INL),Y ; read in frame delay
|
lda (INL),Y ; read in frame delay
|
||||||
cmp #$ff ; see if end
|
cmp #$ff ; see if end
|
||||||
beq done_play ; if so, done
|
beq done_play ; if so, done
|
||||||
@ -72,90 +70,96 @@ new_frame:
|
|||||||
tax
|
tax
|
||||||
old_frame:
|
old_frame:
|
||||||
dex ; decrement the frame diff
|
dex ; decrement the frame diff
|
||||||
bpl delay_a_bit ; if not there yet, delay
|
beq bottom_regs ; if not there yet, delay
|
||||||
|
jsr delay_50Hz
|
||||||
|
jmp old_frame
|
||||||
|
|
||||||
top_regs:
|
bottom_regs:
|
||||||
iny
|
iny
|
||||||
lda (INL),Y ; load low reg bitmask
|
lda (INL),Y ; load low reg bitmask
|
||||||
ldx #$ff
|
sta MASK
|
||||||
top_regs_loop:
|
ldx #$ff ; init to -1
|
||||||
inx
|
bottom_regs_loop:
|
||||||
cmp #$8
|
inx ; increment X
|
||||||
beq bottom_regs
|
cpx #$8 ; if we reach 8, done
|
||||||
ror
|
beq top_regs ; move on to top
|
||||||
bcc top_regs_loop
|
|
||||||
|
|
||||||
stx XX
|
ror MASK
|
||||||
sty YY
|
bcc bottom_regs_loop ; if bit not set in mask, skip reg
|
||||||
|
|
||||||
iny
|
stx XX ; save X
|
||||||
lda (INL),Y ; read in value
|
|
||||||
tax
|
|
||||||
|
|
||||||
ldy XX
|
iny ; get next output value
|
||||||
|
lda (INL),Y ; read in value
|
||||||
|
|
||||||
|
sty YY ; save Y
|
||||||
|
|
||||||
|
tax ; value in X
|
||||||
|
ldy XX ; register# in Y
|
||||||
|
|
||||||
; reg in Y, value in X
|
; reg in Y, value in X
|
||||||
jsr write_ay_left ; assume 3 channel (not six)
|
jsr write_ay_left ; assume 3 channel (not six)
|
||||||
jsr write_ay_right ; so write same to both left/write
|
jsr write_ay_right ; so write same to both left/write
|
||||||
|
|
||||||
|
ldx XX ; restore X
|
||||||
|
ldy YY ; restore Y
|
||||||
|
|
||||||
|
jmp bottom_regs_loop ; loop
|
||||||
|
|
||||||
|
top_regs:
|
||||||
|
iny ; point to next value
|
||||||
|
lda (INL),Y ; load top reg bitmask
|
||||||
|
sta MASK
|
||||||
|
ldx #$7 ; load X as 7 (we increment first)
|
||||||
|
top_regs_loop:
|
||||||
|
inx ; increment
|
||||||
|
cpx #$16
|
||||||
|
beq done_with_masks ; exit if done
|
||||||
|
|
||||||
|
ror MASK
|
||||||
|
bcc top_regs_loop ; loop if not set
|
||||||
|
|
||||||
|
stx XX ; save X value
|
||||||
|
|
||||||
|
iny ; point to value
|
||||||
|
lda (INL),Y ; read in output value
|
||||||
|
|
||||||
|
sty YY ; save Y value
|
||||||
|
|
||||||
|
tax ; value in X
|
||||||
|
ldy XX ; register in Y
|
||||||
|
|
||||||
|
; reg in Y, value in X
|
||||||
|
jsr write_ay_left ; assume 3 channel (not six)
|
||||||
|
jsr write_ay_right ; so write same to both left/write
|
||||||
|
|
||||||
ldx XX
|
ldx XX
|
||||||
ldy YY
|
ldy YY
|
||||||
|
|
||||||
jmp top_regs_loop
|
jmp top_regs_loop
|
||||||
|
|
||||||
bottom_regs:
|
done_with_masks:
|
||||||
iny
|
iny
|
||||||
lda (INL),Y ; load low reg bitmask
|
clc
|
||||||
ldx #$ff
|
tya
|
||||||
bottom_regs_loop:
|
adc INL
|
||||||
inx
|
sta INL
|
||||||
cmp #$8
|
lda #0
|
||||||
beq delay_a_bit
|
adc INH
|
||||||
ror
|
sta INH
|
||||||
bcc bottom_regs_loop
|
|
||||||
|
|
||||||
|
jsr delay_50Hz
|
||||||
|
|
||||||
stx XX
|
jmp new_frame
|
||||||
sty YY
|
|
||||||
|
|
||||||
iny
|
|
||||||
lda (INL),Y ; read in value
|
|
||||||
tax
|
|
||||||
|
|
||||||
ldy XX
|
|
||||||
|
|
||||||
; reg in Y, value in X
|
|
||||||
jsr write_ay_left ; assume 3 channel (not six)
|
|
||||||
jsr write_ay_right ; so write same to both left/write
|
|
||||||
|
|
||||||
ldx XX
|
|
||||||
ldy YY
|
|
||||||
|
|
||||||
jmp bottom_regs_loop
|
|
||||||
|
|
||||||
; reg in Y, value in X
|
|
||||||
jsr write_ay_left ; assume 3 channel (not six)
|
|
||||||
jsr write_ay_right ; so write same to both left/write
|
|
||||||
|
|
||||||
delay_a_bit:
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
jmp old_frame
|
|
||||||
done_play:
|
done_play:
|
||||||
|
|
||||||
jsr clear_ay_left
|
jsr clear_ay_left
|
||||||
jsr clear_ay_right
|
jsr clear_ay_right
|
||||||
|
|
||||||
|
|
||||||
lda #0
|
lda #0
|
||||||
sta CH
|
sta CH
|
||||||
lda #2
|
lda #3
|
||||||
sta CV
|
sta CV
|
||||||
lda #<done_message
|
lda #<done_message
|
||||||
sta OUTL
|
sta OUTL
|
||||||
@ -167,6 +171,19 @@ done_play:
|
|||||||
forever_loop:
|
forever_loop:
|
||||||
jmp 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
|
||||||
|
|
||||||
|
|
||||||
;=========
|
;=========
|
||||||
;routines
|
;routines
|
||||||
;=========
|
;=========
|
||||||
@ -182,7 +199,7 @@ forever_loop:
|
|||||||
;=========
|
;=========
|
||||||
; strings
|
; strings
|
||||||
;=========
|
;=========
|
||||||
mocking_message: .asciiz "LOOKING FOR MOCKINGBOARD IN SLOT #4: "
|
mocking_message: .asciiz "ASSUMING 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.
Loading…
Reference in New Issue
Block a user