11d6 INCLUDE KEYB.MAC INCLUDE SCREEN.MAC CSEG SEGMENT ASSUME CS:CSEG,DS:CSEG ORG 100h start: jmp begin stackspace db 32 dup ('STACK ') newstack dw 0 cmf_off dw ? cmf_seg dw ? fm_status db 0 inst_table: db 22h,11h,4ch,00h,0f2h,0f2h,63h,7dh, 00h,00h,04h,00h,00h,00h,00h,00h db 22h,11h,4ch,00h,0f2h,0f2h,63h,7dh, 00h,00h,04h,00h,00h,00h,00h,00h db 22h,11h,4ch,00h,0f2h,0f2h,63h,7dh, 00h,00h,04h,00h,00h,00h,00h,00h db 22h,11h,4ch,00h,0f2h,0f2h,63h,7dh, 00h,00h,04h,00h,00h,00h,00h,00h db 22h,11h,4ch,00h,0f2h,0f2h,63h,7dh, 00h,00h,04h,00h,00h,00h,00h,00h db 22h,11h,4ch,00h,0f2h,0f2h,63h,7dh, 00h,00h,04h,00h,00h,00h,00h,00h db 22h,11h,4ch,00h,0f2h,0f2h,63h,7dh, 00h,00h,04h,00h,00h,00h,00h,00h db 22h,11h,4ch,00h,0f2h,0f2h,63h,7dh, 00h,00h,04h,00h,00h,00h,00h,00h db 22h,11h,4ch,00h,0f2h,0f2h,63h,7dh, 00h,00h,04h,00h,00h,00h,00h,00h db 22h,11h,4ch,00h,0f2h,0f2h,63h,7dh, 00h,00h,04h,00h,00h,00h,00h,00h db 22h,11h,4ch,00h,0f2h,0f2h,63h,7dh, 00h,00h,04h,00h,00h,00h,00h,00h db 22h,11h,4ch,00h,0f2h,0f2h,63h,7dh, 00h,00h,04h,00h,00h,00h,00h,00h db 22h,11h,4ch,00h,0f2h,0f2h,63h,7dh, 00h,00h,04h,00h,00h,00h,00h,00h db 22h,11h,4ch,00h,0f2h,0f2h,63h,7dh, 00h,00h,04h,00h,00h,00h,00h,00h db 22h,11h,4ch,00h,0f2h,0f2h,63h,7dh, 00h,00h,04h,00h,00h,00h,00h,00h buf_init PROC NEAR mov bp,sp mov dx,word ptr[bp] mov sp,OFFSET newstack ;New stack pointer mov ah,4aH ;Mshrink mov bx,65535/16 ;Bytes left for program int 21H mov ah,48H ;Allocate memory for CMF file mov bx,65535/16 int 21H mov cmf_seg,ax ;Pointer to allocated segment mov cmf_off,0 mov bp,sp mov word ptr[bp],dx ret buf_init ENDP ;---------------------------------------------------------------------------- fn_buf db 80,0 cmfname db 80 dup(0) fhandle dw 0 dec_buf db 7 dup(0) sampling dw ? count dw ? read_cmf PROC NEAR Print 'CMF File to play: ' readstr fn_buf mov bp,offset cmfname mov si,OFFSET fn_buf+1 ;Remove trailing CR xor dx,dx mov dl,byte ptr[si] mov si,dx mov byte ptr [bp+si],00h mov ah,3dh ;Open file mov al,0 mov dx,offset cmfname int 21h jc read_error xchg ax,bx push ds mov ds,cmf_seg ;Change to Buffer Segment mov ah,3fh ;Read file mov cx,65535 mov dx,00h int 21h pop ds mov count,ax ;Save bytes read in COUNT abort: ret read_error: pushf cr_lf Print 'Error: file not found' cr_lf popf jmp abort read_cmf ENDP ;-------------------------------------------------------------------------- fm_play PROC NEAR mov dx,ds ;Give status byte adress to mov ax,OFFSET fm_status ;FM driver mov bx,1 int 80h mov ax,208ch ;Set Driver clock rate mov bx,4 int 80h mov es,cmf_seg mov si,0 mov ax,es:word ptr[si+6] ;Offset of instrument table mov cx,es:word ptr[si+24h] ;Number of instruments mov dx,es mov bx,2 ;Set instrument table int 80h mov es,cmf_seg mov si,0 mov ax,es:word ptr[si+8] ;Get offset to music block mov dx,cmf_seg mov bx,6 ;Play CMF music int 80h idle: cmp fm_status,0 jnz idle mov bx,8 ;Reset FM driver int 80h ret fm_play ENDP ;-------------------------------------------------------------------- begin: call buf_init call read_cmf jc not_found call fm_play not_found: ret CSEG ENDS END Start . 0