Bet te: source code.
Tehnoloģija bija tāda ka es kko kodēju C, tad kompilēju, tad dizasemblēju, tad kopēju uz .asm kodu,
un liku kopā asemblerā. Un pēc tam vēl ar hex editoru pielaboju gala produktu. (HIEW mācēja pat kodu pravīt.)
===== main.asm =====
; BBS intro
; by WaTT Software
; 04.05.1996
;
; com version
P286
JUMPS
LOCAL
INCLUDE INC\COPPER.ASM
include inc\setpal.asm
;----------------------------------------
;scroll text across the screen
;----------------------------------------
scroll macro
@1@30:
mov bx,_txtidx
mov al,_txt[bx]
mov _curchar,al
cmp _curchar,0 ; if char is zero, loop
jne short @1@86
mov _txtidx,0
jmp short @1@30 ; and restart
@1@86:
; for (bitpos=0;bitpos!=8;bitpos++)
@1@114:
;
; movedata(FP_SEG(buffer),FP_OFF(buffer),0xA000,320*180,320*16);
;
mov cx,320*16/2
mov di,320*180
mov es,SegA
MOV SI,OFFSET _BUFFER
rep movsw
;
; for (pixline=0;pixline!=16;pixline++)
;
mov _pixline,0
jmp @1@198
@1@142:
; movmem(&buffer[pixline*320+1],&buffer[pixline*320+0],319);
MOV CX,318/2
mov al,_pixline
mov ah,0
mov dx,320
imul dx
mov dx,ax
add ax,offset _buffer
mov di,ax
mov ax,dx
add ax,offset _buffer+1
MOV SI,AX
push ds
pop es
REP MOVSW
movsb ; parity har har
;
; buffer[pixline*320+319]=((peekb(font_seg,font_ofs+(curchar*16)+pixline) >> (7-bitpos))& 1)*(40+(txtidx +pixline+bitpos) %45);
;
mov al,_curchar
mov ah,0
mov cl,4
shl ax,cl
mov dx,_font_ofs
add dx,ax
mov al,_pixline
mov ah,0
add dx,ax
mov si,DX
PUsH DS
PUSH _FONT_SEG
POP DS
LODSB
POP DS
cbw
mov cl,7
sub cl,_bitpos
sar ax,cl
and ax,1
mov dl,_pixline
mov dh,0
mov cx,dx
push ax
mov ax,_txtidx
add ax,dx
mov dl,_bitpos
mov dh,0
add ax,dx
mov bx,45
xor dx,dx
div bx
add dx,40
pop ax
imul dx
push ax
mov ax,cx
mov dx,320
imul dx
mov bx,ax
pop ax
mov _buffer[bx+319],al
inc _pixline
@1@198:
cmp _pixline,16
je @@0
jmp @1@142
@@0:
inc _bitpos
@1@254:
cmp _bitpos,8
jne @@1
mov _bitpos,0 ; if equal
inc _txtidx
@@1:
; inc _txtidx
endm
;---------------------------------
; void DoCopper() main loop in programm - here
;---------------------------------
DOCOPPER macro
mov byte ptr iv,0
jmp short @4@114
@4@58:
mov al,byte ptr iv
mov ah,0
mov dx,15
imul dx
mov dl,byte ptr iv
mov dh,0
shl dx,1
mov bx,dx
mov word ptr _bartab[bx],ax
inc byte ptr iv
@4@114:
cmp byte ptr iv,3
jne short @4@58
CLD
@4@170:
movebars
CLI
MOV DX,03DAH
@@@1:
in al,dx
test al,08
JNE @@@1
@@@2:
in al,dx
test al,08
je @@@2
copperbars
SCROLL
STI
IN AL,60H ; check ESC
CMP AL,1
jnz @4@170
ENDM
; =====================
; DRAW LOG0
; =====================
DRAWLOGO macro
mov ax,SegB
mov SegC,ax
mov doff,5 ; y offset
mov ax,tSeg
mov es,ax
MOV SI,TOFF
mov bp,offset string
;
; for (ch=0;ch!=12;ch++)
;
FOR_LOOP:
mov _ch,0
jmp ch_FOR_CMP
ch_FOR_LOOP:
;
; {
; for (y=0;y!=16;y++)
;
mov y,0
jmp y_FOR_CMP
y_FOR_LOOP:
;
; {for (x=0;x!=8;x++)
;
mov x,0
jmp x_FOR_CMP
x_FOR_LOOP:
;
; buffer[y*8+x]=((peekb(tSeg,tOff+string[ch]*16+y)>>(7-x))&1)?grad[(ch+y+x)%4]:' ';
;
xor bx,bx
mov bl,_ch
mov al,cs:[bp]
cbw
mov cl,y_shift
shl ax,cl
mov bx,tOff
add bx,ax
mov al,y
xor ah,ah
add bx,ax
mov es,tSeg
mov al,byte ptr es:[bx] ; get font byte
cbw
mov cl,7
sub cl,x
sar ax,cl
test al,1
je SPACE
; xor ah,ah
; mov al,_ch
; xor bh,bh
; mov bl,y
; add ax,bx
; xor bh,bh
; mov bl,x
; add ax,bx
; mov bx,16 ; mod
; cwd
; idiv bx
; mov al,dl
mov al,Ncolor ; color of next
jmp short SYMBOL
SPACE:
xor al,al
SYMBOL:
;
; pokeb(0xB800,0x0000+y*132*2+x*2+ch*2*8+40,buffer[y*8+x]);
;
push ax
xor ah,ah
mov al,y
add al,y
add al,doff ; offset dn
mov dx,320
imul dx
xor dh,dh
mov dl,x
shl dx,1
add ax,30 ; -> modify here
add ax,dx ; for logo offset from
xor dh,dh ; left. !!!!
mov dl,_ch
shl dx,1
mov cl,3
shl dx,cl
add ax,dx
add ax,5
mov di,ax
mov es,SegC
pop ax
stosb
stosb
add di,318
stosb
stosb
inc x
x_FOR_CMP:
cmp x,8
je @@01
jmp x_FOR_LOOP
@@01:
inc y
Y_FOR_CMP:
mov al,maxy
cmp y,al
je @@2
jmp y_FOR_LOOP
@@2:
inc _ch
inc bp
ch_FOR_CMP:
cmp _ch,16
je @@3
jmp ch_FOR_LOOP
@@3:
CALL SMEAR_OUT
; MOV STARX,320*30+90
; MOV TOX,240
; call smear
; CMP DOFF,20 ; smear 2 pass
; JZ @@31
; MOV DOFF,20
; JMP short @@3
;@@31:
CMP DOFF,90
JZ @@4
MOV DOFF,90
mov ax,1130h ; get font
mov bh,03h ; 8x8
int 10h
mov tSeg,es
mov tOff,bp
mov maxy,8
mov y_shift,3
mov bp,offset string2
mov ncolor,1
mov ax,SegA ; init Rseg
mov SegC,ax
jmp FOR_LOOP
@@4:
ENDM
code segment para public 'CoDE'
assume cs:code,ds:code
ORG 100h
;========================================================================
; main ... init and deinit ...
;========================================================================
MAIN PROC
push cs
pop ds
cld
xor ax,ax
push cs
pop es
mov di,offset start_data
mov cx,data_length
rep stosb
mov si,offset _sintab
mov di,offset _stab
mov cx,256
@@iSin:
lodsb
; xchg ah,al
stosw
; xor ah,ah
loop @@iSin
mov ax,offset SPBUFFER
shr ax,4 ; div 16
mov bx,ds
add bx,ax
mov SegB,bx
mov ax,1130h
mov bh,06h
int 10h
mov _font_seg,es
mov _font_ofs,bp
MOV AX,1130H ; get font
mov bh,06h
int 10h
mov tSeg,es
mov tOff,bp
mov ax,0013h ; set video mode
INT 10H
CLI
MOV DX,03DAH
@@@a1:
in al,dx
test al,08
JNE @@@a1
@@@a2:
in al,dx
test al,08
je @@@a2
STI
SETPAL
DRAWLOGO
docopper ; get into main loop
@@5:
mov ah,1 ; clear KBD buffer
int 16h
jz ExiT
xor ah,ah
int 16h
jmp @@5 ; getch
EXIT:
mov cx,320*16/2
mov di,320*180
mov es,SegA
MOV SI,OFFSET ZEROBUFFER
rep movsw
MOV CX,15
@@s_out:
PUSH CX
CALL SMEAR_OUT
POP CX
LOOP @@S_OUT
mov ax,0003h
INT 10H
mov ah,09
mov dx,offset endStrg ; display end message
int 21h
mov ah,02h
xor bh,bh
xor dl,dl
mov dh,20
INT 10H
RET
MAIN ENDP
include inc\smear.asm
SMEAR_OUT PROC
MOV STARX,20
MOV TOX,90
CALL SMEAR
MOV STARX,110
MOV TOX,200
CALL SMEAR
PUSH DS
PUSH CX
mov es,SegA
mov ds,SegB
mov di,320*20
mov cx,320*45/2
mov si,320*4
REP MOVSW ; display logo
POP CX
POP DS
ENDP
include INC\data.inc
ends
END MAIN
====== inc\copper.asm =====
;------------------------
; void movebars() movement
;------------------------
MOVEBARS macro
MOV AX,0
PUSH DS
POP ES
MOV DI,OFFSET _PAL
MOV CX,750/2
REP STOSW
;
; for (n=0;n!=bars;n++)
;
xor si,si
jmp @2@338
@2@58:
;
; {for (i=0;i!=31;i++) pal[n%3+3*stab[bartab[n]]+3*i]=2*i;
;
mov word ptr mbi,0
jmp short @2@142
@2@86:
mov ax,si
mov bx,3
xor dx,dx
div bx
mov bx,si
shl bx,1
mov bx,word ptr _bartab[bx]
shl bx,1
mov ax,word ptr _stab[bx]
mov bx,3
push dx
imul bx
pop bx
add bx,ax
mov ax,word ptr mbi
mov dx,3
imul dx
add bx,ax
mov al,byte ptr mbi
shl al,1
mov byte ptr _pal[bx],al
inc word ptr mbi
@2@142:
cmp word ptr mbi,32
jne short @2@86
;
; for (i=0;i!=31;i++) pal[n%3+3*stab[bartab[n]]+3*32+3*i]=63-2*i;
;
mov word ptr mbi,0
jmp short @2@254
@2@198:
mov ax,si
mov bx,3
xor dx,dx
div bx
mov bx,si
shl bx,1
mov bx,word ptr _bartab[bx]
shl bx,1
mov ax,word ptr _stab[bx]
mov bx,3
push dx
imul bx
pop bx
add bx,ax
mov ax,word ptr mbi
mov dx,3
imul dx
add bx,ax
mov al,byte ptr mbi
shl al,1
mov dl,63
sub dl,al
mov byte ptr _pal[bx+96],dl
inc word ptr mbi
@2@254:
cmp word ptr mbi,32
jne short @2@198
;
; bartab[n]=1+bartab[n]%255;
;
mov bx,si
shl bx,1
mov ax,word ptr _bartab[bx]
mov bx,255
xor dx,dx
div bx
inc dx
mov bx,si
shl bx,1
mov word ptr _bartab[bx],dx
inc si
@2@338:
cmp si,3
je @@00
jmp @2@58
@@00:
@@mb_exit:
;ret
ENDM
;----------------------------
; void copperbars() Draw the coppers
;----------------------------
COPPERBARS macro
; CLI
xor si,si
;
; for (l=0;l!=size;l++)
;
xor cx,cx
jmp short @3@254
@3@86:
;
; outportb(0x3c8,0);
;
mov dx,968
mov al,0
out dx,al
;
; outportb(0x3c9,pal[cc]);
;
mov al,byte ptr _pal[si]
mov dx,969
out dx,al
;
; outportb(0x3c9,pal[cc+1]);
;
mov al,byte ptr _pal[si+1]
mov dx,969
out dx,al
jmp short @3@114
@3@114:
;
; while ((inportb(0x3da)&1)!=0) ;
;
mov dx,986
in al,dx
test al,1
jne short @3@114
jmp short @3@170
@3@170:
;
; while ((inportb(0x3da)&1)==0) ;
;
mov dx,986
in al,dx
test al,1
je short @3@170
;
; outportb(0x3c9,pal[cc+2]);
;
mov al,byte ptr _pal[si+2]
mov dx,969
out dx,al
add si,3
inc cx
@3@254:
cmp cx,250
JNE SHORT @3@86
; STI
@@cb_exit:
;ret
ENDM
===== inc\setpal.asm =====
; set palette green gradient
; (you name it)
; selfmodifying code? dunno.
SETPAL macro
MOV CH,32
XOR CL,CL
MOV DX,3C9H
@@DLOP:
DEC DX
MOV AL,CL
OUT DX,AL
INC DX
MOV AL,0
OUT DX,AL
MOV AL,CL
SHL AL,1
OUT DX,AL
MOV AL,0
OUT DX,AL
INC CL
CMP CL,CH
JNZ @@DLOP
DEC DX ; 32 color is BLACK
MOV AL,CL
OUT DX,AL
INC DX
MOV AL,0
OUT DX,AL
OUT DX,AL
OUT DX,AL
; RET
ENDM
===== inc\data.inc ======
SegA dw 0a000h
endStrg db " The "
string db "R3aL C0DeR's BBS"
db ". call (371)-72435xx every day: 00:00-07:00",13,10,'$'
string2 db "! call us now ! "
grad db 15
_sintab label byte ; sintab
include inc\sintab.inc
maxy db 16
Y_SHIFT DB 4
ncolor db 32
_TXT LABEL BYTE
include inc\stext.inc ; soup
;) ============== CUT HERE =============
start_data: ; start uninitialised data
db 0 ; EndOF _TXT (ASCIIZ)
doff db 0
iv db 0
tSeg dw 0
tOff dw 0
_pal label byte
db 750 dup (0)
_bartab label word
db 6 dup (0)
x db 0
y db 0
_ch db 0
_font_seg dw 0
_font_ofs dw 0
_curchar db 0
mbi dw 0
_bitpos db 0
_pixline db 0
_txtidx dw 0
_buffer DB 5120 DUP (0) ; screen buffer
zerobuffer DB 5120 DUP (0) ; screen buffer
_stab label word
dw 512 DUP(0) ; will be pre-processed
TOX db 0
STARX dw 0
SegB dw 0
SegC dw 0
ALIGN 16
SPBUFFER db 320*50 dup(0) ; screen logo preprocess buffer
data_length equ $-offset start_data
==== inc\sintab.inc =====
; sintable (hand optimised)
; byte space for it!
; should be RLE or something >;-] but i was too lazy to craft up
; any sin generator :(
DB 93,95,97,99,102,104,106,108,111,113,115,117,120
DB 122,124,126,128,130,132,134,136,139,140,142,144,146
DB 148,150,152,153,155,157,158,160,162,163,165,166
DB 167,169,170,171,172,174,175,176,177,178,179,179,180
DB 181,182,182,183,183,184,184,185,185,185,185,185
DB 185,185,185,185,185,185,185,184,184,184,183,183,182
DB 181,181,180,179,178,177,176,175,174,173,172,171
DB 169,168,167,165,164,162,161,159,158,156,154,153,151
DB 149,147,145,143,141,139,138,135,133,131,129,127
DB 125,123,121,119,116,114,112,110,107,105,103,101,98
DB 96,94,92,90,88,85,83,81,79,76,74,72,70,67,65
DB 63,61,59,57,55,53,51,48,47,45,43,41,39,37,35
DB 33,32,30,28,27,25,24,22,21,19,18,17,15,14,13
DB 12,11,10,9,8,7,6,5,5,4,3,3,2,2,2,1,1
DB 1,1,1,1,1,1,1,1,1,1,2,2,3,3,4,4,5,6,7
DB 7,8,9,10,11,12,14,15,16,17,19,20,21,23,24
DB 26,28,29,31,33,34,36,38,40,42,44,46,47,50,52
DB 54,56,58,60,62,64,66,69,71,73,75,78,80,82,84
DB 87,89,91,93
==== inc\smear.asm =====
; almost optimal code...
; slow anyway :(
;
; void _saveregs Smear(int starx, char TOX,char TOY)
;
TOY equ 40
Smear proc
push ES
Push DS
PUSH AX
PUSH BX
PUSH CX
PUSH DX
PUSH SI
PUSH DI
mov ch,TOY
mov dh,TOX
mov si,SegB
mov di,StarX
mov ds,si
mov es,si
mov si,di
cld
mov cl,0
jmp @3@1206
@3@310:
;
; for(_DL=0;_DL!=_DH;_DL++)
;
mov dl,0
jmp @3@982
@3@338:
sub si,321
xor ah,ah
lodsb
mov bx,ax
inc si
inc si
add si,320-3
lodsb
add bx,ax
inc si
lodsb
add bx,ax
add si,320-3
inc si
inc si
lodsb
add bx,ax
xchg bx,ax
shr ax,2
stosb
mov si,di
inc dl
@3@982:
cmp dl,dh
je s@@0
jmp @3@338
s@@0:
xchg ax,di
add ax,320
sub al,dh
sbb ah,0
mov di,ax
mov si,di
inc cl
@3@1206:
cmp cl,ch
je s@@1
jmp @3@310
s@@1:
POP DI
POP SI
POP DX
POP CX
POP BX
POP AX
POP DS
POP ES
ret
Smear endp
==== inc\stext.inc ====
; Scrolltext goes (scrolls) here
db " The programming oriented board in RiGA,LATVIA exclusively for "
db " C++ and ASM sources, GFX and GAMES programming ! ... pascal is"
db " considered pseydocode ;) ... call the XX bbs and get into -"
db "THE CODING POWER!- Upload your releases and enjoy ... "
db " Intro coded by WaTT, the SysOp of XX "