Electronic Birthday Cake



This is a lot of source code and all the .incs and .dat are at the
end. Contact me if would like the executable. Run from a full screen
window in XP.

; birthday.asm Tasm code
; To make the .exe, use tasm32.exe
; tasm32 birthday
; tlink birthday /3 (to Enable 32-bit processing)
; This version has some jumps changed to short jumps
;
; This file has all the includes as well at the bottom !!
;
; Electronic_Birthday_Cake________ V01.10
;
; Date:23-Nov-93
;
; Copyright (C) 1993 by F.Becker aka -=* SliQ *=-
;
; Normal Assembly Program Header
; (Simplified Segment Definitions)

MaxPts EQU 1146

DOSSEG
;**************************************************
..MODEL Compact
..386
;**************************************************
..STACK 100h
;**************************************************
..DATA

;Sines and cosines used in rotations
Xsin dd 0
Xcos dd 0
Ysin dd 0
Ycos dd 0
Zsin dd 0
Zcos dd 0

palblack db 3*256 DUP (0) ;
palwhite db 3*256 DUP (63) ;
pal2 db 3*256 DUP (0) ;
pal3 db 3*256 DUP (0) ;

eyeposX dd 0
eyeposY dd 0
eyeposZ dd 0

lookatX dd 0
lookatY dd 0
lookatZ dd 0

VRCount dw 0
FrameReady dw 0
Frame dw 0
PalChanged dw 0

ClearColor db 0
WriteOffset dw 0
CurrPage dw 0
NextPage dw 19200
ClipMinX dw 1
ClipMinY dw 1
ClipMaxX dw 319
ClipMaxY dw 239

deg1 dw 0
deg2 dw 40

;**************************************************
..FARDATA @dataseg2

xtmp dd 0
ytmp dd 0
ztmp dd 0

dispptr dw offset starbuff1
clearptr dw offset starbuff2
staroffset dw 0
dw 1*MaxPts
dw 2*MaxPts
dw 3*MaxPts

sphere dd 3*MaxPts DUP (0)
bday dd 3*MaxPts DUP (0)
deltas dd 3*MaxPts DUP (0)

colors db MaxPts DUP (0)
db MaxPts DUP (0)
db MaxPts DUP (0)
db MaxPts DUP (0)

starbuff1 dw MaxPts DUP (0)
dw MaxPts DUP (0)
dw MaxPts DUP (0)
dw MaxPts DUP (0)

starbuff2 dw MaxPts DUP (0)
dw MaxPts DUP (0)
INCLUDE Birthday.inc ;the arrays in birthday.inc are part of
starbuff2!

;**************************************************
..FARDATA @dataseg3

;**************************************************
..CODE

INCLUDE ModeX.inc
INCLUDE Fixed.inc
INCLUDE Random.inc
INCLUDE IntMisc.inc

;--------------------------------------------------
main proc ;main part of program

ASSUME gs:@dataseg2
ASSUME fs:@dataseg3

start:
Call DisableKbd

;set up datasegments
mov ax,@data
mov ds,ax
mov ax,@dataseg2
mov gs,ax
mov ax,@dataseg3
mov fs,ax
mov ax,0a000h
mov es,ax

; Fade to Black!
mov si,offset palblack
mov ax,200h
mov cx,256
Call FadeIn

Call InitPalette
Call Scron

mov si,offset pal2
mov al,0
mov cx,256
Call SetPal

;reorganize 'Happy Birthday' data
Call MakeBirthday
;create sphere points
Call MakeSphere

mov ax,NextPage
Call SetPage
mov ax,CurrPage
Call ShowPage
mov ax,CurrPage
xchg ax,NextPage
mov CurrPage,ax

;set up interrupts
Call SetINT9
Call SetINT8

main1:
;calc new eyeposition and lookat
Call CalcEye
;rotate and draw
Call DrawPoints

;change page - will take effect next VR
mov ax,CurrPage
Call ShowPage
inc FrameReady

main2: ;synchronize with timer
cmp FrameReady,0
jne main2

mov ax,NextPage
Call SetPage
mov ax,NextPage
xchg ax,CurrPage
mov NextPage,ax

; clear points on other page
Call ClearPoints

mov ax,dispptr
xchg ax,clearptr
mov dispptr,ax

;NOTE : transformations are still CPU-speed dependent
; (it'll always take 32 frames to transform)
; I was to lazy to fix this. Maybe you would
; like to get frustrated over this |-)
mov ax,Frame
and ax,1ffh
cmp ax,112
jle short main4
cmp ax,144
jg short main3
Call Transform1
jmp short short main4
main3:
cmp ax,368
jle main4
cmp ax,400
jg short main4
Call Transform2
main4:

inc Frame
in al,60h
dec al ;someone hugged ESC?
jz short main6
jmp main1

main6:
; Fade White!
mov si,offset palwhite
mov ax,0a00h ;fade towards white - fast
mov cx,256
Call FadeIn

; Fade Out!
mov si,offset palblack
mov ax,0400h ;fade towards black - medium speed
mov cx,256
Call FadeIn

; get those old int vectors back in place
Call RestoreINT8
Call RestoreINT9

Call Scroff

Call EnableKbd

;back to DOS
mov ax,4c00h
int 21h

main endp
;--------------------------------------------------
;called every VR - from INT8handler
HouseKeeper PROC

pusha
inc VRCount

mov FrameReady,0

add deg1,3
add deg2,2
popa
ret

HouseKeeper ENDP
;--------------------------------------------------

MakeSphere PROC

xor di,di
makesp1:
Call CalcSphere

mov eax,xtmp
mov sphere[di],eax
mov ebx,bday[di]
sub ebx,eax
sar ebx,5
mov deltas[di],ebx

mov eax,ytmp
mov sphere[di+4],eax
mov ebx,bday[di+4]
sub ebx,eax
sar ebx,5
mov deltas[di+4],ebx

mov eax,ztmp
mov sphere[di+8],eax
mov ebx,bday[di+8]
sub ebx,eax
sar ebx,5
mov deltas[di+8],ebx

add di,12
cmp di,12*(MaxPts-1)
jle makesp1

MakeSphere ENDP

; modifies : eax,ebx,ecx,edx,si
CalcSphere PROC

mov ecx,4096

Call Random
xor edx,edx
div ecx
mov xtmp,edx

sub ecx,edx
Call Random
xor edx,edx
div ecx
mov ytmp,edx

sub ecx,edx
mov ztmp,ecx

mov ecx,xtmp
shl ecx,14
Call Sqrt
mov xtmp,eax

mov ecx,ytmp
shl ecx,14
Call Sqrt
mov ytmp,eax

mov ecx,ztmp
shl ecx,14
Call Sqrt
mov ztmp,eax

Call Random

test ax,1
jz short noneg1
neg xtmp
noneg1:

test ax,2
jz short noneg2
neg ytmp
noneg2:

test ax,4
jz short noneg3
neg ztmp
noneg3:

ret

CalcSphere ENDP
;--------------------------------------------------
MakeBirthday PROC

xor si,si
xor ebx,ebx

mov cx,MaxPts
MBir1:
xor eax,eax
mov ax,oldstars1[ebx]
sub ax,150
cwde
shl eax,16
mov dword ptr bday[si],eax
add si,4

xor eax,eax
mov ax,oldstars2[ebx]
sub ax,55
cwde
shl eax,16
mov dword ptr bday[si],eax
add si,8
add ebx,2
loop MBir1

ret

MakeBirthday ENDP
;--------------------------------------------------
CalcEye PROC

;calc eye position
mov bx,deg1
Call Sin
shl eax,6
mov ebx,12*(750)
add eax,sphere[ebx]
mov eyeposX,eax

mov bx,deg2
Call Cos
shl eax,5
;mov ebx,12*(750)+4
sub eax,65536*20
;add eax,sphere[ebx]
mov eyeposZ,eax

mov bx,deg1
add bx,50
Call Cos
shl eax,6
neg eax
mov eyeposY,eax

