#include "../../build/memory.inc" #include "../../bios.inc" #include "../../hardware.inc" CTC_BASE .equ 020h CTC_CHANNEL_0 .equ CTC_BASE+000h CTC_CHANNEL_1 .equ CTC_BASE+001h CTC_CHANNEL_2 .equ CTC_BASE+002h CTC_CHANNEL_3 .equ CTC_BASE+003h RAM_TOP .equ 0xbfff ; workspace variables here vv ; ------------------------ ^^ SAVED_SP .equ RAM_TOP-0x02 ; word STACK_TOP .equ RAM_TOP-0x100 ; ------------------------------------------------------- ; Entry ; ------------------------------------------------------- .org SN76489_ROM_START push bc push de push hl ld hl, 0 add hl, sp ; get sp ld (SAVED_SP), hl ; save sp for later ld hl, STACK_TOP ld sp, hl ; use own stack ld hl,str_header call BIOS_PUTS ld hl,SHARED_MEM_START+042h ld bc, ctc_interrupt ; install own ctc isr ld (hl), bc di call PSGInit ; Initialize psglib ld a,10100111b ; interrupts enabled ; timer mode ; prescaler 256 ; automatic trigger ; time constant follows ; reset ; control word out (CTC_CHANNEL_1), a ld a,78 ; 50Hz out (CTC_CHANNEL_1), a ; music must be loaded from 8000 ld hl, 0x8000 call PSGPlayNoRepeat ei exit: ld hl, (SAVED_SP) ld sp, hl ; restore original stack pop hl pop de pop bc ret ; ------------------------------------------------------- ; CTC CHAN 1 interrupt handler ; ------------------------------------------------------- ctc_interrupt: push af push bc push de push hl call PSGFrame pop hl pop de pop bc pop af reti ; ------------------------------------------------------- ; Strings ; ------------------------------------------------------- str_header: .db "SN76489 test",00dh,00ah,000h #include "psglib_zasm.asm"