dos33fsprogs/pt3_lib/pt3_test.s
Vince Weaver 73d9b710c7 pt3_lib: add directory with just the pt3 player
This will be less optimized than pt3_player but possibly
easier for other programs to use.
2019-06-07 15:18:51 -04:00

185 lines
3.6 KiB
ArmAsm

;=================
; VMW PT3_LIB test
;=================
; template for using the pt3_lib
; zero page definitions
.include "zp.inc"
; Location the files load at.
; If you change this, you need to update the Makefile
PT3_LOC = song
;=============================
; Setup
;=============================
pt3_setup:
jsr HOME
jsr TEXT
;===========================
; Check for Apple II/II+/IIc
;===========================
; this is used to see if we have lowecase support
lda $FBB3 ; IIe and newer is $06
cmp #6
beq apple_iie
lda #1 ; set if older than a IIe
sta apple_ii
apple_iie:
;===============
; init variables
;===============
lda #0
sta DONE_PLAYING
sta LOOP
;=======================
; Detect mockingboard
;========================
; Note, we do this, but then ignore it, as sometimes
; the test fails and then you don't get music.
; In theory this could do bad things if you had something
; easily confused in slot4, but that's probably not an issue.
; print detection message
; lda #<mocking_message ; load loading message
; sta OUTL
; lda #>mocking_message
; sta OUTH
; jsr move_and_print ; print it
jsr mockingboard_detect_slot4 ; call detection routine
cpx #$1
beq mockingboard_found
; lda #<not_message ; if not found, print that
; sta OUTL
; lda #>not_message
; sta OUTH
; inc CV
; jsr move_and_print
; jmp forever_loop ; and wait forever
mockingboard_found:
; lda #<found_message ; print found message
; sta OUTL
; lda #>found_message
; sta OUTH
; inc CV
; jsr move_and_print
;============================
; Init the Mockingboard
;============================
jsr mockingboard_init
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
;==================
jsr pt3_init_song
;============================
; Enable 6502 interrupts
;============================
start_interrupts:
cli ; clear interrupt mask
;============================
; Loop forever
;============================
main_loop:
jmp main_loop
;==============================-=========
;========================================
; Helper routines below
;========================================
;========================================
;=========
; vars
;=========
time_frame: .byte $0
apple_ii: .byte $0
;=========
;routines
;=========
.include "mockingboard_a.s"
.include "interrupt_handler.s"
.include "pt3_lib.s"
;=========
; strings
;=========
;mocking_message: .asciiz "LOOKING FOR MOCKINGBOARD IN SLOT #4"
not_message: .byte "NOT "
found_message: .asciiz "FOUND"
;done_message: .asciiz "DONE PLAYING"
;=============
; include song
;=============
.align 256 ; must be on page boundary
; this can be fixed but some changes would have
; to be made throughout the player code
song:
.incbin "../pt3_player/music/EA.PT3"