Last Updated or created 2023-10-05
Plays RAW adlib songs in 100 lines of code … kindda
Using information from here:
https://moddingwiki.shikadi.net/wiki/RAW_Format_(Adlib)
And using fasm to compile I can play captured raw songs.
But something is still off ?!?
It sounds a little different, and I need to implement a better timer routine. (Below my version and opencubicplayer)
This is a test for my bootloader, playing music from my bootblock!
CODE
use16 org 0x100 ctrlreg=0388h datareg=0389h mainloop: ; set speed (Byte 8,9 from the raw file) mov ax,[tune+8] mov [clockspeed],ax ; call player call rawreg ; wait 0.5 sec for exit mov bx,6 call waitmore jmp exit rawreg: mov bx,tune+0ah ; start of song at offset ah ; order registerdata, register! ; Are there more control codes? ??? lraw: mov cx,[bx] ; reg = 2 - check data cmp ch,2 je checkreg2 ; reg = 0 - cyclewait cmp ch,0 je cyclewait ; data = FFFF - end song - end play routine cmp cx,0ffffh jne skipr ret cyclewait: ; waits cl times waitroutine cylloop: call waitlong dec cl jnz cylloop inc bx inc bx jmp lraw checkreg2: ; check low opl cmp cl,1 jne checkh mov ch,0 mov [highlow],ch jmp incandret checkh: ; check high opl cmp cl,2 jne check00 mov ch,1 mov [highlow],ch jmp incandret check00: ; set new speed cmp cl,0 jne incandret inc bx inc bx mov ax,[bx] mov [clockspeed],ax incandret: ; next double byte in the song please inc bx inc bx jmp lraw skipr: ; sends data to the control and data registers mov dx,ctrlreg mov al,[highlow] cmp al,0 je regokay inc dx inc dx regokay: mov al,ch out dx,al ; call waitshort ; not needed for newer adlib cards mov dx,datareg mov al,[highlow] cmp al,0 je regokay2 inc dx inc dx regokay2: mov al,cl out dx,al call waitlong inc bx inc bx jmp lraw waitshort: push ax push cx push dx mov cx, 0 ;HIGH WORD. mov dx, 010h ;LOW WORD. mov ah, 86h ;WAIT. int 15h pop dx pop cx pop ax ret waitlong: push bx push ax push cx push dx mov cx, 0 ;HIGH WORD. mov dx, [clockspeed] shr dx,1 mov ah, 86h ;WAIT. int 15h pop dx pop cx pop ax pop bx ret waitmore: ; in bx == 12h is 1 sec ; destroys ax,bx,cx,dx push ax push bx push cx push dx mov ax,0h int 1ah add dx, bx mov bx,dx waitloop: mov ax,0h int 1ah cmp bx,dx jnz waitloop pop dx pop cx pop bx pop ax ret exit: mov dx,0388h mov al,0b0h out dx,al inc dx xor al,al out dx,al mov ax,04c00h int 21h clockspeed: dw 0 highlow: db 0 tune: file 'RAWSONG.RAW'