Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
---------------------------
16 bit MS-DOS Subsystem
---------------------------
C:\DOCUME~1\SZELEN~1\Desktop\k29.com
The NTVDM CPU has encountered an illegal instruction.
CS:c000 IP:dede OP:ff ff ff ff ff Choose 'Close' to terminate the application.
---------------------------
Close Ignore
---------------------------
4d3
< ; [106h] == 0
7,8c6
< mov si, 100
< mov di, RRR
---
> mov di, kruch
21,22c19,20
< mov ax, 0A000h
< mov es, ax
---
> push 0A000h
> pop es
25c23
< mov ax, si
---
> mov ax, 100
31,33c29,30
<
< pusha
< mul ax
---
> push ax cx
> imul ax
35c32
< mul ax
---
> imul ax
37,42c34,36
< xor dx, dx
< mov bx, [kruch] ;mov bx, 40 ; K1 = 40
< div bx
< mov bx, sp
< mov word [bx+10], ax
< popa
---
> div word [di]
> push ax
> mov si,sp
47,50c41,42
< mov word [si], ax ; COS
< fild word [si]
< mov word [si], cx ; SIN
< fild word [si]
---
> fild word [si+4] ; COS
> fild word [si+2] ; SIN
52,55c44,49
< fimul word [vnum]
< fmul dword [glad]
< fist word [si]
< add dx, [si]
---
> fimul word [di+vnum-kruch]
> fmul dword [di+glad-kruch]
> fiadd word [si]
> fist word [si]
> pop dx
> pop cx ax
94d87
< add al, cl ; + ??????
102a96
> add al, cl ; + ??????
108d101
< mov bx, di
112c105
< and al, [bx]
---
> and al, byte [di+RRR-kruch]
114c107
< inc bx
---
> inc di
121,123c114
< sub al, cl ; - ??????
<
< inc al
---
> inc al
157c148
< dec [kruch]
---
> dec word [di]
159c150,151
< inc [kruch]
---
> inc_kruch_paint_me:
> inc word [di]
165,167c157
< jne label_push_R
< inc [kruch]
< jmp paint
---
> je inc_kruch_paint_me
172c162
< not byte [di]
---
> not byte [di+RRR-kruch]
177c167
< not byte [di+1]
---
> not byte [di+GGG-kruch]
182c172
< not byte [di+2]
---
> not byte [di+BBB-kruch]
189c179
< jmp paint
---
> jmp paint_me
205c195
< sign db 'Dedicated to my wife 9'
\ No newline at end of file
---
> ;sign db 'Dedicated to my wife 9'
7c7,8
< mov si, 100
---
> mov si, 0A000h
> mov es, si
8a10
> mov bp, 13 ; kruch
18,25c20
< push cx
<
< ; ??????? ES ????????? ?? ???????????
< mov ax, 0A000h
< mov es, ax
<
< mov bh, 0FAh ;mov bx, 320*200
< mov ax, si
---
> mov bh, 0FAh
27,43c22,27
<
< mov cx, 160
< lp2:
< ; ?????? ? DX ????? ??????? ?? K1
<
< pusha
< mul ax
< xchg ax, cx
< mul ax
< add ax, cx
< xor dx, dx
< mov bx, [kruch] ;mov bx, 40 ; K1 = 40
< div bx
< mov bx, sp
< mov word [bx+10], ax
< popa
<
---
> mov ax, bx
> xor dx, dx
> div word [_320+di-RRR]
> sub ax, 100
> sub dx, 160
>
49c33
< mov word [si], cx ; SIN
---
> mov word [si], dx ; SIN
52,55c36,45
< fimul word [vnum]
< fmul dword [glad]
< fist word [si]
< add dx, [si]
---
> fimul word [vnum+di-RRR]
> fmul dword [glad+di-RRR]
> fistp word [si]
>
> imul ax, ax
> imul dx, dx
> add ax, dx
> xor dx, dx
> div bp
> add ax, [si]
59,69c49,50
< mov byte [es:bx], dl
<
< dec cx
< cmp cx, -160
< jg lp2
<
< dec ax
< cmp al, -100
< jg lp1
<
< pop cx
---
> mov byte [es:bx], al
> jnz lp1
77c58
< add cl, ch ; [DELTA]
---
> add ch, cl ; [DELTA]
88,92d68
< cmp al, 0 ; was ah!!
< jl no_inv
< not ah
< no_inv:
<
94d69
< add al, cl ; + ??????
102a78
> add al, ch ; + ??????
108,109d83
< mov bx, di
< mov cx, 3
112c86
< and al, [bx]
---
> and al, [di+bx]
115c89
< loop mmm
---
> jnp mmm
118a93,94
> xor al, 0xFF
> js setColor
121,122d96
< sub al, cl ; - ??????
<
124c98
< jnz setPalette_loop
---
> jns setPalette_loop
138a113,126
> label_push_down:
> cmp al, 80
> jne label_push_up
> dec bp
> jnz paint_me
> inc_kruch_paint_me:
> inc bp
> paint_me:
> jmp paint
>
> label_push_up:
> cmp al, 72
> je inc_kruch_paint_me
>
142c130
< mov ch, 0
---
> mov cl, 0
147c135
< dec ch
---
> dec cx
151,164d138
< jne label_push_down
< inc ch
<
< label_push_down:
< cmp al, 80
< jne label_push_up
< dec [kruch]
< jnz paint_me
< inc [kruch]
< paint_me:
< jmp paint
<
< label_push_up:
< cmp al, 72
166,167c140
< inc [kruch]
< jmp paint
---
> inc cx
171,174c144,145
< jne label_push_G
< not byte [di]
<
< label_push_G:
---
> je change_color
> inc bx
176,179c147,148
< jne label_push_B
< not byte [di+1]
<
< label_push_B:
---
> je change_color
> inc bx
182c151,152
< not byte [di+2]
---
> change_color:
> not byte [di+bx]
184a155
> xor bx, bx
189c160
< jmp paint
---
> jmp paint_me
203c174
< kruch dw 13
---
> _320 dw 320
205c176
< sign db 'Dedicated to my wife 9'
\ No newline at end of file
---
> ;sign db 'Dedicated to my wife 9'
\ No newline at end of file
;выделяем память
mov ah,4ah
mov bx,1000h
int 21h
mov ah,48h
int 21h
jc exit
mov word ptr vseg,ax
;обнулим её
mov es,ax
xor ax,ax
xor di,di
mov cx,32000
rep stosw ;можно использовать stosd
;ваш код
mov dx,3DAh ;порт
; цикл ожидания синхронизации c лучём элт
sync:
in al,dx
test al,8h
jz sync
pusha
push ds
; во vseg, понятно у нас как раз лежит указатель на наш буфер
mov ax,word ptr vseg
mov ds,ax
mov ax,0A000h
mov es,ax
xor si,si
xor di,di
mov cx,32000
rep movsw ;можно использовать movsd
pop ds
popa
;всё, фрейм отрисован
mov dx,03dah
sync:
in al,dx
test al,8h
jz sync
mov ax, 0A000h
mov es, ax
mov ax, 0A000h
mov es, axВ Win7 и Vista работать не будетЭто потому что не поддерживается полноэкранный режим. Я давно хочу преодолеть это ограничение, уже даже есть наработки. А именно — во всем виноват видеодрайвер.
.model tiny
.code
.386
org 100h
start: mov al,13h
int 10h
mov ax,0A000h
mov ds,ax
mov dx,1
M0: mov cl,40h
M1: push cx
xor cx,cx
mov ax,1010h
int 10h
add dh,dl
inc bx
pop cx
loop M1
neg dl
add dh,dl
cmp bl,0
jnz M0
M2: mov si,1
mov ax,108h
mov bx,154h
mov bp,101h
call proc1
neg si
add bp,7Eh
add bx,ax
call proc1
in al,60h
dec al
jnz M2
mov ax,3h
int 10h
ret
proc1 proc near
pusha
xor cx,cx
mov cl,0C8h
M4: push cx
mov cl,40h
M3: push cx
xor dx,dx
mov al,byte ptr [bx-1]
add dx,ax
mov al,byte ptr [bx+1]
add dx,ax
mov al,byte ptr [bx-140h]
add dx,ax
mov al,byte ptr [bx+140h]
add dx,ax
shr dx,2
inc dl
inc dl
mov byte ptr [bx],dl
add bx,si
pop cx
loop M3
add bx,bp
pop cx
loop M4
popa
ret
ret
proc1 endp
end start
3) Циклический сдвиг палитры на одну позицию. Это и даёт иллюзию вращения спирали.
Управляемая градиентная спираль на ассемблере в 256 байт (k29)