Difference between revisions of "Indian Spirit"
(Created page with "{{Tinyprog|title=Indian Spirit|author=Hellmood|bsize=32|link=http://www.pouet.net/prod.php?which=80341}} Category:Case Study Indian Spirit implements a 640x400 American In...") |
(Added explaination) |
||
(One intermediate revision by one other user not shown) | |||
Line 22: | Line 22: | ||
<syntaxhighlight lang=nasm> | <syntaxhighlight lang=nasm> | ||
− | pop ds | + | pop ds |
− | cwd | + | cwd |
Y: | Y: | ||
− | xor al,0x69 | + | xor al,0x69 |
− | int 0x10 | + | int 0x10 |
− | mov dl,cl | + | mov dl,cl |
− | mov al,[0x46C] | + | mov al,[0x46C] |
− | neg al | + | neg al |
− | xor dl,al | + | xor dl,al |
− | and al,32+16+4+2 | + | and al,32+16+4+2 |
− | or al,0x41 | + | or al,0x41 |
− | out 0x42,al | + | out 0x42,al |
− | out 0x61,al | + | out 0x61,al |
− | mov ah,12 | + | mov ah,12 |
− | loop Y | + | loop Y |
− | inc bl | + | inc bl |
− | jmp short Y | + | jmp short Y |
</syntaxhighlight> | </syntaxhighlight> | ||
+ | |||
+ | <code>pop ds</code> puts 0 into DS. The top stack value at the start of a DOS program is known to be zero. <code>cwd</code> is used to clear DX, it is needed because later, pixel setting via BIOS is used (int10h, AH=12), where DX is the row number. Since DX is the same as DS at start, we need to clear it, otherwise there is an offset for the whole graphic effect. <code>xor al,0x69</code> is a part of the graphic effect as well as assigning a graphic mode number to AL. This is a non standard short cut to the usual way of setting a high resolution graphic mode (VESA), which needs 4 bytes more. The mode numbers differ depending on the graphics cards used, here it works for the graphics card DOSBOX is emulating, so it should work on real hardware. A proof of concept version for a GT105M from NVIDIA [https://www.youtube.com/watch?v=uTCnMpNHBIw can be found here]. The idea of the graphic effect is to <code>loop</code> over 65536 values of <code>CX</code> which denotes the column at the same time, while changing the row in <code>DL</code> to create an interesting pattern. The row has to be kept in reasonable range, otherwise uncaught illegal memory accesses can occur. Here, the row number itself cannot exceed 255, since only DL is modified in an otherwise empty DX. Due to the linear memory modell of graphics memory, a column of 65535 would translate to about 102 rows, so we reach up to 357 rows, which fills about 75% of the screen. Syncing to the timer in [0:0x46C] and generating PC speaker output both are explained [http://www.sizecoding.org/wiki/Output#The_drum_channel here] and [http://www.sizecoding.org/wiki/Output#PC_Speaker here]. The melody itself is playing with some binary logic on the raw timing value, and heavily intertwined with the actual pixel color, as well as switching the PC speaker on and off. |
Latest revision as of 02:49, 26 April 2019
Indian Spirit was created by Hellmood and is 32 bytes in size. Indian Spirit implements a 640x400 American Indian cloth tapestry while playing music inspired by that culture. Original Readme:
"Indian Spirit" - HellMood / DSR released just for fun 02/2019 DOSBOX - 32 bytes - PC Speaker Somewhat inspired by Adoks "Indian" Series i coded for one hour to see what i can come up with, but in 32 bytes, and with sound. At the same time i exploited the "secret mode" 0x69 which switches to 640x400 in 256 colors, but without using the size-unfriendly VESA functions. For that reason, this demo only works in DOSBOX or on a computer which as the EXACT graphic card dosbox emulates. Youtube Capture : https://www.youtube.com/watch?v=TeIkW31Blf0
pop ds
cwd
Y:
xor al,0x69
int 0x10
mov dl,cl
mov al,[0x46C]
neg al
xor dl,al
and al,32+16+4+2
or al,0x41
out 0x42,al
out 0x61,al
mov ah,12
loop Y
inc bl
jmp short Y
pop ds
puts 0 into DS. The top stack value at the start of a DOS program is known to be zero. cwd
is used to clear DX, it is needed because later, pixel setting via BIOS is used (int10h, AH=12), where DX is the row number. Since DX is the same as DS at start, we need to clear it, otherwise there is an offset for the whole graphic effect. xor al,0x69
is a part of the graphic effect as well as assigning a graphic mode number to AL. This is a non standard short cut to the usual way of setting a high resolution graphic mode (VESA), which needs 4 bytes more. The mode numbers differ depending on the graphics cards used, here it works for the graphics card DOSBOX is emulating, so it should work on real hardware. A proof of concept version for a GT105M from NVIDIA can be found here. The idea of the graphic effect is to loop
over 65536 values of CX
which denotes the column at the same time, while changing the row in DL
to create an interesting pattern. The row has to be kept in reasonable range, otherwise uncaught illegal memory accesses can occur. Here, the row number itself cannot exceed 255, since only DL is modified in an otherwise empty DX. Due to the linear memory modell of graphics memory, a column of 65535 would translate to about 102 rows, so we reach up to 357 rows, which fills about 75% of the screen. Syncing to the timer in [0:0x46C] and generating PC speaker output both are explained here and here. The melody itself is playing with some binary logic on the raw timing value, and heavily intertwined with the actual pixel color, as well as switching the PC speaker on and off.