;calc lookat (currently looking at point 750 which
;is part of the D in 'happy birthDay'
mov ebx,12*(750)
mov eax,sphere[ebx]
sub eax,eyeposX
sar eax,7
mov lookatX,eax

mov ebx,12*(750)+4
mov eax,sphere[ebx]
sub eax,eyeposY
sar eax,7
mov lookatY,eax

mov ebx,12*(750)+8
mov eax,sphere[ebx]
sub eax,eyeposZ
sar eax,7
mov lookatZ,eax

;calc sines and cosines for X and Y rotations
mov eax,lookatX
imul lookatX
add eax,8000h
adc edx,0
shrd eax,edx,16
mov ecx,eax

mov eax,lookatZ
imul lookatZ
add eax,8000h
adc edx,0
shrd eax,edx,16 ; 2 2 2
add ecx,eax ;ecx is (distance1) = lookatX + lookatZ

mov eax,lookatY
imul lookatY
add eax,8000h
adc edx,0
shrd eax,edx,16 ; 2 2 2
add eax,ecx ;eax is (distance2) = dist1 + lookatY

push eax
Call Sqrt
mov ebx,eax ;eax is dist1
mov edx,lookatX
xor eax,eax
shrd eax,edx,16
sar edx,16
idiv ebx
mov Ysin,eax ;sin = lookatX/dist1

mov edx,lookatZ
xor eax,eax
shrd eax,edx,16
sar edx,16
idiv ebx
mov Ycos,eax
pop ecx ;cos = lookatZ/dist1

push ebx
Call Sqrt
mov ebx,eax ;eax is dist2
mov edx,lookatY
xor eax,eax
shrd eax,edx,16
sar edx,16
idiv ebx
mov Xsin,eax ;sin = lookatY/dist2

pop edx ;edx = dist1
xor eax,eax
shrd eax,edx,16
sar edx,16
idiv ebx
mov Xcos,eax ;cos = dist1/dist2

ret

CalcEye ENDP
;--------------------------------------------------
InitPalette PROC

xor bx,bx
mov cx,256
initpal1:
mov al,cl
shr al,2
mov pal2[bx+0],0 ;red
mov pal2[bx+1],al ;green
mov pal2[bx+2],0 ;blue
mov pal3[bx],al ;help entry
add bx,3
loop initpal1
ret

InitPalette ENDP
;--------------------------------------------------
DrawPoints PROC


xor ecx,ecx
mov cx,dispptr
mov word ptr gs:[ecx],0
mov word ptr gs:[ecx+(2*MaxPts)],0
mov word ptr gs:[ecx+(4*MaxPts)],0
mov word ptr gs:[ecx+(6*MaxPts)],0

mov ecx,12*(MaxPts-1)
dpts1:
push ecx
mov eax,sphere[ecx]
sub eax,eyeposX
mov Xtmp,eax

mov eax,sphere[ecx+4]
sub eax,eyeposY
mov Ytmp,eax

mov eax,sphere[ecx+8]
sub eax,eyeposZ
mov Ztmp,eax

mov si,offset Xtmp
Call RotateY
mov Xtmp,ebx
mov Ztmp,ecx

Call RotateX
mov Ytmp,ebx
mov Ztmp,ecx

cmp ecx,65536 ;ignore points with Z<1
jl short dpts2

mov ebx,ecx
Call Three2TwoD
shr ecx,16
shr edx,16
add ecx,160
add edx,120
shr ebx,15
sub bx,10
cmp bx,256
jl short dpts3
mov bl,255 ;bl - color, ecx-X, edx-Y
dpts3:
mov al,bl
Call EnterDot
dpts2:
pop ecx
sub ecx,12
jge dpts1

Call ShootEm

ret

DrawPoints ENDP
;--------------------------------------------------
EnterDot PROC

cmp dx,[ClipMaxY]
jae NoEnter
cmp dx,[ClipMinY]
jb NoEnter

cmp cx,[ClipMaxX]
jae short NoEnter
cmp cx,[ClipMinX]
jb short NoEnter

nop
mov bx,cx
and bx,011b
shl bx,1
mov bx,staroffset[bx]
mov si,bx
shl si,1
add si,dispptr
add bx,gs:[si]
inc word ptr gs:[si]
mov colors[bx],al
shl bx,1
mov si,bx
add si,dispptr
add si,2
shr cx,2
xor ebx,ebx
mov bx,dx
shl bx,4
lea ebx,[ebx+4*ebx]
add bx,cx
add bx,[WriteOffset]
mov gs:[si],bx

NoEnter:
ret

EnterDot ENDP
;--------------------------------------------------
ShootEm PROC

nop
mov bx,dispptr
xor si,si

mov cx,gs:[bx]
or cx,cx
jz shoot2
add bx,2

mov ax,0100h + MAP_MASK ;AL = index in SC of Map Mask reg
mov dx,SC_INDEX ;set the Map Mask to enable only the
out dx,ax ; pixel's plane
shoot1:
mov al,colors[si]
mov di,gs:[bx]
mov es:[di],al
add bx,2
inc si
loop shoot1
shoot2:

mov bx,dispptr
add bx,MaxPts*2
xor si,si

mov cx,gs:[bx]
or cx,cx
jz short shoot4
add bx,2

mov ax,0200h + MAP_MASK ;AL = index in SC of Map Mask reg
mov dx,SC_INDEX ;set the Map Mask to enable only the
out dx,ax ; pixel's plane
shoot3:
mov al,colors[si+MaxPts]
mov di,gs:[bx]
mov es:[di],al
add bx,2
inc si
;stosb
loop shoot3
shoot4:

mov bx,dispptr
add bx,MaxPts*4
xor si,si

mov cx,gs:[bx]
or cx,cx
jz shoot6
add bx,2

mov ax,0400h + MAP_MASK ;AL = index in SC of Map Mask reg
mov dx,SC_INDEX ;set the Map Mask to enable only the
out dx,ax ; pixel's plane
shoot5:
mov al,colors[si+2*MaxPts]
mov di,gs:[bx]
mov es:[di],al
add bx,2
inc si
;stosb
loop shoot5
shoot6:

mov bx,dispptr
add bx,MaxPts*6
xor si,si

mov cx,gs:[bx]
or cx,cx
jz shoot8
add bx,2

mov ax,0800h + MAP_MASK ;AL = index in SC of Map Mask reg
mov dx,SC_INDEX ;set the Map Mask to enable only the
out dx,ax ; pixel's plane
shoot7:
mov al,colors[si+3*MaxPts]
mov di,gs:[bx]
mov es:[di],al
add bx,2
inc si
;stosb
loop shoot7
shoot8:

ret

ShootEm ENDP
;--------------------------------------------------
ClearPoints PROC

nop
mov bx,clearptr

mov cx,gs:[bx]
or cx,cx
jz clrem2
add bx,2

mov ax,0100h + MAP_MASK ;AL = index in SC of Map Mask reg
mov dx,SC_INDEX ;set the Map Mask to enable only the
out dx,ax ; pixel's plane
clrem1:
mov di,gs:[bx]
mov byte ptr es:[di], 0
add bx,2
loop clrem1
clrem2:

mov bx,clearptr
add bx,MaxPts*2

mov cx,gs:[bx]
or cx,cx
jz clrem4
add bx,2

mov ax,0200h + MAP_MASK ;AL = index in SC of Map Mask reg
mov dx,SC_INDEX ;set the Map Mask to enable only the
out dx,ax ; pixel's plane
clrem3:
mov di,gs:[bx]
mov byte ptr es:[di], 0
add bx,2
loop clrem3
clrem4:

mov bx,clearptr
add bx,MaxPts*4

mov cx,gs:[bx]
or cx,cx
jz clrem6
add bx,2

mov ax,0400h + MAP_MASK ;AL = index in SC of Map Mask reg
mov dx,SC_INDEX ;set the Map Mask to enable only the
out dx,ax ; pixel's plane
clrem5:
mov di,gs:[bx]
mov byte ptr es:[di], 0
add bx,2
loop clrem5
clrem6:

mov bx,clearptr
add bx,MaxPts*6

mov cx,gs:[bx]
or cx,cx
jz clrem8
add bx,2

mov ax,0800h + MAP_MASK ;AL = index in SC of Map Mask reg
mov dx,SC_INDEX ;set the Map Mask to enable only the
out dx,ax ; pixel's plane
clrem7:
mov di,gs:[bx]
mov byte ptr es:[di], 0
add bx,2
loop clrem7
clrem8:

ret

ClearPoints ENDP
;--------------------------------------------------
Transform1 PROC

mov ecx,12*(MaxPts-1)
trans1:
mov eax,deltas[ecx]
add sphere[ecx],eax
mov eax,deltas[ecx+4]
add sphere[ecx+4],eax
mov eax,deltas[ecx+8]
add sphere[ecx+8],eax
sub ecx,12
jge trans1

xor bx,bx
trans4:
mov al,pal3[bx]
dec al
cmp pal2[bx],al
jge trans2
add pal2[bx],2
sub pal2[bx+1],2
jmp short trans3
trans2:
inc al
mov pal2[bx],al
mov pal2[bx+1],0
trans3:
add bx,3
cmp bx,768
jl trans4

mov si,offset pal2
mov al,0
mov cx,256
Call SetPal

ret

Transform1 ENDP
;--------------------------------------------------
Transform2 PROC

mov ecx,12*(MaxPts-1)
transf1:
mov eax,deltas[ecx]
sub sphere[ecx],eax
mov eax,deltas[ecx+4]
sub sphere[ecx+4],eax
mov eax,deltas[ecx+8]
sub sphere[ecx+8],eax
sub ecx,12
jge transf1

xor bx,bx
transf4:
mov al,pal2[bx]
sub al,2
jb transf2
mov pal2[bx],al
add pal2[bx+1],2
jmp short transf3
transf2:
mov al,pal3[bx]
mov pal2[bx+1],al
mov pal2[bx],0
transf3:
add bx,3
cmp bx,768
jl transf4

mov si,offset pal2
mov al,0
mov cx,256
Call SetPal

ret

Transform2 ENDP

END start

; random.inc
;
;ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
;º Name:Random_Number_Generator_________ V01.00 º
;º º
;º Modified:29-Oct-93 FB º
;ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
;

;**************************************************

random64 dd 423497850,293874509,872340985,720349875,029834709
dd 389735263,249879782,435345234,852938745,982697526
dd 924387349,824624386,423645625,602586386,478557463
dd 101398630,987197471,051798980,798517092,309717542
dd 523778179,801324079,705476523,976215378,913405967
dd 078231980,357243764,320743262,306743789,420970738
dd 437809432,784284784,789017893,478248247,437624367
dd 436984342,362436234,122433436,266802430,984360250
dd 346230523,487023872,436876234,987625978,632874675
dd 432689432,872398243,698259634,062398734,652986324
dd 439084327,623462397,823486567,243729784,376576237
dd 439082364,624397825,398749234,862354987,525268234
dd 342098742,397843269,234983498,986538974

seed1 db 29
seed2 db 63


;--------------------------------------------------
; Random - Random Number Generator
; IN : -
; OUT : - eax
; Modified : eax,ebx
; Vars Used: random64,seed1,seed2 (local cs)

Random PROC

xor ebx,ebx
mov bl,cs:seed1
mov eax,cs:random64[4*ebx]

mov bl,cs:seed2
add eax,cs:random64[4*ebx]

mov cs:random64[4*ebx],eax
inc cs:seed1
and cs:seed1,63
inc cs:seed2
and cs:seed2,63

ret

Random ENDP

; modex.inc
;
;ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
;º Name:Mode_X_(320x240)_Routines_______ V01.00 º
;º º
;º Modified:22-Nov-93 FB º
;ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
;
; All code assumes that ES points to video segment!
;
;**************************************************
; Vars NOT defined in this INC file
; WriteOffset:word
; ClipMinX:word
; ClipMinY:word
; ClipMaxX:word
; ClipMaxY:word
; ClearColor:byte

;General Regs
MISC_OUTPUT equ 03c2h
MISC_OUTPUT_READ equ 03cch
FCW equ 03dah
FCR equ 03cah
INPUT_STATUS_0 equ 03c2h
INPUT_STATUS_1 equ 03dah

;Sequencer Regs
SC_INDEX equ 03c4h
SC_DATA equ 03c5h
MAP_MASK equ 02h

;CRTC Regs
CRTC_INDEX equ 03d4h
CRTC_DATA equ 03d5h

;Graphics Regs
GC_INDEX equ 03ceh
GC_DATA equ 03cfh
READ_MAP equ 04h

;Attribute Regs
ACW_FF equ 03c0h
ACR_FF equ 03c1h

;Color Regs
PEL_GET equ 03c7h
PEL_SET equ 03c8h
PEL_DATA equ 03c9h

START_ADDRESS_HIGH equ 0ch ;bitmap start address high byte
START_ADDRESS_LOW equ 0dh ;bitmap start address low byte

tmppal db 768 DUP (0) ;temp palette
DONE dw 0 ;temp word

; Sequencer Regs
Sequencer db 003h,021h,00fh,000h
SeqEnd db 006h

; CRTC Regs
CRTC db 05fh,04fh,050h,082h,054h,080h,00dh,03eh
db 000h,041h,000h,000h,000h,000h,003h,0c0h
db 0eah,02ch,0dfh,028h,000h,0e7h,006h,0e3h
CRTCEnd db 0ffh

; Graphics Regs
Graphics db 000h,000h,000h,000h,000h,040h,005h,00fh
GraphicsEnd db 0ffh

;Attribute Regs
Attrib db 041h,000h,00fh,000h
AttribEnd db 000h


; Scron - Sets ModeX 320x240x256
; IN : -
; OUT : -
; Modified : ax,cx,dx,si,di
; Vars Used: ClearColor
;
Scron PROC

mov dx,INPUT_STATUS_1
Scron1:
in al,dx
test al,08h
jz Scron1 ;vertical sync is active high (1 = active)

;turn screen off
mov dx,SC_INDEX
mov al,1
out dx,al
inc dx
in al,dx
or al,00100000b
out dx,al

mov cx,5
mov dx,ACW_FF
mov si,offset AttribEnd
Scron6:
mov al,cl
add al,2fh
out dx,al
mov al,cs:[si]
out dx,al
dec si
loop Scron6

mov cx,10h ;Bit 5 not set-> allow host access to pal
Scron5:
mov al,cl
dec al
out dx,al
out dx,al
loop Scron5

mov al,30h
out dx,al

mov dx,SC_INDEX
mov ax,0604h
out dx,ax ;disable chain4 mode
mov ax,0100h
out dx,ax ;synchronous reset while setting Misc Output
; for safety, even though clock unchanged
;General Regs
mov dx,MISC_OUTPUT
mov al,0e3h
out dx,al

mov si,offset SeqEnd
mov dx,SC_INDEX
mov cx,5
Scron2:
mov al,cl
dec al
mov ah,cs:[si]
dec si
out dx,ax
loop Scron2

mov si,offset CRTCEnd
mov dx,CRTC_INDEX
mov cx,19h
Scron3:
mov al,cl
dec al
mov ah,cs:[si]
dec si
out dx,ax
loop Scron3

mov si,offset GraphicsEnd
mov dx,GC_INDEX
mov cx,9
Scron4:
mov al,cl
dec al
mov ah,cs:[si]
dec si
out dx,ax
loop Scron4

mov dx,SC_INDEX
mov ax,0f02h
out dx,ax ;enable writes to all four planes

sub di,di ;point ES:DI to display memory
mov al,[ClearColor]
mov ah,al
mov cx,8000h ;# of words in display memory
rep stosw ;clear all of display memory

mov dx,03c4h ;turn screen on again
mov ax,0101h
out dx,ax

ret

Scron ENDP

;--------------------------------------------------------
;
; Scroff - Leaves ModeX
; IN : -
; OUT : -
; Modified : ax,dx
; Vars Used: -
;

Scroff PROC

mov dx,03c4h
mov al,1
out dx,al
inc dx
in al,dx
or al,00100000b
out dx,al
mov dx,INPUT_STATUS_1
WaitVS:
in al,dx
test al,08h
jz WaitVS ;vertical sync is active high (1 = active)

push ds
push 0000
pop ds
;we didn't use int10h to set video mode
;so we the old mode # is still set in
;BIOS data area.
mov al,ds:[0449h] ;get previous mode
mov ah,00h
int 10h
pop ds
ret

Scroff ENDP

;--------------------------------------------------
;
; ScrClear - Clears 320x240 Window
; IN : -
; OUT : -
; Modified : ax,cx,dx,di
; Vars Used: WriteOffset,ClearColor
;

ScrClear PROC

mov dx,SC_INDEX
mov ax,0f02h
out dx,ax ;enable writes to all four planes
mov di,[WriteOffset] ;point ES:DI to display memory
mov al,[ClearColor]
mov ah,al
mov cx,2580h ;# of words
cld
rep stosw ;clear all of page

ret

ScrClear ENDP

;--------------------------------------------------
; BoxClear - Clears Window on 4-pixel boundary
; IN : cx (XPos div 4)
; dx (YPos)
; ax (XLen div 4)
; bx (YLen)
; OUT : -
; Modified : ax,bx,cx,dx,di,es
; Vars Used: WriteOffset,ClearColor
;
;Note: This only clears on 4-pixel boundaries! - but FAST!

BoxClear PROC


xor edi,edi
mov di,dx
shl di,4 ;multiply by 16
lea edi,[edi+4*edi] ;multiply by 5
add di,cx
add di,[WriteOffset] ;point ES:DI to display memory
mov dx,80
sub dx,ax
mov cx,ax
cld
mov dx,SC_INDEX
mov ax,0f02h
out dx,ax ;enable writes to all four planes

mov al,[ClearColor]

boxclear1:
push cx
rep stosb ;clears horizontal line
pop cx
add di,dx
dec bx
jnz boxclear1

ret

BoxClear ENDP

;--------------------------------------------------
; ClearVGAMem - Clears VGA Video Memory
; IN : -
; OUT : -
; Modified : ax,cx,dx,di,es
; Vars Used: ClearColor

ClearVGAMem PROC

mov dx,SC_INDEX
mov ax,0f02h
out dx,ax ;enable writes to all four planes
sub di,di ;point ES:DI to display memory
mov al,[ClearColor]
mov ah,al
mov cx,8000h ;# of words in display memory
cld
rep stosw ;clear all of display memory

ret

ClearVGAMem ENDP

;--------------------------------------------------
; SetDot - Sets Dot/Pixel - with clipping
; IN : cx (XPos)
; dx (YPos)
; al (Color)
; OUT : -
; Modified : bx,cx,dx,es
; Vars Used: WriteOffset
;

SetDot PROC

cmp dx,[ClipMaxY]
jae NoDot
cmp dx,[ClipMinY]
jb NoDot

cmp cx,[ClipMaxX]
jae NoDot
cmp cx,[ClipMinX]
jb NoDot

push ax
xor eax,eax
mov ax,dx
;multyply by 80
shl ax,4 ;multiply by 16
lea eax,[eax+4*eax] ;multiply by 5

mov bx,cx
shr bx,2
add bx,ax ;offset of pixel in page
add bx,[WriteOffset] ;offset of pixel in display memory

and cl,011b ;pixel's plane
mov ax,0100h + MAP_MASK ;AL = index in SC of Map Mask reg
shl ah,cl ;set only the bit for the pixel's plane to 1
mov dx,SC_INDEX ;set the Map Mask to enable only the
out dx,ax ; pixel's plane

pop ax
mov es:[bx],al ;draw the pixel in the desired color
NoDot:
ret
SetDot ENDP

;--------------------------------------------------
; GetDot - Gets Dot/Pixel
; IN : cx (XPos)
; dx (YPos)
; OUT : ax (Color)
; Modified : bx,cx,dx,es
; Vars Used: WriteOffset
;

GetDot PROC

xor eax,eax
mov ax,dx
shl ax,4 ;multiply by 16
lea eax,[eax+4*eax] ;multiply by 5
mov bx,cx
shr bx,2
add bx,ax ;offset of pixel in page
add bx,[WriteOffset] ;offset of pixel in display memory

mov ah,cl
and ah,011b ;AH = pixel's plane
mov al,READ_MAP ;AL = index in GC of the Read Map reg
mov dx,GC_INDEX ;set the Read Map to read the pixel's
out dx,ax ; plane

mov al,es:[bx] ;read the pixel's color
sub ah,ah ;convert it to an unsigned int

ret

GetDot ENDP

;--------------------------------------------------
; SetCol - Sets Color Register
; IN : al (ColReg)
; ah (Red)
; bl (Green)
; bh (Blue)
; OUT : -
; Modified : ax,bx,dx
; Vars Used: -

SetCol PROC

mov dx,PEL_SET
out dx,al

inc dx

mov al,ah
out dx,al
mov al,bl
out dx,al
mov al,bh
out dx,al

ret

SetCol ENDP

;--------------------------------------------------
; SetPal - Sets Color Palette
; IN : ds:si (Ptr to Palette)
; al (ColReg - Start)
; cx (Range)
; OUT : -
; Modified : ax,cx,dx,si
; Vars Used: -
SetPal PROC

mov dx,PEL_SET
out dx,al

cld
mov dx,cx
shl cx,1
add cx,dx ;cx=cx*3

mov dx,INPUT_STATUS_1
WaitVS1:
in al,dx
test al,08h
jz WaitVS1 ;vertical sync is active high (1 = active)
mov dx,PEL_SET+1

palwrite:
outsb ;very fast V-cards don't like rep outsb
loop palwrite

ret

SetPal ENDP
;--------------------------------------------------
; FadeIn - Fades Current Palette into New Palette
; IN : ds:si (Ptr to (should-be) Palette)
; al (From ColReg)
; ah (Stepsize)
; cx (Range)
; OUT : -
; Modified : ax,bx,cx,dx,si,di,bp
; Vars Used: tmppal (local cs)
FadeIn PROC

mov dx,PEL_SET-1 ;PEL Read Mode Reg
out dx,al ;start reading PEL data from color entry FR_COL

mov dx,cx
shl cx,1
add cx,dx ;cx=cx*3
mov dx,PEL_SET+1 ;PEL Data Reg

mov bp,cx
mov di,offset tmppal
cld

push es
push cs
pop es
fadein5:
insb ;read PEL data
loop fadein5
pop es

xor ecx,ecx
mov cl,al
lea ecx,[ecx+2*ecx]

mov di,offset tmppal
add si,cx
add di,cx
xchg di,si
mov cx,bp

fadeagain:
;mov dx,PEL_SET ;PEL Read Mode Reg
;out dx,al ;start reading PEL data from color entry FR_COL

xor bp,bp ;number of colregs that actually changed

push si
push di
push cx
fadein1:
mov al,byte ptr [di] ;should-be-value
mov bl,byte ptr cs:[si]
sub bl,al ;compare with is-value
je fadein2 ;reached destination value?
jb fadein3

cmp bl,ah
jge fadein7
mov byte ptr cs:[si],al
jmp short fadein4
fadein7:
sub byte ptr cs:[si],ah ;should-be-value < is-value
jmp short fadein4
fadein3:
neg bl
cmp bl,ah
jge fadein8
mov byte ptr cs:[si],al
jmp short fadein4
fadein8:
add byte ptr cs:[si],ah
fadein4:

inc bp
fadein2:
inc di
inc si
loop fadein1
pop cx
pop di
pop si
or bp,bp ;have any colregs changed?
je fadedone

push cx
push si
mov dx,INPUT_STATUS_1
WaitVS2:
in al,dx
test al,08h
jz WaitVS2 ;vertical sync is active high (1 = active)

mov dx,PEL_SET ;PEL Read Mode Reg
mov al,0
out dx,al ;start reading PEL data from color entry FR_COL

mov dx,PEL_SET+1 ;PEL Data Reg
fadein6:
outs dx,byte ptr cs:[si] ;do the deed
loop fadein6

pop si
pop cx
jmp short fadeagain
fadedone:
ret

FadeIn ENDP
;--------------------------------------------------
; SetPage - Sets page to write to
; IN : ax (WriteOffset)
; OUT : -
; Modified : -
; Vars Used: -

SetPage PROC

mov [WriteOffset],ax
ret

SetPage ENDP

;--------------------------------------------------
; ShowPage - Sets page to show
; IN : ax (DisplayStart)
; OUT : -
; Modified : ax,bx,cx,dx
; Vars Used: -

;code originally from PC-Mag (?)

ShowPage PROC

; Wait for display enable to be active (status is active low), to be
; sure both halves of the start address will take in the same frame.
mov cx,ax
mov bh,cl
mov bl,START_ADDRESS_LOW
mov cl,START_ADDRESS_HIGH
mov dx,INPUT_STATUS_1
WaitDE:
in al,dx
test al,01h
jnz WaitDE ;display enable is active low (0 = active)

; Set the start offset in display memory of the page to display.
mov dx,CRTC_INDEX
mov ax,bx
out dx,ax ;start address low
mov ax,cx
out dx,ax ;start address high

; Now wait for vertical sync, so the other page will be invisible when
; we start drawing to it.

;we are synchronized with VR, so we don't need this...

;mov dx,INPUT_STATUS_1
;WaitVS3:
;in al,dx
;test al,08h
;jz WaitVS3 ;vertical sync is active high (1 = active)

ret
ShowPage ENDP


; intmisc.inc
;
;ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
;º Name:Video_Sync_And_Keyboard_INT_Routines º
;º º
;º Modified:23-Nov-93 FB º
;ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
;
;--------------------------------------------------------------
;
; SetINT8
; -INT8handler
; RestoreINT8
;
; SetINT9
; -INT9handler
; RestoreINT9
;
; DisableKbd
; EnableKbd
;
; WaitBorder
; GetRasterline
; WaitRasterline
;
;-----------------------------------------------------------------

frametime dw ?
oldINT8 dd ?
oldINT9 dd ?

;-----------------------------------------------------------------
INT8handler PROC FAR

;timer interrupt
push ax
push dx

mov al,20h
out 20h,al

mov dx,3dah
int8_1: in al,dx
test al,8
jz int8_1 ; wait for VR
;call waitborder

mov al,34h ; pulse
out 43h,al
mov al,byte ptr cs:[frametime]
out 40h,al
mov al,byte ptr cs:[frametime+1]
out 40h,al

;NOTE: we are now in a VR!
;if housekeeper takes relative long you might want to
;move it to the beginning of the handler and adjust
;the interrupt timing s.t. the prog gets interrupted
;some additional scan lines before the VR.
sti
call housekeeper
cli

pop dx
pop ax
iret
INT8handler ENDP

;-----------------------------------------------------------------
; SetINT8 - Sets Timer Interrupt (8) - timer synchronized with VR
; IN : -
; OUT : -
; Modified : ax,dx
; Vars Used: oldINT8,frametime


SetINT8 PROC NEAR
cli
;set up timer int vector
push es
xor ax,ax
mov es,ax
mov ax,es:[8*4]
mov word ptr cs:oldINT8[0],ax
mov ax,es:[8*4+2]
mov word ptr cs:oldINT8[2],ax
mov ax,offset INT8handler
mov es:[8*4],ax
mov es:[8*4+2],cs
pop es
sti

;find time it takes from VR to next VR
call waitborder
;set timer to max period 65536
mov al,34h ;pulse
out 43h,al
mov al,0
out 40h,al
mov al,0
out 40h,al

call waitborder
xor al,al ;latch present counter value
out 43h,al
in al,40h ;read LO
mov ah,al
in al,40h ;read HI
xchg al,ah

;counter counts down from 65536
;to find time: (65536-HILO)=-HILO
neg ax

;frametime = frametime-(frametime/128)
;make sure we never miss the beginning of a VR
mov dx,ax
shr ax,7 ;7 works fine with short housekeeper
sub dx,ax
mov cs:frametime,dx ;length of one frame

;set timer
call waitborder
mov al,34h ;pulse
out 43h,al
mov al,byte ptr cs:[frametime]
out 40h,al
mov al,byte ptr cs:[frametime+1]
out 40h,al
ret

SetINT8 ENDP

;-----------------------------------------------------------------
; RestoreINT8 - Restores Timer Interrupt (8)
; IN : -
; OUT : -
; Modified : ax,dx
; Vars Used: oldINT8


RestoreINT8 PROC NEAR
cli
push es
mov ax,0
mov es,ax
mov ax,WORD PTR cs:oldINT8[0]
mov dx,WORD PTR cs:oldINT8[2]
mov es:[8*4],ax
mov es:[8*4+2],dx
sti

; retore timer to old setting
mov al,34h ;pulse
out 43h,al
mov al,0
out 40h,al
mov al,0
out 40h,al
pop es
ret

RestoreINT8 ENDP

;-------------------------------------------------------------------
; DisableKbd - Disables Keyboard
; IN : -
; OUT : -
; Modified : ax
; Vars Used: -

DisableKbd PROC NEAR
in al,21h
or al,00000010b
out 21h,al
ret
DisableKbd ENDP

;-----------------------------------------------------------------
; EnablesKbd - Enables Keyboard
; IN : -
; OUT : -
; Modified : ax
; Vars Used: -

EnableKbd PROC NEAR
in al,21h
and al,11111101b
out 21h,al
ret
EnableKbd ENDP

;-----------------------------------------------------------------

INT9handler PROC FAR
push ax
in al,60h
; cmp al,01h ; ESC
; je nokey
cmp al,1ch ; RETURN
je nokey
; cmp al,39h ; SPACE
; je nokey

;ignore all other keys
in al,61h
mov ah,al
or al,80h
out 61h,al
xchg ah,al
out 61h,al
mov al,20h
out 20h,al
pop ax
iret

nokey:
pop ax
jmp cs:oldint9
INT9handler ENDP

;-----------------------------------------------------------------
; SetINT9 - Sets Keyboard Interrupt (9)
; IN : -
; OUT : -
; Modified : ax
; Vars Used: -

SetINT9 PROC NEAR
cli
push es
xor ax,ax
mov es,ax
mov ax,es:[9*4]
mov word ptr cs:oldint9[0],ax
mov ax,es:[9*4+2]
mov word ptr cs:oldint9[2],ax
mov ax,offset INT9handler
mov es:[9*4],ax
mov es:[9*4+2],cs
pop es
sti
ret
SetINT9 ENDP

;-----------------------------------------------------------------
; RestoreINT9 - Restores Keyboard Interrupt (9)
; IN : -
; OUT : -
; Modified : ax
; Vars Used: -

RestoreINT9 PROC NEAR
cli
push es
xor ax,ax
mov es,ax
mov ax,word ptr cs:oldint9[0]
mov bx,word ptr cs:oldint9[2]
mov es:[9*4],ax
mov es:[9*4+2],bx
pop es
sti
ret
RestoreINT9 ENDP

;-----------------------------------------------------------------
; Waitborder - Wait for next VR
; IN : -
; OUT : -
; Modified : -
; Vars Used: -

Waitborder PROC NEAR
push ax
push dx
mov dx,3dah
wbr1: in al,dx
test al,8
jnz wbr1
wbr2: in al,dx
test al,8
jz wbr2
pop dx
pop ax
ret
Waitborder ENDP

;-----------------------------------------------------------------
; GetRasterline - Gets current rasterline (not exact!) apprx range:
1..479
; IN : -
; OUT : ax (Rasterline)
; Modified : cx,dx
; Vars Used: frametime

GetRasterline PROC NEAR
;AX=scan line the VGA is in (requires ints set)
cli
xor al,al
out 43h,al
in al,40h
mov dl,al
in al,40h
mov dh,al

mov ax,cs:frametime
sub ax,dx
mov cx,506
mul cx
mov cx,cs:frametime
div cx
sub ax,26 ;adjust to 480 (506-26=480)

sti
ret
GetRasterline ENDP

;-----------------------------------------------------------------
; WaitRasterline - Wait until Rasterline (not exact!) apprx. range
1..479
; IN : dx (Rasterline)
; OUT : -
; Modified : ax,cx,dx
; Vars Used: frametime

WaitRasterline PROC NEAR
;returns when Scan Line=DX (requires ints set)
cli
mov cx,506 ;# of horizontal scan lines + VR
mov ax,480 ;# of horizontal scan lines
sub ax,dx
mul word ptr cs:frametime
div cx
mov cx,ax

waitraster1:
xor al,al
out 43h,al
in al,40h
mov ah,al
in al,40h
xchg al,ah
cmp ax,cx
ja waitraster1

sti

ret
WaitRasterline ENDP

; fixed.inc
;
;ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
;º Name:Fixed_Point_Routines____________ V01.00 º
;º º
;º Modified:15-Nov-93 FB º
;ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
;

INCLUDE TRIGTABL.DAT

;--------------------------------------------------
; FixedMul - Fixed Point Multiplication and rounding
; IN : - eax
; edx
; OUT : - eax
; Modified : eax,edx
; Vars Used: -

FixedMul PROC

imul edx
add eax,8000h
adc edx,0
shrd eax,edx,16
ret


FixedMul ENDP
;--------------------------------------------------
; FixedDiv - Fixed Point Division (No Rounding!)
; IN : - edx (edx div ebx)
; ebx
; OUT : - eax
; Modified : eax,ebx,edx

FixedDiv PROC

;mov edx,A
xor eax,eax
shrd eax,edx,16
sar edx,16
idiv ebx
ret

FixedDiv ENDP
;--------------------------------------------------
; Sin - Fixed Point Sine (lookup - circle=1024 steps)
; IN : bx (deg 0..1023)
; OUT : eax
; Modified : bx dx
Sin PROC

;mov bx,DEG ;0-> 1, 256-> 0, 512-> -1, 768-> 0
add bx,768 ;convert sin to cos
xor dx,dx
and bx,1023 ;Maxdegree
shl bx,1
mov ax,cs:trigtable[bx]
cmp bx,256*2 ;is it negative
jbe fcosi2
cmp bx,768*2
jae fcosi2
dec dx
fcosi2:
shl eax,16
shrd eax,edx,16
ret

Sin ENDP
;--------------------------------------------------
; Cos - Fixed Point Cosine (lookup - circle=1024 steps)
; IN : bx (deg 0..1023)
; OUT : eax
; Modified : bx dx
Cos PROC

;mov bx,DEG ;0-> 1, 256-> 0, 512-> -1, 768-> 0
xor dx,dx
and bx,1023 ;Maxdegree
shl bx,1
mov ax,cs:trigtable[bx]
cmp bx,256*2 ;is it negative
jbe fcosi
cmp bx,768*2
jae fcosi
dec dx
fcosi:
shl eax,16
shrd eax,edx,16
ret

Cos ENDP
;--------------------------------------------------
; SqrtLP - Fixed Point Square Root (Low Precision)
; IN : ecx
; OUT : eax
; Modified : ebx,ecx,edx

SqrtLP PROC
;NOTE:
;this function only gives a 8.8 precision !!!!!!!!!!!!!

xor eax,eax

mov ebx,40000000h
sqrtLP1:
mov edx,ecx ;edx = val
sub edx,ebx ;val - bitsqr
jl sqrtLP2
sub edx,eax ;val - root
jl sqrtLP2
mov ecx,edx ;val >= (root+bitsqr) -> accept subs
shr eax,1 ;root >> 1
or eax,ebx ;root | bitsqr
shr ebx,2 ;bitsqr>>2
jnz sqrtLP1
shl eax,8
ret
sqrtLP2:
shr eax,1 ;val < (root+bitsqr) -> dont change val
shr ebx,2 ;bitsqr>>2
jnz sqrtLP1
shl eax,8
ret

SqrtLP ENDP
;--------------------------------------------------
; Sqrt - Fixed Point Square Root (High/Normal Precision)
; IN : ecx
; OUT : eax
; Modified : ebx,ecx,edx
Sqrt PROC

;This is the High Precision version for the sqrt.
;It gives the optimal 8.16 precision but takes
;a little longer (24 iterations, 48 bits intead of
;16 iterations and 32 bits)

xor eax,eax ;eax is root
mov ebx,40000000h
sqrt1:
mov edx,ecx ;edx = val
sub edx,ebx ;val - bitsqr
jb sqrt2
sub edx,eax ;val - root
jb sqrt2
mov ecx,edx ;val >= (root+bitsqr) -> accept subs
shr eax,1 ;root >> 1
or eax,ebx ;root | bitsqr
shr ebx,2 ;bitsqr>>2
jnz sqrt1
jz sqrt5
sqrt2:
shr eax,1 ;val < (root+bitsqr) -> dont change val
shr ebx,2 ;bitsqr>>2
jnz sqrt1
; we now have the 8.8 precision

sqrt5:
mov ebx,00004000h
shl eax,16
shl ecx,16
sqrt3:
mov edx,ecx ;edx = val
sub edx,ebx ;val - bitsqr
jb sqrt4
sub edx,eax ;val - root
jb sqrt4
mov ecx,edx ;val >= (root+bitsqr) -> accept subs
shr eax,1 ;root >> 1
or eax,ebx ;root | bitsqr
shr ebx,2 ;bitsqr>>2
jnz sqrt3
ret
sqrt4:
shr eax,1 ;val < (root+bitsqr) -> dont change val
shr ebx,2 ;bitsqr>>2
jnz sqrt3
ret

Sqrt ENDP
;--------------------------------------------------
; RotateX - Fixed Point X-Axis-rotation
; IN : gs:si (ptr to x,y,z fixed point coords)
; Xsin ( sine )
; Xcos ( cosine )
; OUT :
; ebx (y)
; ecx (z)
; Modified : eax,edx,ebp
RotateX PROC

mov eax,gs:[si+4] ;get y value
imul Xcos ; y*cos
add eax,8000h
adc edx,0
shrd eax,edx,16
mov ebp,eax

mov eax,gs:[si+8] ;get z value
imul Xsin ; z*sin
add eax,8000h
adc edx,0
shrd eax,edx,16
sub ebp,eax ; y*cos-z*sin

mov eax,gs:[si+4] ;get y value
imul Xsin ; y*sin
add eax,8000h
adc edx,0
shrd eax,edx,16
mov ebx,ebp ;set up return register (y)
mov ebp,eax

mov eax,gs:[si+8] ;get z value
imul Xcos ; z*cos
add eax,8000h
adc edx,0
shrd eax,edx,16
add ebp,eax ; y*sin+z*cos
mov ecx,ebp ;set up return register (z)

ret

RotateX ENDP
;--------------------------------------------------
; RotateY - Fixed Point Y-Axis-rotation
; IN : gs:si (ptr to x,y,z fixed point coords)
; Ysin ( sine )
; Ycos ( cosine )
; OUT :
; ebx (x)
; ecx (z)
; Modified : eax,edx,ebp
RotateY PROC

mov eax,gs:[si] ;get x value
imul Ycos ; x*cos
add eax,8000h
adc edx,0
shrd eax,edx,16
mov ebp,eax

mov eax,gs:[si+8] ;get z value
imul Ysin ; z*sin
add eax,8000h
adc edx,0
shrd eax,edx,16
sub ebp,eax ; x*cos-z*sin

mov eax,gs:[si+8] ;get z value
imul Ycos ; z*cos
add eax,8000h
adc edx,0
shrd eax,edx,16
mov ebx,ebp ;set up return register (x)
mov ebp,eax ; z*cos

mov eax,gs:[si] ;get x value
imul Ysin ; x*sin
add eax,8000h
adc edx,0
shrd eax,edx,16
add ebp,eax ; z*cos+x*sin
mov ecx,ebp ;set up return register (z)

ret

RotateY ENDP
;--------------------------------------------------
; RotateZ - Fixed Point Z-Axis-rotation
; IN : gs:si (ptr to x,y,z fixed point coords)
; Zsin ( sine )
; Zcos ( cosine )
; OUT :
; ebx (x)
; ecx (y)
; Modified : eax,edx,ebp
RotateZ PROC

mov eax,gs:[si] ;get x value
imul Zcos ; x*cos
add eax,8000h
adc edx,0
shrd eax,edx,16
mov ebp,eax

mov eax,gs:[si+4] ;get y value
imul Zsin ; y*sin
add eax,8000h
adc edx,0
shrd eax,edx,16
sub ebp,eax ; x*cos-y*sin

mov eax,gs:[si] ;get x value
imul Zsin ; x*sin
add eax,8000h
adc edx,0
shrd eax,edx,16
mov ebx,ebp ;set up return register (x)
mov ebp,eax

mov eax,gs:[si+4] ;get y value
imul Zcos ; y*cos
add eax,8000h
adc edx,0
shrd eax,edx,16
add ebp,eax ; x*sin+y*cos
mov ecx,ebp ;set up return register (y)

ret

RotateZ ENDP
;--------------------------------------------------
; Three2TwoD - Fixed Point (x,y,z) to (x,y)
; IN : gs:si (ptr to x,y,z fixed point coords)
; ebx (z) value (usually gs:[si+8])
; OUT :
; ecx (x)
; edx (y)
; Modified : eax
Three2TwoD PROC

mov edx,gs:[si+4] ;get y-value
shl edx,7 ;zoom factor = 128

xor eax,eax
shrd eax,edx,16
sar edx,16
idiv ebx
mov ecx,eax

mov edx,gs:[si] ;get x-value
shl edx,7 ;zoom factor = 128

xor eax,eax
shrd eax,edx,16
sar edx,16
idiv ebx
mov edx,ecx
mov ecx,eax

ret

Three2TwoD ENDP

; Birthday.inc Don't put this in the file !!

oldstars1 dw 0063h, 0064h, 0065h, 0066h, 0070h, 0071h, 0072h, 007eh
dw 007fh, 0080h, 0081h, 0082h, 0083h, 0084h, 0085h, 0086h
dw 0090h, 0091h, 0092h, 0093h, 0094h, 0095h, 0096h, 0097h
dw 0098h, 0099h, 009ah, 009bh, 00a4h, 00a5h, 00a6h, 00a7h
dw 00a8h, 00a9h, 00aah, 00abh, 00ach, 00adh, 00aeh, 00afh
dw 00b8h, 00b9h, 00bah, 00bbh, 00bch, 00c5h, 00c6h, 00c7h
dw 00c8h, 00c9h, 00cah, 0062h, 0067h, 006fh, 0073h, 0074h
dw 007dh, 0087h, 008fh, 009ch, 009dh, 00a3h, 00b0h, 00b1h
dw 00b7h, 00bch, 00c4h, 00cbh, 0062h, 0067h, 006fh, 0075h
dw 007ch, 0088h, 008fh, 009eh, 009fh, 00a3h, 00b2h, 00b3h
dw 00b7h, 00bdh, 00c4h, 00cbh, 0061h, 0067h, 006eh, 0075h
dw 007bh, 0089h, 008fh, 00a0h, 00a3h, 00b4h, 00b7h, 00beh
dw 00c3h, 00cbh, 0061h, 0068h, 006eh, 0075h, 007bh, 008ah
dw 0090h, 0095h, 0096h, 0097h, 00a1h, 00a4h, 00a9h, 00aah
dw 00abh, 00b5h, 00b8h, 00beh, 00c3h, 00cah, 0061h, 0068h
dw 006eh, 0075h, 007ah, 0081h, 0082h, 0083h, 008bh, 0090h
dw 0095h, 0098h, 0099h, 009ah, 00a2h, 00a4h, 00a9h, 00ach
dw 00adh, 00aeh, 00b6h, 00b8h, 00bfh, 00c3h, 00cah, 0061h
dw 0068h, 006ch, 006dh, 006eh, 0075h, 007ah, 0080h, 0084h
dw 008bh, 0091h, 0095h, 009bh, 009ch, 00a2h, 00a5h, 00a9h
dw 00afh, 00b0h, 00b6h, 00b9h, 00c0h, 00c2h, 00c9h, 0061h
dw 0068h, 0069h, 006ah, 006bh, 0075h, 007ah, 007fh, 0085h
dw 008ch, 0091h, 0096h, 009dh, 00a2h, 00a5h, 00aah, 00b1h
dw 00b6h, 00bah, 00c1h, 00c8h, 0062h, 0076h, 0079h, 007fh
dw 0086h, 008ch, 0091h, 0096h, 009dh, 00a2h, 00a5h, 00aah
dw 00b1h, 00b6h, 00bbh, 00c7h, 0062h, 0076h, 0079h, 007eh
dw 0086h, 008dh, 0091h, 0096h, 009ch, 00a2h, 00a5h, 00aah
dw 00b0h, 00b6h, 00bbh, 00c6h, 0062h, 0076h, 0079h, 007eh
dw 0087h, 008dh, 0091h, 0096h, 009ch, 00a1h, 00a5h, 00aah
dw 00b0h, 00b5h, 00bch, 00c5h, 0061h, 0076h, 0079h, 007fh
dw 0080h, 0081h, 0082h, 0083h, 0084h, 0085h, 0086h, 008dh
dw 0091h, 0096h, 0097h, 0098h, 0099h, 009ah, 009bh, 00a1h
dw 00a5h, 00aah, 00abh, 00ach, 00adh, 00aeh, 00afh, 00b5h
dw 00bdh, 00c4h, 0061h, 006dh, 006eh, 0076h, 0079h, 008dh
dw 0091h, 00a0h, 00a5h, 00b4h, 00bch, 00c3h, 0061h, 0068h
dw 0069h, 006ah, 006bh, 006ch, 006fh, 0076h, 0079h, 008dh
dw 0091h, 009fh, 00a5h, 00b3h, 00bbh, 00c2h, 0061h, 0067h
dw 006fh, 0076h, 0079h, 008dh, 0091h, 009eh, 00a5h, 00b2h
dw 00bbh, 00c1h, 0061h, 0067h, 006fh, 0076h, 0079h, 008dh
dw 0090h, 009ch, 009dh, 00a4h, 00b0h, 00b1h, 00bah, 00c1h
dw 0060h, 0061h, 0067h, 006fh, 0075h, 0079h, 0080h, 0081h
dw 0082h, 0083h, 0084h, 0085h, 0086h, 008dh, 0090h, 0096h
dw 0097h, 0098h, 0099h, 009ah, 009bh, 00a4h, 00aah, 00abh
dw 00ach, 00adh, 00aeh, 00afh, 00bah, 00c0h, 0060h, 0067h
dw 006fh, 0075h, 0079h, 007fh, 0087h, 008dh, 0090h, 0096h
dw 00a4h, 00aah, 00b9h, 00c0h, 0060h, 0066h, 006fh, 0075h
dw 0079h, 007fh, 0087h, 008dh, 0090h, 0095h, 00a4h, 00a9h
dw 00b9h, 00bfh, 0060h, 0066h, 006fh, 0075h, 0079h, 007fh
dw 0087h, 008dh, 0090h, 0095h, 00a4h, 00a9h, 00b9h, 00bfh
dw 0060h, 0066h, 006fh, 0075h, 007ah, 007fh, 0087h, 008ch
dw 0090h, 0095h, 00a4h, 00a9h, 00b9h, 00bfh, 0061h, 0062h
dw 0063h, 0064h, 0065h, 0070h, 0071h, 0072h, 0073h, 0074h
dw 007bh, 007ch, 007dh, 007eh, 0088h, 0089h, 008ah, 008bh
dw 0091h, 0092h, 0093h, 0094h, 00a5h, 00a6h, 00a7h, 00a8h
dw 00bah, 00bbh, 00bch, 00bdh, 00beh, 005eh, 005fh, 0060h
dw 0061h, 005dh, 0062h, 005dh, 0062h, 005eh, 005fh, 0060h
dw 0061h, 0046h, 0047h, 0048h, 0049h, 004ah, 004bh, 004ch
dw 004dh, 004eh, 004fh, 0050h, 0051h, 005fh, 0060h, 0061h
dw 0067h, 0068h, 0069h, 006ah, 006bh, 006ch, 006dh, 006eh
dw 006fh, 0070h, 0071h, 0072h, 007ah, 007bh, 007ch, 007dh
dw 007eh, 007fh, 0080h, 0081h, 0082h, 0083h, 0084h, 0085h
dw 0086h, 0087h, 0088h, 0089h, 008ah, 008bh, 008ch, 008dh
dw 008eh, 008fh, 0093h, 0094h, 0095h, 0096h, 00a0h, 00a1h
dw 00a2h, 00a9h, 00aah, 00abh, 00ach, 00adh, 00aeh, 00afh
dw 00b0h, 00b1h, 00b2h, 00b3h, 00b4h, 00c3h, 00c4h, 00c5h
dw 00c6h, 00c7h, 00c8h, 00c9h, 00cah, 00cbh, 00d4h, 00d5h
dw 00d6h, 00d7h, 00e1h, 00e2h, 00e3h, 00e4h, 00e5h, 00e6h
dw 0045h, 0052h, 005eh, 0062h, 0066h, 0073h, 0074h, 0079h
dw 0090h, 0092h, 0097h, 009fh, 00a3h, 00a4h, 00a8h, 00b5h
dw 00b6h, 00c2h, 00cch, 00d3h, 00d8h, 00e0h, 00e7h, 0045h
dw 0053h, 0054h, 005dh, 0062h, 0066h, 0075h, 0076h, 007ah
dw 0090h, 0092h, 0097h, 009fh, 00a5h, 00a8h, 00b7h, 00b8h
dw 00c1h, 00cdh, 00d3h, 00d9h, 00e0h, 00e7h, 0046h, 0055h
dw 005dh, 0062h, 0066h, 0077h, 007ah, 008fh, 0091h, 0097h
dw 009eh, 00a5h, 00a9h, 00b9h, 00c0h, 00ceh, 00d3h, 00dah
dw 00dfh, 00e7h, 0046h, 004ah, 004bh, 004ch, 004dh, 004eh
dw 004fh, 0056h, 005dh, 0062h, 0066h, 006ch, 006dh, 006eh
dw 0078h, 007bh, 008eh, 0091h, 0098h, 009eh, 00a5h, 00a9h
dw 00bah, 00c0h, 00cfh, 00d4h, 00dah, 00dfh, 00e6h, 0046h
dw 004ah, 0050h, 0056h, 005dh, 0063h, 0067h, 006ch, 006fh
dw 0070h, 0071h, 0079h, 007ch, 007dh, 007eh, 007fh, 0080h
dw 0088h, 0089h, 008ah, 008bh, 008ch, 008dh, 0091h, 0098h
dw 009eh, 00a5h, 00a9h, 00afh, 00b0h, 00b1h, 00b2h, 00b3h
dw 00bah, 00bfh, 00c6h, 00c7h, 00c8h, 00d0h, 00d4h, 00dbh
dw 00dfh, 00e6h, 0046h, 004bh, 0050h, 0056h, 005dh, 0063h
dw 0067h, 006ch, 0072h, 0073h, 0079h, 0081h, 0087h, 0091h
dw 0098h, 009ch, 009dh, 009eh, 00a5h, 00aah, 00afh, 00b4h
dw 00bbh, 00bfh, 00c5h, 00c9h, 00d0h, 00d5h, 00dch, 00deh
dw 00e5h, 0046h, 004bh, 0050h, 0056h, 005dh, 0063h, 0067h
dw 006dh, 0074h, 0079h, 0081h, 0087h, 0091h, 0098h, 0099h
dw 009ah, 009bh, 00a5h, 00aah, 00afh, 00b5h, 00bbh, 00bfh
dw 00c4h, 00cah, 00d1h, 00d6h, 00ddh, 00e4h, 0047h, 004bh
dw 004ch, 004dh, 004eh, 004fh, 0055h, 005dh, 0063h, 0068h
dw 006dh, 0074h, 0079h, 0081h, 0087h, 0092h, 00a6h, 00aah
dw 00afh, 00b5h, 00bbh, 00beh, 00c4h, 00cbh, 00d1h, 00d7h
dw 00e3h, 0047h, 0054h, 0055h, 0056h, 005eh, 0063h, 0068h
dw 006dh, 0073h, 0079h, 0081h, 0087h, 0092h, 00a6h, 00aah
dw 00b0h, 00b5h, 00bbh, 00beh, 00c3h, 00cbh, 00d1h, 00d7h
dw 00e2h, 0047h, 0057h, 0058h, 005eh, 0063h, 0068h, 006dh
dw 0073h, 0078h, 0081h, 0087h, 0092h, 00a6h, 00aah, 00b0h
dw 00b5h, 00bbh, 00beh, 00c3h, 00cch, 00d2h, 00d8h, 00e1h
dw 0046h, 0059h, 005eh, 0063h, 0068h, 006dh, 006eh, 006fh
dw 0070h, 0071h, 0072h, 0078h, 0081h, 0087h, 0091h, 00a6h
dw 00aah, 00b0h, 00b5h, 00bbh, 00beh, 00c4h, 00c5h, 00c6h
dw 00c7h, 00c8h, 00c9h, 00cah, 00cbh, 00d2h, 00d9h, 00e0h
dw 0046h, 004bh, 004ch, 004dh, 004eh, 004fh, 0050h, 0051h
dw 005ah, 005eh, 0063h, 0068h, 0077h, 0081h, 0087h, 0091h
dw 009dh, 009eh, 00a6h, 00aah, 00b0h, 00b5h, 00bbh, 00beh
dw 00d2h, 00d8h, 00dfh, 0046h, 004bh, 0052h, 0053h, 005ah
dw 005eh, 0063h, 0068h, 0076h, 0081h, 0087h, 0091h, 0098h
dw 0099h, 009ah, 009bh, 009ch, 009fh, 00a6h, 00aah, 00b0h
dw 00b5h, 00bbh, 00beh, 00d2h, 00d7h, 00deh, 0046h, 004bh
dw 0054h, 005bh, 005eh, 0063h, 0068h, 0075h, 0081h, 0086h
dw 0091h, 0097h, 009fh, 00a6h, 00aah, 00afh, 00b5h, 00bbh
dw 00beh, 00d2h, 00d7h, 00ddh, 0046h, 004ah, 0054h, 005bh
dw 005eh, 0063h, 0067h, 0074h, 0081h, 0086h, 0091h, 0097h
dw 009fh, 00a6h, 00a9h, 00afh, 00b4h, 00bbh, 00beh, 00d2h
dw 00d6h, 00ddh, 0045h, 0046h, 004ah, 0052h, 0053h, 005bh
dw 005eh, 0063h, 0067h, 006dh, 006eh, 006fh, 0075h, 0080h
dw 0086h, 0090h, 0091h, 0097h, 009fh, 00a5h, 00a9h, 00afh
dw 00b0h, 00b1h, 00b2h, 00b3h, 00bbh, 00beh, 00c5h, 00c6h
dw 00c7h, 00c8h, 00c9h, 00cah, 00cbh, 00d2h, 00d6h, 00dch
dw 0045h, 004ah, 004bh, 004ch, 004dh, 004eh, 004fh, 0050h
dw 0051h, 005bh, 005eh, 0063h, 0067h, 006dh, 006fh, 0076h
dw 0080h, 0086h, 0090h, 0097h, 009fh, 00a5h, 00a9h, 00bah
dw 00beh, 00c4h, 00cch, 00d2h, 00d5h, 00dch, 0045h, 005ah
dw 005eh, 0063h, 0067h, 006ch, 0070h, 0077h, 0080h, 0086h
dw 0090h, 0096h, 009fh, 00a5h, 00a9h, 00bah, 00beh, 00c4h
dw 00cch, 00d2h, 00d5h, 00dbh, 0045h, 0058h, 0059h, 005eh
dw 0063h, 0067h, 006ch, 0070h, 0077h, 0080h, 0086h, 0090h
dw 0096h, 009fh, 00a5h, 00a9h, 00b9h, 00beh, 00c4h, 00cch
dw 00d2h, 00d5h, 00dbh, 0045h, 0055h, 0056h, 0057h, 005fh
dw 0062h, 0067h, 006ch, 0071h, 0078h, 0080h, 0086h, 0090h
dw 0096h, 009fh, 00a5h, 00a9h, 00b7h, 00b8h, 00bfh, 00c4h
dw 00cch, 00d1h, 00d5h, 00dbh, 0046h, 0047h, 0048h, 0049h
dw 004ah, 004bh, 004ch, 004dh, 004eh, 004fh, 0050h, 0051h
dw 0052h, 0053h, 0054h, 005fh, 0060h, 0061h, 0068h, 0069h
dw 006ah, 006bh, 0072h, 0073h, 0074h, 0075h, 0076h, 0077h
dw 0081h, 0082h, 0083h, 0084h, 0085h, 0091h, 0092h, 0093h
dw 0094h, 0095h, 00a0h, 00a1h, 00a2h, 00a3h, 00a4h, 00aah
dw 00abh, 00ach, 00adh, 00aeh, 00afh, 00b0h, 00b1h, 00b2h
dw 00b3h, 00b4h, 00b5h, 00b6h, 00bfh, 00c0h, 00c1h, 00c2h
dw 00c3h, 00cdh, 00ceh, 00cfh, 00d0h, 00d6h, 00d7h, 00d8h
dw 00d9h, 00dah

oldstars2 dw 001ch, 001ch, 001ch, 001ch, 001ch, 001ch, 001ch, 001ch
dw 001ch, 001ch, 001ch, 001ch, 001ch, 001ch, 001ch, 001ch
dw 001ch, 001ch, 001ch, 001ch, 001ch, 001ch, 001ch, 001ch
dw 001ch, 001ch, 001ch, 001ch, 001ch, 001ch, 001ch, 001ch
dw 001ch, 001ch, 001ch, 001ch, 001ch, 001ch, 001ch, 001ch
dw 001ch, 001ch, 001ch, 001ch, 001ch, 001ch, 001ch, 001ch
dw 001ch, 001ch, 001ch, 001dh, 001dh, 001dh, 001dh, 001dh
dw 001dh, 001dh, 001dh, 001dh, 001dh, 001dh, 001dh, 001dh
dw 001dh, 001dh, 001dh, 001dh, 001eh, 001eh, 001eh, 001eh
dw 001eh, 001eh, 001eh, 001eh, 001eh, 001eh, 001eh, 001eh
dw 001eh, 001eh, 001eh, 001eh, 001fh, 001fh, 001fh, 001fh
dw 001fh, 001fh, 001fh, 001fh, 001fh, 001fh, 001fh, 001fh
dw 001fh, 001fh, 0020h, 0020h, 0020h, 0020h, 0020h, 0020h
dw 0020h, 0020h, 0020h, 0020h, 0020h, 0020h, 0020h, 0020h
dw 0020h, 0020h, 0020h, 0020h, 0020h, 0020h, 0021h, 0021h
dw 0021h, 0021h, 0021h, 0021h, 0021h, 0021h, 0021h, 0021h
dw 0021h, 0021h, 0021h, 0021h, 0021h, 0021h, 0021h, 0021h
dw 0021h, 0021h, 0021h, 0021h, 0021h, 0021h, 0021h, 0022h
dw 0022h, 0022h, 0022h, 0022h, 0022h, 0022h, 0022h, 0022h
dw 0022h, 0022h, 0022h, 0022h, 0022h, 0022h, 0022h, 0022h
dw 0022h, 0022h, 0022h, 0022h, 0022h, 0022h, 0022h, 0023h
dw 0023h, 0023h, 0023h, 0023h, 0023h, 0023h, 0023h, 0023h
dw 0023h, 0023h, 0023h, 0023h, 0023h, 0023h, 0023h, 0023h
dw 0023h, 0023h, 0023h, 0023h, 0024h, 0024h, 0024h, 0024h
dw 0024h, 0024h, 0024h, 0024h, 0024h, 0024h, 0024h, 0024h
dw 0024h, 0024h, 0024h, 0024h, 0025h, 0025h, 0025h, 0025h
dw 0025h, 0025h, 0025h, 0025h, 0025h, 0025h, 0025h, 0025h
dw 0025h, 0025h, 0025h, 0025h, 0026h, 0026h, 0026h, 0026h
dw 0026h, 0026h, 0026h, 0026h, 0026h, 0026h, 0026h, 0026h
dw 0026h, 0026h, 0026h, 0026h, 0027h, 0027h, 0027h, 0027h
dw 0027h, 0027h, 0027h, 0027h, 0027h, 0027h, 0027h, 0027h
dw 0027h, 0027h, 0027h, 0027h, 0027h, 0027h, 0027h, 0027h
dw 0027h, 0027h, 0027h, 0027h, 0027h, 0027h, 0027h, 0027h
dw 0027h, 0027h, 0028h, 0028h, 0028h, 0028h, 0028h, 0028h
dw 0028h, 0028h, 0028h, 0028h, 0028h, 0028h, 0029h, 0029h
dw 0029h, 0029h, 0029h, 0029h, 0029h, 0029h, 0029h, 0029h
dw 0029h, 0029h, 0029h, 0029h, 0029h, 0029h, 002ah, 002ah
dw 002ah, 002ah, 002ah, 002ah, 002ah, 002ah, 002ah, 002ah
dw 002ah, 002ah, 002bh, 002bh, 002bh, 002bh, 002bh, 002bh
dw 002bh, 002bh, 002bh, 002bh, 002bh, 002bh, 002bh, 002bh
dw 002ch, 002ch, 002ch, 002ch, 002ch, 002ch, 002ch, 002ch
dw 002ch, 002ch, 002ch, 002ch, 002ch, 002ch, 002ch, 002ch
dw 002ch, 002ch, 002ch, 002ch, 002ch, 002ch, 002ch, 002ch
dw 002ch, 002ch, 002ch, 002ch, 002ch, 002ch, 002dh, 002dh
dw 002dh, 002dh, 002dh, 002dh, 002dh, 002dh, 002dh, 002dh
dw 002dh, 002dh, 002dh, 002dh, 002eh, 002eh, 002eh, 002eh
dw 002eh, 002eh, 002eh, 002eh, 002eh, 002eh, 002eh, 002eh
dw 002eh, 002eh, 002fh, 002fh, 002fh, 002fh, 002fh, 002fh
dw 002fh, 002fh, 002fh, 002fh, 002fh, 002fh, 002fh, 002fh
dw 0030h, 0030h, 0030h, 0030h, 0030h, 0030h, 0030h, 0030h
dw 0030h, 0030h, 0030h, 0030h, 0030h, 0030h, 0031h, 0031h
dw 0031h, 0031h, 0031h, 0031h, 0031h, 0031h, 0031h, 0031h
dw 0031h, 0031h, 0031h, 0031h, 0031h, 0031h, 0031h, 0031h
dw 0031h, 0031h, 0031h, 0031h, 0031h, 0031h, 0031h, 0031h
dw 0031h, 0031h, 0031h, 0031h, 0031h, 0039h, 0039h, 0039h
dw 0039h, 003ah, 003ah, 003bh, 003bh, 003ch, 003ch, 003ch
dw 003ch, 003fh, 003fh, 003fh, 003fh, 003fh, 003fh, 003fh
dw 003fh, 003fh, 003fh, 003fh, 003fh, 003fh, 003fh, 003fh
dw 003fh, 003fh, 003fh, 003fh, 003fh, 003fh, 003fh, 003fh
dw 003fh, 003fh, 003fh, 003fh, 003fh, 003fh, 003fh, 003fh
dw 003fh, 003fh, 003fh, 003fh, 003fh, 003fh, 003fh, 003fh
dw 003fh, 003fh, 003fh, 003fh, 003fh, 003fh, 003fh, 003fh
dw 003fh, 003fh, 003fh, 003fh, 003fh, 003fh, 003fh, 003fh
dw 003fh, 003fh, 003fh, 003fh, 003fh, 003fh, 003fh, 003fh
dw 003fh, 003fh, 003fh, 003fh, 003fh, 003fh, 003fh, 003fh
dw 003fh, 003fh, 003fh, 003fh, 003fh, 003fh, 003fh, 003fh
dw 003fh, 003fh, 003fh, 003fh, 003fh, 003fh, 003fh, 003fh
dw 0040h, 0040h, 0040h, 0040h, 0040h, 0040h, 0040h, 0040h
dw 0040h, 0040h, 0040h, 0040h, 0040h, 0040h, 0040h, 0040h
dw 0040h, 0040h, 0040h, 0040h, 0040h, 0040h, 0040h, 0041h
dw 0041h, 0041h, 0041h, 0041h, 0041h, 0041h, 0041h, 0041h
dw 0041h, 0041h, 0041h, 0041h, 0041h, 0041h, 0041h, 0041h
dw 0041h, 0041h, 0041h, 0041h, 0041h, 0041h, 0042h, 0042h
dw 0042h, 0042h, 0042h, 0042h, 0042h, 0042h, 0042h, 0042h
dw 0042h, 0042h, 0042h, 0042h, 0042h, 0042h, 0042h, 0042h
dw 0042h, 0042h, 0043h, 0043h, 0043h, 0043h, 0043h, 0043h
dw 0043h, 0043h, 0043h, 0043h, 0043h, 0043h, 0043h, 0043h
dw 0043h, 0043h, 0043h, 0043h, 0043h, 0043h, 0043h, 0043h
dw 0043h, 0043h, 0043h, 0043h, 0043h, 0043h, 0043h, 0044h
dw 0044h, 0044h, 0044h, 0044h, 0044h, 0044h, 0044h, 0044h
dw 0044h, 0044h, 0044h, 0044h, 0044h, 0044h, 0044h, 0044h
dw 0044h, 0044h, 0044h, 0044h, 0044h, 0044h, 0044h, 0044h
dw 0044h, 0044h, 0044h, 0044h, 0044h, 0044h, 0044h, 0044h
dw 0044h, 0044h, 0044h, 0044h, 0044h, 0044h, 0044h, 0044h
dw 0044h, 0044h, 0045h, 0045h, 0045h, 0045h, 0045h, 0045h
dw 0045h, 0045h, 0045h, 0045h, 0045h, 0045h, 0045h, 0045h
dw 0045h, 0045h, 0045h, 0045h, 0045h, 0045h, 0045h, 0045h
dw 0045h, 0045h, 0045h, 0045h, 0045h, 0045h, 0045h, 0045h
dw 0045h, 0046h, 0046h, 0046h, 0046h, 0046h, 0046h, 0046h
dw 0046h, 0046h, 0046h, 0046h, 0046h, 0046h, 0046h, 0046h
dw 0046h, 0046h, 0046h, 0046h, 0046h, 0046h, 0046h, 0046h
dw 0046h, 0046h, 0046h, 0046h, 0046h, 0046h, 0047h, 0047h
dw 0047h, 0047h, 0047h, 0047h, 0047h, 0047h, 0047h, 0047h
dw 0047h, 0047h, 0047h, 0047h, 0047h, 0047h, 0047h, 0047h
dw 0047h, 0047h, 0047h, 0047h, 0047h, 0047h, 0047h, 0047h
dw 0047h, 0048h, 0048h, 0048h, 0048h, 0048h, 0048h, 0048h
dw 0048h, 0048h, 0048h, 0048h, 0048h, 0048h, 0048h, 0048h
dw 0048h, 0048h, 0048h, 0048h, 0048h, 0048h, 0048h, 0048h
dw 0048h, 0049h, 0049h, 0049h, 0049h, 0049h, 0049h, 0049h
dw 0049h, 0049h, 0049h, 0049h, 0049h, 0049h, 0049h, 0049h
dw 0049h, 0049h, 0049h, 0049h, 0049h, 0049h, 0049h, 0049h
dw 004ah, 004ah, 004ah, 004ah, 004ah, 004ah, 004ah, 004ah
dw 004ah, 004ah, 004ah, 004ah, 004ah, 004ah, 004ah, 004ah
dw 004ah, 004ah, 004ah, 004ah, 004ah, 004ah, 004ah, 004ah
dw 004ah, 004ah, 004ah, 004ah, 004ah, 004ah, 004ah, 004ah
dw 004bh, 004bh, 004bh, 004bh, 004bh, 004bh, 004bh, 004bh
dw 004bh, 004bh, 004bh, 004bh, 004bh, 004bh, 004bh, 004bh
dw 004bh, 004bh, 004bh, 004bh, 004bh, 004bh, 004bh, 004bh
dw 004bh, 004bh, 004bh, 004ch, 004ch, 004ch, 004ch, 004ch
dw 004ch, 004ch, 004ch, 004ch, 004ch, 004ch, 004ch, 004ch
dw 004ch, 004ch, 004ch, 004ch, 004ch, 004ch, 004ch, 004ch
dw 004ch, 004ch, 004ch, 004ch, 004ch, 004ch, 004dh, 004dh
dw 004dh, 004dh, 004dh, 004dh, 004dh, 004dh, 004dh, 004dh
dw 004dh, 004dh, 004dh, 004dh, 004dh, 004dh, 004dh, 004dh
dw 004dh, 004dh, 004dh, 004dh, 004eh, 004eh, 004eh, 004eh
dw 004eh, 004eh, 004eh, 004eh, 004eh, 004eh, 004eh, 004eh
dw 004eh, 004eh, 004eh, 004eh, 004eh, 004eh, 004eh, 004eh
dw 004eh, 004eh, 004fh, 004fh, 004fh, 004fh, 004fh, 004fh
dw 004fh, 004fh, 004fh, 004fh, 004fh, 004fh, 004fh, 004fh
dw 004fh, 004fh, 004fh, 004fh, 004fh, 004fh, 004fh, 004fh
dw 004fh, 004fh, 004fh, 004fh, 004fh, 004fh, 004fh, 004fh
dw 004fh, 004fh, 004fh, 004fh, 004fh, 004fh, 004fh, 004fh
dw 0050h, 0050h, 0050h, 0050h, 0050h, 0050h, 0050h, 0050h
dw 0050h, 0050h, 0050h, 0050h, 0050h, 0050h, 0050h, 0050h
dw 0050h, 0050h, 0050h, 0050h, 0050h, 0050h, 0050h, 0050h
dw 0050h, 0050h, 0050h, 0050h, 0050h, 0050h, 0051h, 0051h
dw 0051h, 0051h, 0051h, 0051h, 0051h, 0051h, 0051h, 0051h
dw 0051h, 0051h, 0051h, 0051h, 0051h, 0051h, 0051h, 0051h
dw 0051h, 0051h, 0051h, 0051h, 0052h, 0052h, 0052h, 0052h
dw 0052h, 0052h, 0052h, 0052h, 0052h, 0052h, 0052h, 0052h
dw 0052h, 0052h, 0052h, 0052h, 0052h, 0052h, 0052h, 0052h
dw 0052h, 0052h, 0052h, 0053h, 0053h, 0053h, 0053h, 0053h
dw 0053h, 0053h, 0053h, 0053h, 0053h, 0053h, 0053h, 0053h
dw 0053h, 0053h, 0053h, 0053h, 0053h, 0053h, 0053h, 0053h
dw 0053h, 0053h, 0053h, 0053h, 0054h, 0054h, 0054h, 0054h
dw 0054h, 0054h, 0054h, 0054h, 0054h, 0054h, 0054h, 0054h
dw 0054h, 0054h, 0054h, 0054h, 0054h, 0054h, 0054h, 0054h
dw 0054h, 0054h, 0054h, 0054h, 0054h, 0054h, 0054h, 0054h
dw 0054h, 0054h, 0054h, 0054h, 0054h, 0054h, 0054h, 0054h
dw 0054h, 0054h, 0054h, 0054h, 0054h, 0054h, 0054h, 0054h
dw 0054h, 0054h, 0054h, 0054h, 0054h, 0054h, 0054h, 0054h
dw 0054h, 0054h, 0054h, 0054h, 0054h, 0054h, 0054h, 0054h
dw 0054h, 0054h, 0054h, 0054h, 0054h, 0054h, 0054h, 0054h
dw 0054h, 0054h


; trigtabl.dat Don't put this in the file !!


trigtable dw 65535, 65534, 65531, 65525, 65516, 65505, 65492, 65476
dw 65457, 65436, 65413, 65387, 65358, 65328, 65294, 65259
dw 65220, 65180, 65137, 65091, 65043, 64993, 64940, 64884
dw 64827, 64766, 64704, 64639, 64571, 64501, 64429, 64354
dw 64277, 64197, 64115, 64031, 63944, 63854, 63763, 63668
dw 63572, 63473, 63372, 63268, 63162, 63054, 62943, 62830
dw 62714, 62596, 62476, 62353, 62228, 62101, 61971, 61839
dw 61705, 61568, 61429, 61288, 61145, 60999, 60851, 60700
dw 60547, 60392, 60235, 60075, 59914, 59750, 59583, 59415
dw 59244, 59071, 58896, 58718, 58538, 58356, 58172, 57986
dw 57798, 57607, 57414, 57219, 57022, 56823, 56621, 56418
dw 56212, 56004, 55794, 55582, 55368, 55152, 54934, 54714
dw 54491, 54267, 54040, 53812, 53581, 53349, 53114, 52878
dw 52639, 52398, 52156, 51911, 51665, 51417, 51166, 50914
dw 50660, 50404, 50146, 49886, 49624, 49361, 49095, 48828
dw 48559, 48288, 48015, 47741, 47464, 47186, 46906, 46624
dw 46341, 46056, 45769, 45480, 45190, 44898, 44604, 44308
dw 44011, 43713, 43412, 43110, 42806, 42501, 42194, 41886
dw 41576, 41264, 40951, 40636, 40320, 40002, 39683, 39362
dw 39040, 38716, 38391, 38064, 37736, 37407, 37076, 36744
dw 36410, 36075, 35738, 35401, 35062, 34721, 34380, 34037
dw 33692, 33347, 33000, 32652, 32303, 31952, 31600, 31248
dw 30893, 30538, 30182, 29824, 29466, 29106, 28745, 28383
dw 28020, 27656, 27291, 26925, 26558, 26190, 25821, 25451
dw 25080, 24708, 24335, 23961, 23586, 23210, 22834, 22457
dw 22078, 21699, 21320, 20939, 20557, 20175, 19792, 19409
dw 19024, 18639, 18253, 17867, 17479, 17091, 16703, 16314
dw 15924, 15534, 15143, 14751, 14359, 13966, 13573, 13180
dw 12785, 12391, 11996, 11600, 11204, 10808, 10411, 10014
dw 9616, 9218, 8820, 8421, 8022, 7623, 7224, 6824
dw 6424, 6023, 5623, 5222, 4821, 4420, 4019, 3617
dw 3216, 2814, 2412, 2010, 1608, 1206, 804, 402
dw 0, 65135, 64733, 64331, 63929, 63527, 63125, 62723
dw 62321, 61920, 61518, 61117, 60716, 60315, 59914, 59514
dw 59113, 58713, 58313, 57914, 57515, 57116, 56717, 56319
dw 55921, 55523, 55126, 54729, 54333, 53937, 53541, 53146
dw 52752, 52357, 51964, 51571, 51178, 50786, 50394, 50003
dw 49613, 49223, 48834, 48446, 48058, 47670, 47284, 46898
dw 46513, 46128, 45745, 45362, 44980, 44598, 44217, 43838
dw 43459, 43080, 42703, 42327, 41951, 41576, 41202, 40829
dw 40457, 40086, 39716, 39347, 38979, 38612, 38246, 37881
dw 37517, 37154, 36792, 36431, 36071, 35713, 35355, 34999
dw 34644, 34289, 33937, 33585, 33234, 32885, 32537, 32190
dw 31845, 31500, 31157, 30816, 30475, 30136, 29799, 29462
dw 29127, 28793, 28461, 28130, 27801, 27473, 27146, 26821
dw 26497, 26175, 25854, 25535, 25217, 24901, 24586, 24273
dw 23961, 23651, 23343, 23036, 22731, 22427, 22125, 21824
dw 21526, 21229, 20933, 20639, 20347, 20057, 19768, 19481
dw 19196, 18913, 18631, 18351, 18073, 17796, 17522, 17249
dw 16978, 16709, 16442, 16176, 15913, 15651, 15391, 15133
dw 14877, 14623, 14371, 14120, 13872, 13626, 13381, 13139
dw 12898, 12659, 12423, 12188, 11956, 11725, 11497, 11270
dw 11046, 10823, 10603, 10385, 10169, 9955, 9743, 9533
dw 9325, 9119, 8916, 8714, 8515, 8318, 8123, 7930
dw 7739, 7551, 7365, 7181, 6999, 6819, 6641, 6466
dw 6293, 6122, 5954, 5787, 5623, 5462, 5302, 5145
dw 4990, 4837, 4686, 4538, 4392, 4249, 4108, 3969
dw 3832, 3698, 3566, 3436, 3309, 3184, 3061, 2941
dw 2823, 2707, 2594, 2483, 2375, 2269, 2165, 2064
dw 1965, 1869, 1774, 1683, 1593, 1506, 1422, 1340
dw 1260, 1183, 1108, 1036, 966, 898, 833, 771
dw 710, 653, 597, 544, 494, 446, 400, 357
dw 317, 278, 243, 209, 179, 150, 124, 101
dw 80, 61, 45, 32, 21, 12, 6, 2
dw 1, 2, 6, 12, 21, 32, 45, 61
dw 80, 101, 124, 150, 179, 209, 243, 278
dw 317, 357, 400, 446, 494, 544, 597, 653
dw 710, 771, 833, 898, 966, 1036, 1108, 1183
dw 1260, 1340, 1422, 1506, 1593, 1683, 1774, 1869
dw 1965, 2064, 2165, 2269, 2375, 2483, 2594, 2707
dw 2823, 2941, 3061, 3184, 3309, 3436, 3566, 3698
dw 3832, 3969, 4108, 4249, 4392, 4538, 4686, 4837
dw 4990, 5145, 5302, 5462, 5623, 5787, 5954, 6122
dw 6293, 6466, 6641, 6819, 6999, 7181, 7365, 7551
dw 7739, 7930, 8123, 8318, 8515, 8714, 8916, 9119
dw 9325, 9533, 9743, 9955, 10169, 10385, 10603, 10823
dw 11046, 11270, 11497, 11725, 11956, 12188, 12423, 12659
dw 12898, 13139, 13381, 13626, 13872, 14120, 14371, 14623
dw 14877, 15133, 15391, 15651, 15913, 16176, 16442, 16709
dw 16978, 17249, 17522, 17796, 18073, 18351, 18631, 18913
dw 19196, 19481, 19768, 20057, 20347, 20639, 20933, 21229
dw 21526, 21824, 22125, 22427, 22731, 23036, 23343, 23651
dw 23961, 24273, 24586, 24901, 25217, 25535, 25854, 26175
dw 26497, 26821, 27146, 27473, 27801, 28130, 28461, 28793
dw 29127, 29462, 29799, 30136, 30475, 30816, 31157, 31500
dw 31845, 32190, 32537, 32885, 33234, 33585, 33937, 34289
dw 34644, 34999, 35355, 35713, 36071, 36431, 36792, 37154
dw 37517, 37881, 38246, 38612, 38979, 39347, 39716, 40086
dw 40457, 40829, 41202, 41576, 41951, 42327, 42703, 43080
dw 43459, 43838, 44217, 44598, 44980, 45362, 45745, 46128
dw 46513, 46898, 47284, 47670, 48058, 48446, 48834, 49223
dw 49613, 50003, 50394, 50786, 51178, 51571, 51964, 52357
dw 52752, 53146, 53541, 53937, 54333, 54729, 55126, 55523
dw 55921, 56319, 56717, 57116, 57515, 57914, 58313, 58713
dw 59113, 59514, 59914, 60315, 60716, 61117, 61518, 61920
dw 62321, 62723, 63125, 63527, 63929, 64331, 64733, 65135
dw 0, 402, 804, 1206, 1608, 2010, 2412, 2814
dw 3216, 3617, 4019, 4420, 4821, 5222, 5623, 6023
dw 6424, 6824, 7224, 7623, 8022, 8421, 8820, 9218
dw 9616, 10014, 10411, 10808, 11204, 11600, 11996, 12391
dw 12785, 13180, 13573, 13966, 14359, 14751, 15143, 15534
dw 15924, 16314, 16703, 17091, 17479, 17867, 18253, 18639
dw 19024, 19409, 19792, 20175, 20557, 20939, 21320, 21699
dw 22078, 22457, 22834, 23210, 23586, 23961, 24335, 24708
dw 25080, 25451, 25821, 26190, 26558, 26925, 27291, 27656
dw 28020, 28383, 28745, 29106, 29466, 29824, 30182, 30538
dw 30893, 31248, 31600, 31952, 32303, 32652, 33000, 33347
dw 33692, 34037, 34380, 34721, 35062, 35401, 35738, 36075
dw 36410, 36744, 37076, 37407, 37736, 38064, 38391, 38716
dw 39040, 39362, 39683, 40002, 40320, 40636, 40951, 41264
dw 41576, 41886, 42194, 42501, 42806, 43110, 43412, 43713
dw 44011, 44308, 44604, 44898, 45190, 45480, 45769, 46056
dw 46341, 46624, 46906, 47186, 47464, 47741, 48015, 48288
dw 48559, 48828, 49095, 49361, 49624, 49886, 50146, 50404
dw 50660, 50914, 51166, 51417, 51665, 51911, 52156, 52398
dw 52639, 52878, 53114, 53349, 53581, 53812, 54040, 54267
dw 54491, 54714, 54934, 55152, 55368, 55582, 55794, 56004
dw 56212, 56418, 56621, 56823, 57022, 57219, 57414, 57607
dw 57798, 57986, 58172, 58356, 58538, 58718, 58896, 59071
dw 59244, 59415, 59583, 59750, 59914, 60075, 60235, 60392
dw 60547, 60700, 60851, 60999, 61145, 61288, 61429, 61568
dw 61705, 61839, 61971, 62101, 62228, 62353, 62476, 62596
dw 62714, 62830, 62943, 63054, 63162, 63268, 63372, 63473
dw 63572, 63668, 63763, 63854, 63944, 64031, 64115, 64197
dw 64277, 64354, 64429, 64501, 64571, 64639, 64704, 64766
dw 64827, 64884, 64940, 64993, 65043, 65091, 65137, 65180
dw 65220, 65259, 65294, 65328, 65358, 65387, 65413, 65436
dw 65457, 65476, 65492, 65505, 65516, 65525, 65531, 65534

.



Relevant Pages

  • an example
    ... add ecx, edx ... mov dword, ecx ...
    (alt.lang.asm)
  • Re: global start, global main or anything I want?
    ... the program with a _start label in it, then assembling and linking it, ... you can end with "ret". ... If we send a number to stdout, it's treated as an ascii code, and the ascii codes for the "number characters" are not the same as the number! ... mov edx, hiya_len ...
    (comp.lang.asm.x86)
  • Re: intelligent disassembly
    ... loads pretty fast by getting whole tracks at a time whenever possible. ... mov ax,es ...
    (comp.os.msdos.programmer)
  • Re: Able to transfer files CP/M <> PC, what next?
    ... 1DB8:0103 MOV DX,0131 ... like a BDOS call. ... 1DB8:0107 RET ... Memory Model used by the CMD file? ...
    (comp.os.cpm)
  • Re: Betovs lies continue
    ... mov eax D$edi + TSkinSection_Text ... sub ecx eax|neg ecx ...
    (alt.lang.asm)