flat assembler
Message board for the users of flat assembler.

flat assembler > DOS > zymmetry - screen saver project (Version 3.0 DONE!)

Author
Thread Post new topic Reply to topic
mbr_tsr



Joined: 03 Apr 2011
Posts: 4785
Code:
;============================================================ ;ZYMMETRY.ASM ;AMAZING ZYMMETRICAL PATTERN COMPILER VERSION 2.0 ;(C)2011/2015 By Shawn T. Cook ;Credit to the original author I lost his name. ;For DOS / Uses int 21h ;Note I am currently working on version 3.0 available soon! ;This allows you to create a screen saver .COM file called 'output.com'. ;To edit output.com Type C:\>output.com 1 (don't forget the 1). ;============================================================ Org 100h ;============================================================ SCREEN_WIDTH =320 ;160 SCREEN_HEIGHT =200 ;100 X_WIDTH =(SCREEN_WIDTH +2) X_HEIGHT =(SCREEN_HEIGHT +2) ;============================================================ MainMenu: mov ax, cs mov ds, ax mov es, ax mov fs, ax mov gs, ax cld cmp byte [cs:82h], '1' je SkipRun cmp byte [cs:Running], 1 je Launch SkipRun: mov ah, 0 ;Screen Mode 1 mov al, 1 int 0x10 mov ah, 09 mov dx, Setup int 21h mov si, buff mov ah, 09 mov dx, Setupi0 int 21h mov AL,byte [cs:Setup0] call showhex mov ah, 09 mov dx, Setupi1a int 21h mov AL,byte [cs:Setup1a] call showhex mov ah, 09 mov dx, Setupi1b int 21h mov AL,byte [cs:Setup1b] call showhex mov ah, 09 mov dx, Setupi2 int 21h mov AL,byte [cs:Setup2] call showhex mov ah, 09 mov dx, Setupi3 int 21h mov AL,byte [cs:Setup3] call showhex mov ah, 09 mov dx, Setupi4 int 21h mov AL,byte [cs:Setup4] call showhex mov ah, 09 mov dx, Setupi5 int 21h mov AL,byte [cs:Setup5] call showhex mov ah, 09 mov dx, Setupi6 int 21h mov AL,byte [cs:Setup6] call showhex mov ah, 09 mov dx, Setupi7 int 21h mov AL,byte [cs:Setup7] call showhex mov ah, 09 mov dx, Setupi8 int 21h mov AL,byte [cs:Setup8] call showhex mov ah, 09 mov dx, Setupi9 int 21h mov AL,byte [cs:Setup9] call showhex mov ah, 09 mov dx, Setupia int 21h mov AL,byte [cs:Setupa] call showhex mov ah, 09 mov dx, Setupib int 21h mov AL,byte [cs:Setupb] call showhex mov dx, Setupic int 21h mov AL,byte [cs:Setupc] call showhex mov ah, 09 mov dx, bar int 21h mov ah, 09 mov dx, op int 21h mov ah, 09 mov dx, prompt1 int 21h mov ah, 0 int 16h mov ah, 0x0e int 0x10 cmp al, '0' jne n1 call input mov byte [cs:Setup0], AL jmp SetVal n1: cmp al, '1' jne n2 call input mov byte [cs:Setup1a], AL jmp SetVal n2: cmp al, '2' jne n3 call input mov byte [cs:Setup1b], AL jmp SetVal n3: cmp al, '3' jne n4 call input mov byte [cs:Setup2], AL jmp SetVal n4: cmp al, '4' jne n5 call input mov byte [cs:Setup3], AL jmp SetVal n5: cmp al, '5' jne n6 call input mov byte [cs:Setup4], AL jmp SetVal n6: cmp al, '6' jne n7 call input mov byte [cs:Setup5], AL jmp SetVal n7: cmp al, '7' jne n8 call input mov byte [cs:Setup6], AL jmp SetVal n8: cmp al, '8' jne n9 call input mov byte [cs:Setup7], AL jmp SetVal n9: cmp al, '9' jne nA call input mov byte [cs:Setup8], AL jmp SetVal nA: cmp al, 'a' jne nB call input cmp AL, 0 jne NotNulBug mov al, 1 NotNulBug: mov byte [cs:Setup9], AL jmp SetVal nB: cmp al, 'b' jne nC call input mov byte [cs:Setupa], AL jmp SetVal nC: cmp al, 'c' jne nD call input mov byte [cs:Setupb], AL jmp SetVal nD: cmp al, 'd' jne nE call input mov byte [cs:Setupc], AL jmp SetVal nE: cmp al, 'r' je Launch cmp al, 'w' je Write cmp al, 'q' je Quit SetVal: jmp MainMenu Write: push cs pop ds mov byte [cs:Running], 1 mov ah, 0x3C mov cx, 0 mov dx, FileNameBuff int 0x21 mov bx, ax mov ah, 0x40 push cs pop ds mov dx, 100h mov cx, EndOfCode - 100h int 0x21 mov ah, 0x3E int 0x21 mov byte [cs:Running], 0 jmp MainMenu Launch: ;============================================================ mov ax, 0x0013 int 0x10 ;============================================================ cmp byte [cs:Setup0], 0 je NoPalette mov ah, 0x0b mov bh, 0 mov bl, byte [cs:Setup0] int 0x10 NoPalette: ;============================================================ cld mov ax, 0x6000 mov bx, ax mov es, ax push es mov cx, X_WIDTH * X_HEIGHT / 2 xor di, di xor ax, ax rep stosw add bx, 0x2000 mov es, bx mov cx, X_WIDTH * X_HEIGHT / 2 xor di, di xor ax, ax rep stosw pop ds ;============================================================ inc byte [X_HEIGHT / 2 * X_WIDTH + X_WIDTH / 2] ;============================================================ mov ax, 0xa000 mov gs, ax std ;============================================================ NextFrame: cmp byte [cs:Setup9], 0 je Fast push CX mov CH, 0 mov CL, byte [cs:Setup9] Delay: push AX push BX push ES mov AX, 40h mov ES, AX mov AX, word [es:6Ch] Sleep: mov BX, word [es:6Ch] cmp AX, BX je Sleep pop ES pop BX pop AX loop Delay pop CX Fast: mov si, (X_WIDTH * (X_HEIGHT -1) - 2) mov di, si mov bx, (SCREEN_WIDTH) * (SCREEN_HEIGHT) - 1 ;============================================================ NextLine: mov cx, SCREEN_WIDTH NextPixel: mov [gs:bx], al lodsb cmp al, 00 je Check cmp byte [cs:Setup3], 0 je NoXor xor al, byte [cs:Setup3] NoXor: cmp al, byte [cs:Setup4] je Check cmp byte [cs:Setup8], 0 je Default sub al, byte [cs:Setup8] jmp CheckEnd Default: inc AL jmp CheckEnd ;============================================================ Check: mov al, 0 mov dl, 0 cmp byte [cs:Setup7], 0 je None push bx mov bh, 0 mov bl, byte [cs:Setup7] add dl, [si + BX] pop bx None: cmp byte [cs:Setupa], 1 jne NoTwist add dl, [si - X_WIDTH + 2] add dl, [si - X_WIDTH] add dl, [si + X_WIDTH] add dl, [si + X_WIDTH + 2] NoTwist: add dl, [si - X_WIDTH + 1] add dl, [si] add dl, [si + 2] add dl, [si + X_WIDTH + 1] xor dl, byte [cs:Setupc] cmp dl, byte [cs:Setup5] jg Work cmp dl, byte [cs:Setup1a] je Work cmp dl, byte [cs:Setup1b] jne CheckEnd ;============================================================ Work: mov al, byte [cs:Setupb] CheckEnd: cmp al, byte [cs:Setup2] jne SetNext ;============================================================ push bx mov al, byte [cs:Setup6] inc byte [X_HEIGHT / 2 * X_WIDTH + X_WIDTH / 2] pop bx ;============================================================ SetNext: mov [es:di], al dec bx dec di loop NextPixel_ sub si, 2 sub di, 2 cmp bx, 0xffff jne NextLine push ds push es pop ds pop es mov ah, 1 int 0x16 jnz over jmp NextFrame over: mov ah, 0 int 0x16 xor ah, ah mov al, 03 int 0x10 mov ax, cs mov ds, ax mov es, ax cmp byte [cs:Running], 1 je Quit jmp MainMenu NextPixel_: jmp NextPixel ;============================================================ scnhex: push cx ;DS:SI as HEX to ASCII->AL push dx mov cl,4 xor dx,dx scn: lodsb cmp al,'0' jb endr cmp al,'9' jna decdgt or al,0x20 cmp al,'a' jb endr cmp al,'f' ja endr sub al,'a'-'9'-1 decdgt: sub al,'0' shl dx,cl or dl,al jmp scn endr: dec si xchg dx,ax pop dx pop cx ret ;============================================================ showhex: ;shows ascii value in AL as HEX push ax push bx push cx push dx call conhex mov cx,ax mov al,cl mov ah, 0x0e int 10h mov al,ch mov ah, 0x0e int 10h pop dx pop cx pop bx pop ax ret ;============================================================ conhex: ;converts ASCII (AL) to hex (AX) mov cl,10h mov ah,0 div cl add al,30h add ah,30h cmp al,'9' jbe ca4 add al,7 ca4: cmp ah,'9' jbe ca5 add ah,7 ca5: ret ;============================================================ Quit: mov ah, 0 mov al, 3 int 10h mov ah, 4ch int 21h ;============================================================ input: mov ah, 09 mov dx, prompt2 int 21h mov ah,0 int 16h mov ah, 0eh int 10h mov dh, al mov ah,0 int 16h mov ah, 0eh int 10h mov dl, al mov byte [ds:si], DH mov byte [ds:si+1], DL mov byte [ds:si+2], 0 call scnhex ret ;============================================================ Setup: db 13,10,"------------------------------------" db 13,10,"AMAZING SYMMETRICAL PATTERN COMPILER" bar db 13,10,"------------------------------------$",0 Setupi0 db 13,10,"0. Color Setup =$" Setupi1a db 13,10,"1. Pattern #1 =$" Setupi1b db 13,10,"2. Pattern #2 =$" Setupi2 db 13,10,"3. States =$" Setupi3 db 13,10,"4. Bits =$" Setupi4 db 13,10,"5. Matrix =$" Setupi5 db 13,10,"6. Precise =$" Setupi6 db 13,10,"7. Die (0/1) =$" Setupi7 db 13,10,"8. Blaster =$" Setupi8 db 13,10,"9. Minus =$" Setupi9 db 13,10,"a. Speed =$" Setupia db 13,10,"b. Diamond(0/1)=$" Setupib db 13,10,"c. Veng =$" Setupic db 13,10,"d. Adapt =$" op db 13,10,"(R)un (W)rite (Q)uit$" FileName db 13,10,"Enter .COM FileName?$" prompt1 db 13,10,'Choice (1 to d):$' prompt2 db 13,10,'Enter 2 Digit HEX code:$' Setup0 db 0x0 Setup1a db 0x1 Setup1b db 0x1 Setup2 db 0xff Setup3 db 0x0 Setup4 db 0xFF Setup5 db 0x50 Setup6 db 0x1 Setup7 db 0x0 Setup8 db 0x0 Setup9 db 0x1 Setupa db 0x1 Setupb db 0x1 Setupc db 0x2 FileNameBuff db 'output.com',0 buff rb 8 Running db 0 db 1 ;============================================================ EndOfCode:


Last edited by mbr_tsr on 10 Sep 2015, 06:43; edited 1 time in total
Post 09 Sep 2015, 19:15
View user's profile Send private message Reply with quote
mbr_tsr



Joined: 03 Apr 2011
Posts: 4785
Code:
;============================================================ ;ZYMMETRY.ASM ;AMAZING ZYMMETRICAL PATTERN COMPILER VERSION 3.0 ;(C)2011/2015 By Shawn T. Cook ;Credit to the original author I lost his name. ;For DOS / Uses int 21h ;Note I am currently working on version 4.0 available soon! ;This allows you to create a screen saver .COM file called 'output.com'. ;To edit output.com Type C:\>output.com 1 (don't forget the 1). ;============================================================ Org 100h ;============================================================ SCREEN_WIDTH =320 ;160 SCREEN_HEIGHT =200 ;100 X_WIDTH =(SCREEN_WIDTH +2) X_HEIGHT =(SCREEN_HEIGHT +2) ;============================================================ MainMenu: mov ax, cs mov ds, ax mov es, ax mov fs, ax mov gs, ax cld cmp byte [cs:82h], '1' je SkipRun cmp byte [cs:Running], 1 je Launch SkipRun: mov ah, 0 ;Screen Mode 1 mov al, 1 int 0x10 mov ah, 09 mov dx, Setup int 21h mov si, buff mov ah, 09 mov dx, Setupi0 int 21h mov AL,byte [cs:Setup0] call showhex mov ah, 09 mov dx, Setupi1 int 21h mov AL,byte [cs:Setup1] call showhex mov ah, 09 mov dx, Setupi2 int 21h mov AL,byte [cs:Setup2] call showhex mov ah, 09 mov dx, Setupi3 int 21h mov AL,byte [cs:Setup3] call showhex mov ah, 09 mov dx, Setupi4 int 21h mov AL,byte [cs:Setup4] call showhex mov ah, 09 mov dx, Setupi5 int 21h mov AL,byte [cs:Setup5] call showhex mov ah, 09 mov dx, Setupi6 int 21h mov AL,byte [cs:Setup6] call showhex mov ah, 09 mov dx, Setupi7 int 21h mov AL,byte [cs:Setup7] call showhex mov ah, 09 mov dx, Setupi8 int 21h mov AL,byte [cs:Setup8] call showhex mov ah, 09 mov dx, Setupi9 int 21h mov AL,byte [cs:Setup9] call showhex mov ah, 09 mov dx, SetupiA int 21h mov AL,byte [cs:SetupA] call showhex mov ah, 09 mov dx, SetupiB int 21h mov AL,byte [cs:SetupB] call showhex mov ah, 09 mov dx, SetupiC int 21h mov AL,byte [cs:SetupC] call showhex mov dx, SetupiD int 21h mov AL,byte [cs:SetupD] call showhex mov dx, SetupiE int 21h mov AL,byte [cs:SetupE] call showhex mov ah, 09 mov dx, bar int 21h mov ah, 09 mov dx, op int 21h mov ah, 09 mov dx, prompt1 int 21h mov ah, 0 int 16h mov ah, 0x0e int 0x10 cmp al, '0' jne n1 call input mov byte [cs:Setup0], AL jmp SetVal n1: cmp al, '1' jne n2 call input mov byte [cs:Setup1], AL jmp SetVal n2: cmp al, '2' jne n3 call input mov byte [cs:Setup2], AL jmp SetVal n3: cmp al, '3' jne n4 call input mov byte [cs:Setup3], AL jmp SetVal n4: cmp al, '4' jne n5 call input mov byte [cs:Setup4], AL jmp SetVal n5: cmp al, '5' jne n6 call input mov byte [cs:Setup5], AL jmp SetVal n6: cmp al, '6' jne n7 call input mov byte [cs:Setup6], AL jmp SetVal n7: cmp al, '7' jne n8 call input mov byte [cs:Setup7], AL jmp SetVal n8: cmp al, '8' jne n9 call input mov byte [cs:Setup8], AL jmp SetVal n9: cmp al, '9' jne nA call input mov byte [cs:Setup9], AL jmp SetVal nA: cmp al, 'a' jne nB call input cmp AL, 0 jne NotNulBug mov al, 1 NotNulBug: mov byte [cs:SetupA], AL jmp SetVal nB: cmp al, 'b' jne nC call input mov byte [cs:SetupB], AL jmp SetVal nC: cmp al, 'c' jne nD call input mov byte [cs:SetupC], AL jmp SetVal nD: cmp al, 'd' jne nE call input mov byte [cs:SetupD], AL jmp SetVal nE: cmp al, 'e' jne nF call input mov byte [cs:SetupE], AL jmp SetVal nF: cmp al, 'r' je Launch cmp al, 'w' je Write cmp al, 'q' je Quit SetVal: jmp MainMenu Write: push cs pop ds mov byte [cs:Running], 1 mov ah, 0x3C mov cx, 0 mov dx, FileNameBuff int 0x21 mov bx, ax mov ah, 0x40 push cs pop ds mov dx, 100h mov cx, EndOfCode - 100h int 0x21 mov ah, 0x3E int 0x21 mov byte [cs:Running], 0 jmp MainMenu Launch: ;============================================================ mov ax, 0x0013 int 0x10 ;============================================================ cmp byte [cs:Setup0], 0 je NoPalette mov ah, 0x0b mov bh, 0 mov bl, byte [cs:Setup0] int 0x10 NoPalette: ;============================================================ cld mov ax, 0x6000 mov bx, ax mov es, ax push es mov cx, X_WIDTH * X_HEIGHT / 2 xor di, di xor ax, ax rep stosw add bx, 0x2000 mov es, bx mov cx, X_WIDTH * X_HEIGHT / 2 xor di, di xor ax, ax rep stosw pop ds ;============================================================ inc byte [X_HEIGHT / 2 * X_WIDTH + X_WIDTH / 2] ;============================================================ mov ax, 0xa000 mov gs, ax std ;============================================================ NextFrame: cmp byte [cs:SetupA], 0 je Fast push CX mov CH, 0 mov CL, byte [cs:SetupA] Delay: push AX push BX push ES mov AX, 40h mov ES, AX mov AX, word [es:6Ch] Sleep: mov BX, word [es:6Ch] cmp AX, BX je Sleep pop ES pop BX pop AX loop Delay pop CX Fast: mov si, (X_WIDTH * (X_HEIGHT -1) - 2) mov di, si mov bx, (SCREEN_WIDTH) * (SCREEN_HEIGHT) - 1 ;============================================================ NextLine: mov cx, SCREEN_WIDTH NextPixel: xor al, byte [cs:SetupE] mov [gs:bx], al lodsb cmp al, 00 je Check cmp byte [cs:Setup4], 0 je NoXor xor al, byte [cs:Setup4] NoXor: cmp al, byte [cs:Setup5] je Check cmp byte [cs:Setup9], 0 je Default sub al, byte [cs:Setup9] jmp CheckEnd Default: inc AL jmp CheckEnd ;============================================================ Check: mov al, 0 mov dl, 0 cmp byte [cs:Setup8], 0 je None push bx mov bh, 0 mov bl, byte [cs:Setup8] add dl, [si + BX] pop bx None: cmp byte [cs:SetupB], 1 jne NoTwist add dl, [si - X_WIDTH + 2] add dl, [si - X_WIDTH] add dl, [si + X_WIDTH] add dl, [si + X_WIDTH + 2] NoTwist: add dl, [si - X_WIDTH + 1] add dl, [si] add dl, [si + 2] add dl, [si + X_WIDTH + 1] xor dl, byte [cs:SetupD] cmp dl, byte [cs:Setup6] jg Work cmp dl, byte [cs:Setup1] je Work cmp dl, byte [cs:Setup2] jne CheckEnd ;============================================================ Work: mov al, byte [cs:SetupC] CheckEnd: cmp al, byte [cs:Setup3] jne SetNext ;============================================================ mov al, byte [cs:Setup7] SetNext: mov [es:di], al dec bx dec di loop NextPixel_ sub si, 2 sub di, 2 cmp bx, 0xffff jne NextLine push ds push es pop ds pop es mov ah, 1 int 0x16 jnz over jmp NextFrame over: mov ah, 0 int 0x16 xor ah, ah mov al, 03 int 0x10 mov ax, cs mov ds, ax mov es, ax cmp byte [cs:Running], 1 je Quit jmp MainMenu NextPixel_: jmp NextPixel ;============================================================ scnhex: push cx ;DS:SI as HEX to ASCII->AL push dx mov cl,4 xor dx,dx scn: lodsb cmp al,'0' jb endr cmp al,'9' jna decdgt or al,0x20 cmp al,'a' jb endr cmp al,'f' ja endr sub al,'a'-'9'-1 decdgt: sub al,'0' shl dx,cl or dl,al jmp scn endr: dec si xchg dx,ax pop dx pop cx ret ;============================================================ showhex: ;shows ascii value in AL as HEX push ax push bx push cx push dx call conhex mov cx,ax mov al,cl mov ah, 0x0e int 10h mov al,ch mov ah, 0x0e int 10h pop dx pop cx pop bx pop ax ret ;============================================================ conhex: ;converts ASCII (AL) to hex (AX) mov cl,10h mov ah,0 div cl add al,30h add ah,30h cmp al,'9' jbe ca4 add al,7 ca4: cmp ah,'9' jbe ca5 add ah,7 ca5: ret ;============================================================ Quit: mov ah, 0 mov al, 3 int 10h mov ah, 4ch int 21h ;============================================================ input: mov ah, 09 mov dx, prompt2 int 21h mov ah,0 int 16h mov ah, 0eh int 10h mov dh, al mov ah,0 int 16h mov ah, 0eh int 10h mov dl, al mov byte [ds:si], DH mov byte [ds:si+1], DL mov byte [ds:si+2], 0 call scnhex ret ;============================================================ Setup: db 13,10,"------------------------------------" db 13,10,"AMAZING SYMMETRICAL PATTERN COMPILER" bar db 13,10,"------------------------------------$",0 Setupi0 db 13,10,"0. Color Setup =$" Setupi1 db 13,10,"1. Pattern #1 =$" Setupi2 db 13,10,"2. Pattern #2 =$" Setupi3 db 13,10,"3. States =$" Setupi4 db 13,10,"4. Bits =$" Setupi5 db 13,10,"5. Matrix =$" Setupi6 db 13,10,"6. Precise =$" Setupi7 db 13,10,"7. Die (0/1) =$" Setupi8 db 13,10,"8. Blaster =$" Setupi9 db 13,10,"9. Minus =$" SetupiA db 13,10,"a. Speed =$" SetupiB db 13,10,"b. Diamond(0/1)=$" SetupiC db 13,10,"c. Veng =$" SetupiD db 13,10,"d. Adapt =$" SetupiE db 13,10,"e. Extra =$" op db 13,10,"(R)un (W)rite (Q)uit$" FileName db 13,10,"Enter .COM FileName?$" prompt1 db 13,10,'Choice (1 to d):$' prompt2 db 13,10,'Enter 2 Digit HEX code:$' Setup0 db 0x0 Setup1 db 0x3 Setup2 db 0x1 Setup3 db 0xff Setup4 db 0x0 Setup5 db 0xFF Setup6 db 0x50 Setup7 db 0x1 Setup8 db 0x0 Setup9 db 0x0 SetupA db 0x1 SetupB db 0x1 SetupC db 0x1 SetupD db 0x2 SetupE db 0x0 FileNameBuff db 'output.com',0 buff rb 8 Running db 0 db 1 ;============================================================ EndOfCode:
Post 10 Sep 2015, 06:43
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >

Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 2004-2018, Tomasz Grysztar.

Powered by rwasa.