flat assembler
Message board for the users of flat assembler.

Index > DOS > Text mode patterns with loads of options, unexplored.

Author
Thread Post new topic Reply to topic
mbr_tsr



Joined: 03 Apr 2011
Posts: 12092
mbr_tsr 28 Jun 2011, 18:27
Code:
;============================================================
Org 100h
;============================================================
SCREEN_WIDTH  =80 ;320           ;160
SCREEN_HEIGHT =50 ;200           ;100
X_WIDTH  =(SCREEN_WIDTH  +2)
X_HEIGHT =(SCREEN_HEIGHT +2)
;============================================================
MainMenu:

xor  ah, ah
mov  al, 03
int  0x10

mov  ax, cs
mov  ds, ax
mov  es, ax
mov  gs, ax
mov  fs, ax


cld
mov  si, buff
mov  ah, 09
mov  dx, i0
int  21h
mov  AL,byte [cs:s0]
call showhex
mov  ah, 09
mov  dx, i1
int  21h
mov  AL,byte [cs:s1a]
call showhex
mov  ah, 09
mov  dx, i2
int  21h
mov  AL,byte [cs:s1b]
call showhex
mov  ah, 09
mov  dx, i3
int  21h
mov  AL,byte [cs:s2]
call showhex
mov  ah, 09
mov  dx, i4
int  21h
mov  AL,byte [cs:s3]
call showhex
mov  ah, 09
mov  dx, i5
int  21h
mov  AL,byte [cs:s4]
call showhex
mov  ah, 09
mov  dx, i6
int  21h
mov  AL,byte [cs:s5]
call showhex
mov  ah, 09
mov  dx, i7
int  21h
mov  AL,byte [cs:s6]
call showhex
mov  ah, 09
mov  dx, i8
int  21h
mov  AL,byte [cs:s7]
call showhex
mov  ah, 09
mov  dx, i9
int  21h
mov  AL,byte [cs:s8]
call showhex
mov  ah, 09
mov  dx, iA
int  21h
mov  AL,byte [cs:s9]
call showhex
mov  ah, 09
mov  dx, iB
int  21h
mov  AL,byte [cs:sA]
call showhex
mov  ah, 09
mov  dx, iC
int  21h
mov  AL,byte [cs:sB]
call showhex
mov  dx, iD
int  21h
mov  AL,byte [cs:sC]
call showhex

mov  ah, 09
mov  dx, op
int  21h
mov  ah, 09
mov  dx, prompt1
int  21h
mov  ah, 0
int  16h

cmp  al, '0'
jne  n1
call input
mov  byte [cs:s0], AL
jmp  SetVal

n1:
cmp  al, '1'
jne  n2
call input
mov  byte [cs:s1a], AL
jmp  SetVal

n2:
cmp  al, '2'
jne  n3
call input
mov  byte [cs:s1b], AL
jmp  SetVal

n3:
cmp  al, '3'
jne  n4
call input
mov  byte [cs:s2], AL
jmp  SetVal

n4:
cmp  al, '4'
jne  n5
call input
mov  byte [cs:s3], AL
jmp  SetVal

n5:
cmp  al, '5'
jne  n6
call input
mov  byte [cs:s4], AL
jmp  SetVal

n6:
cmp  al, '6'
jne  n7
call input
mov  byte [cs:s5], AL
jmp  SetVal

n7:
cmp  al, '7'
jne  n8
call input
mov  byte [cs:s6], AL
jmp  SetVal

n8:
cmp  al, '8'
jne  n9
call input
mov  byte [cs:s7], AL
jmp  SetVal

n9:
cmp  al, '9'
jne  nA
call input
mov  byte [cs:s8], AL
jmp  SetVal

nA:
cmp  al, 'a'
jne  nB
call input
mov  byte [cs:s9], AL
jmp  SetVal

nB:
cmp  al, 'b'
jne  nC
call input
mov  byte [cs:sA], AL
jmp  SetVal

nC:
cmp  al, 'c'
jne  nD
call input
mov  byte [cs:sB], AL
jmp  SetVal

nD:
cmp  al, 'd'
jne  nE
call input
mov  byte [cs:sC], AL
jmp  SetVal

nE:
cmp  al, 'r'
je   Launch
cmp  al, 'q'
je   Quit
cmp  al, 'w'
je   Write
SetVal:
jmp  MainMenu
Write:
push cs
pop  ds
mov  ah, 0x40
mov  dx, 0x0100
int  21h
jmp  MainMenu
Launch:
;============================================================
cmp  byte [cs:s0], 0
je   NoPalette
mov  ah, 0x0b
mov  bh, 0
mov  bl, byte [cs:s0]
int  0x10
NoPalette:
;============================================================
cld
mov  ax, ds
add  ax, 0x1000
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, 0xB800
mov  gs, ax
std
;============================================================
NextFrame:
cmp  byte [cs:s9], 0
je   Fast
push CX
mov  CH, 0
mov  CL, byte [cs:s9]
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:s3], 0
je   NoXor
xor  al, byte [cs:s3]
NoXor:
cmp  al, byte [cs:s4]
je   Check
cmp  byte [cs:s8], 0
je   Default
sub  al, byte [cs:s8]
jmp  CheckEnd
Default:
inc  AL
jmp  CheckEnd
;============================================================
Check:
mov  al, 0
mov  dl, 0

cmp  byte [cs:s7], 0
je   None
push bx
mov  bh, 0
mov  bl, byte [cs:s7]
add  dl, [si + BX]
pop  bx
None:

cmp  byte [cs:sA], 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]
cmp  dl, byte [cs:s5]
jg   Work
cmp  dl, byte [cs:s1a]
je   Work
cmp  dl, byte [cs:s1b]
jne  CheckEnd
;============================================================
Work:
mov  al, byte [cs:sB]
CheckEnd:
cmp  al, byte [cs:s2]
jne  SetNext
;============================================================
mov  al, byte [cs:s6]
inc  byte [X_HEIGHT / 2 * X_WIDTH + X_WIDTH / 2]
;============================================================
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
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
;============================================================
prompt1 db 13,10,'Your Choice?$'
prompt2 db 13,10,'Hexidecimal Value?$'
i0  db 13,10,"0. border color=$"
i1  db 13,10,"1. main pattern=$"
i2  db 13,10,"2. secondary pattern=$"
i3  db 13,10,"3. number of stages=$"
i4  db 13,10,"4. offset setting=$"
i5  db 13,10,"5. device matrix=$"
i6  db 13,10,"6. precision factor=$"
i7  db 13,10,"7. kill cells (0/1)=$"
i8  db 13,10,"8. big blaster=$"
i9  db 13,10,"9. subtraction=$"
iA  db 13,10,"A. slow level=$"
iB  db 13,10,"B. diamonds on/off=$"
iC  db 13,10,"C. ultra pattern=$"
iD  db 13,10,"D. unused=$"
op  db 13,10,"(R)un$"
s0  db 0x0
s1a db 0x1
s1b db 0x2
s2  db 0xff
s3  db 0x0
s4  db 0x0
s5  db 0x7e
s6  db 0x1
s7  db 0x0
s8  db 0x0
s9  db 0x1
sA  db 0x1
sB  db 0x1
sC  db 0x00
buff db 8
;============================================================
    
Post 28 Jun 2011, 18:27
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 © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.