Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You've asked for it, you'll get it:</p> <p>This is the source of a DOS .com file that plays the Blue Danube waltz. The executable is just 176 bytes in size. Code is re-used as data and vice versa.</p> <pre><code>.286 .model tiny g4 equ 55-48 ; removed note-decoding ! a4 equ 57-48 ; now: storing midi-notes for octaves 0..2 and convert h4 equ 59-48 ; to 4..6 with a simple add 48. c5 equ 60-48 d5 equ 62-48 e5 equ 64-48 g5 equ 67-48 h5 equ 71-48 c6 equ 72-48 d6 equ 74-48 e6 equ 76-48 g6 equ 79-48 ; = 00011111b pp equ 0 ; c4 is not used in the walz, using it as play-pause. EOM equ 1 ; c#4 is also available... End Of Music ; warning: experts only beyond this point ! pau1 equ 00100000b ; bitfield definitions for note-compression pau2 equ 01000000b ; you can or a pau to each note! pau3 equ 01100000b ;rep1 equ 01000000b ; rep1 is history (only used once). ;rep3 equ 11000000b ; rep3 was never used. rep2 equ 10000000b ; or a rep2 to a note to play it 3 times. drumsize equ 5 .code org 100h start: mov ah,9 mov dx,offset msg int 21h ; print our headerstring mov dx,0330h ; gus midi megaem -port mov si,offset music_code ; start of music data mainloop: ; get new note (melody) xor bp,bp ; bp= repeat-counter lodsb ; get a new note cmp al, EOM ; check for end jne continue ret continue: jns no_rep2 ; check for rep2-Bit inc bp inc bp ; "build" repeat-counter no_rep2: push ax ; save the note for pause ; "convert" to midi-note and al,00011111b jz skip_pp ; check pp, keep it 0 add al,48 ; fix-up oktave skip_pp: xchg ax,bx ; bl= midi-note play_again: mov cl,3 push cx ; patch program (3= piano) push 0c8h ; program change, channel 9 ; wait (cx:dx) times mov ah,86h ; wait a little bit int 15h ; prepare drums dec di ; get the current drum jns no_drum_underflow mov di,drumsize no_drum_underflow: ; play drum push dx ; volume drum push [word ptr drumtrk+di] ; note drum mov al,99h push ax ; play channel 10 ; play melody push dx ; volume melody push bx ; note melody dec ax ; replaces dec al :) push ax ; play channel 9 ; send data to midi-port mov cl,8 ; we have to send 8 bytes play_loop: pop ax ; get the midi event out dx,al ; and send it loop play_loop ; repeat "bp" times dec bp ; repeat the note jns play_again ; check and "play" pause xor bx,bx ; clear the note, so we can hear ; a pause ; decode pause value pop ax test al,01100000b jz mainloop ; no pause, get next note ; decrement pause value and save on stack sub al,20h push ax jmp play_again ; and play next drum ; don't change the order of the following data, it is heavily crosslinked ! music_code db pp or rep2 db g4 or rep2 or pau1 db h4 or pau1, d5 or pau1, d5 or pau3 db d6 or pau1, d6 or pau3, h5 or pau1, h5 or pau3 db g4 or rep2 or pau1 db h4 or pau1, d5 or pau1, d5 or pau3 db d6 or pau1, d6 or pau3, c6 or pau1, c6 or pau3 db a4 or rep2 or pau1 db c5 or pau1, e5 or pau1, e5 or pau3 db e6 or pau1, e6 or pau3, c6 or pau1, c6 or pau3 db a4 or rep2 or pau1 db c5 or pau1, e5 or pau1, e5 or pau3 db e6 or pau1, e6 or pau3, h5 or pau1, h5 or pau3 db g4 or rep2 or pau1 db h4 or pau1, g5 or pau1, g5 or pau3 db g6 or pau1, g6 or pau3, d6 or pau1, d6 or pau3 db g4 or rep2 or pau1 db h4 or pau1, g5 or pau1, g5 or pau3 db g6 or pau1, g6 or pau3, e6 or pau1, e6 or pau3 db a4 or rep2 or pau1 db c5 or pau1, e5 or pau1, e5 or pau3, pp or pau3 db c5 or pau1, e5 or pau1, h5 or pau3, pp or pau3, d5 or pau1 db h4 or pau1, h4 or pau3 db a4 or pau1, e5 or pau3 db d5 or pau1, g4 or pau2 ; db g4 or rep1 or pau1 ; replace this last "rep1"-note with two (equal-sounding) notes db g4 db g4 or pau1 msg db EOM, 'Docking Station',10,'doj&amp;sub' drumtrk db 36, 42, 38, 42, 38, 59 ; reversed order to save some bytes ! end start </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload