-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0af3510
Showing
46 changed files
with
28,553 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
unit basic3d; | ||
|
||
INTERFACE | ||
uses colour,twindraw; | ||
var | ||
{size of the colour ranges and the 'specular' size value} | ||
rangesize:word; | ||
specularrangesize:byte; | ||
Const | ||
nodeselectedcolour=yellow; | ||
nodecolour=white; | ||
linecolour=lightblue; | ||
selectedlinecolour=yellow; | ||
|
||
{////GLOBAL EFFECTS AND LIGHTING CONSTANTS/////////////} | ||
maxranges=8; | ||
{red, green, blue, yellow, magenta, cyan, brown, grey} | ||
rangebasecolours:array[0..maxranges-1]of rgbtype= | ||
( (r:31;g:0;b:0),(r:0;g:31;b:0),(r:0;g:0;b:31),(r:31;g:31;b:0),(r:31;g:0;b:31), | ||
(r:0;g:31;b:31),(r:31;g:16;b:0),(r:31;g:25;b:25) ); | ||
{ | ||
rangebasecolours:array[0..maxranges-1]of rgbtype= | ||
( (r:20;g:20;b:20),(r:0;g:4;b:20),(r:10;g:10;b:10),(r:31;g:31;b:0),(r:31;g:0;b:31), | ||
(r:31;g:31;b:31),(r:31;g:16;b:0),(r:25;g:25;b:25) ); | ||
} | ||
|
||
highlight=10; | ||
lightcol:rgbtype=(r:64;g:64;b:64); | ||
ambient:rgbtype=(r:2;g:2;b:4); | ||
fog=35; | ||
spec=1; {precentage representing highlight value} | ||
specoffset=1; | ||
lightshift=16; {16 bits for fractional part of normal vector} | ||
|
||
{////WORLD BOUNDS//////////////////////////////////////} | ||
maxbound=32000; | ||
minbound=-32000; | ||
ClipNearZ=1; | ||
ClipFarZ=32000; | ||
|
||
{////MAXIMUM POINTS WHEN USING ARRAYS//////////////////} | ||
ZaverageBufSize=3000; | ||
Maximumpoints=2300; | ||
Maximumlines=3000; | ||
Maximumpolys=1400; | ||
Maxtextures=100; | ||
Maxstars=1000; | ||
MaximumLights=2; | ||
Maxlights:byte=0; | ||
|
||
{////ORIENTATION CONSTANTS/////////////////////////////} | ||
ZY_view=0; XZ_view=1; XY_view=2; view_3d=3; | ||
Xaxis=0;Yaxis=1;Zaxis=2;Allaxis=3; | ||
|
||
{////SELECT MODES//////////////////////////////////////} | ||
SMall_nodes=0; | ||
SMselected_nodes=1; | ||
SMobjects=2; | ||
|
||
{////WORLD ATTRIBUTES//////////////////////////////////} | ||
WAstars=1; | ||
WAground=2; | ||
|
||
{////LIGHT TYPES///////////////////////////////////////} | ||
LTdirectional=1; | ||
LTpoint=2; | ||
LTconical=3; | ||
|
||
{////OBJECT TYPES//////////////////////////////////////} | ||
OTmesh=1; {all types can become a mesh} | ||
OTsquare=2; | ||
OTcube=3; | ||
OTsphere=4; | ||
OTcylinder=5; | ||
OTcone=6; | ||
OTgrid=7; | ||
OTsinegrid=8; | ||
OTtext=9; | ||
|
||
{////OBJECT ATTRIBUTES/////////////////////////////////} | ||
OAvisible=1; | ||
OAselected=2; | ||
OAMatrixDeformed=4; {object has been deformed but the change can be represented by a matrix} | ||
OAselectable=8; | ||
OAcamerafix=16; {used for fixed starfields,sky's etc} | ||
OAmoving=32; {object's matrix to be updated by movement vector} | ||
|
||
|
||
{////NODE ATTRIBUTES///////////////////////////////////} | ||
NAvisible=1; | ||
NAselected=2; | ||
NAreserved=128; {used internally, do not set directly} | ||
|
||
{////DELETE MODES///////////////////////////////} | ||
DMnodes=1; | ||
DMjoins=2; | ||
DMpolys=4; | ||
DMall=7; | ||
|
||
{////COPY MODES/////////////////////////////////} | ||
CMjoins=1; | ||
CMpolys=2; | ||
CMall=3; | ||
|
||
{////EXTRUDE MODE///////////////////////////////} | ||
XMabsolute=1; {simply extrudes to destination} | ||
XMtopoint=2; {destination is a node} | ||
XMbyref=3; {destination is a reference list} | ||
XMcopy=4; {destination is ignored, a new polygon is created using CTM} | ||
XMbevel=5; {edges are beveled} | ||
XMmodemask=7; {masks for modes} | ||
XMflipnormals=8; {special bit, if set then normals are flipped on creation} | ||
|
||
{////POLYGON CREATION MODES/////////////////////} | ||
PClines=1; | ||
PCpolys=2; | ||
PCall=3;{mask for the above two} | ||
PCchecklines=4; {check lines to see if they exist already} | ||
PCcheckpolys=8; {check polys to see if they exist already} | ||
PCclockWise=16; {Create the polygon in a clockwise order} | ||
|
||
{////POLYGON SETTING VARIABLES/////////////////////////} | ||
PAmodeFALSE=0; | ||
PAmodeTRUE=1; | ||
PAmodeABS=2; | ||
|
||
{////POLYGON ATTRIBUTE FLAGS///////////////////////////} | ||
PAclockwise=64; {phase this out -should be on creation} | ||
PAsetmask3d=not PAclockwise; | ||
PAallselected=512; | ||
PAsomeselected=1024; | ||
PAselected=PAallselected + PAsomeselected; | ||
|
||
PAvisible=128; | ||
PAabsolute=32; | ||
PAconnected=16; | ||
PAoutLined=8; | ||
PAsmooth=2; | ||
PAdoubleSided=1; | ||
|
||
|
||
|
||
{////FILLER MODES//////////////////////////////////////} | ||
CMDdots =130; | ||
CMDlines =131; | ||
CMDhlines =132; | ||
CMDCpolygons =133; | ||
CMDLsource =135; | ||
CMDgouraud =136; | ||
{1 unit = 0.7 degrees} | ||
PersStart=500; | ||
Pers=PersStart; | ||
|
||
{////ASSIGNED GLOBAL VARIABLES/////////////////////////} | ||
WAttrib:byte=0; {global attribute byte} | ||
nodepatt:array[0..4] of byte=(124,68,68,68,124); {pattern for nodes} | ||
Scale:real=0.3; {scaling value} | ||
|
||
type | ||
|
||
Vectorstruct=record | ||
x,y,z:real; | ||
end; | ||
|
||
polygonstruct=record | ||
numsides:byte; | ||
p:array[0..3] of word; | ||
colour:byte; | ||
attrib:byte; | ||
end; | ||
|
||
JoinStruct=record | ||
f,t:word | ||
end; | ||
|
||
IMPLEMENTATION | ||
|
||
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
unit bitmap16; | ||
{routines to write to a plainiar bitmap} | ||
INTERFACE | ||
uses chardef,ttypes,gbasics,tmaths; | ||
|
||
Procedure ClearDevice; | ||
procedure putpixel(x1,y1:integer); | ||
function getpixel(x1,y1:integer):byte; | ||
Procedure Qsetxy(x1,y1:integer); | ||
Procedure Qwrite(count:word); | ||
function Qget:byte; | ||
|
||
IMPLEMENTATION | ||
|
||
procedure putpixel(x1,y1:integer);assembler; | ||
|
||
|
||
|
||
asm | ||
mov cx,x1 ;mov bx,y1 | ||
cmp cx,BC.viewport.x1 ;jl @fin {clipping..} | ||
cmp bx,BC.viewport.y1 ;jl @fin | ||
cmp cx,BC.viewport.x2 ;jg @fin | ||
cmp bx,BC.viewport.y2 ;jg @fin | ||
|
||
{load start offset from table} | ||
shl bx,1 | ||
mov di,word ptr BC.startoffsets+bx | ||
|
||
{x-offset} | ||
mov bl,cl | ||
xor bh,bh | ||
and bl,7 | ||
shr cx,3 | ||
add di,cx | ||
|
||
mov dl,byte ptr singlepixelbitmasks+bx | ||
mov bx,di | ||
|
||
{create masks} | ||
|
||
mov dh,dl | ||
not dh | ||
mov ah,t_col | ||
|
||
|
||
@plane1: | ||
les di,dword ptr BC.scrptrs | ||
mov al,1 | ||
|
||
|
||
test al,ah | ||
jz @nowrite1 | ||
or es:[di+BX],dl | ||
jmp @plane2 | ||
@nowrite1: | ||
and es:[di+BX],dh | ||
@plane2: | ||
|
||
shl al,1 {move bitmask along} | ||
|
||
les di,dword ptr BC.scrptrs+4 | ||
|
||
test al,ah | ||
jz @nowrite2 | ||
or es:[di+BX],dl | ||
jmp @plane3 | ||
@nowrite2: | ||
and es:[di+BX],dh | ||
@plane3: | ||
|
||
shl al,1 {move bitmask along} | ||
|
||
les di,dword ptr BC.scrptrs+8 | ||
|
||
test al,ah | ||
jz @nowrite3 | ||
or es:[di+BX],dl | ||
jmp @plane4 | ||
@nowrite3: | ||
and es:[di+BX],dh | ||
@plane4: | ||
|
||
shl al,1 {move bitmask along} | ||
|
||
les di,dword ptr BC.scrptrs+12 | ||
test al,ah | ||
jz @nowrite4 | ||
or es:[di+BX],dl | ||
jmp @fin | ||
@nowrite4: | ||
and es:[di+BX],dh | ||
@fin: | ||
|
||
|
||
|
||
end; | ||
|
||
function getpixel(x1,y1:integer):byte; | ||
var adrs:byteptr; | ||
readbit,planelop,currbyte:byte; | ||
picoffset:word; | ||
begin | ||
currbyte:=0; | ||
if (X1>=BC.viewport.x1)and(Y1>=BC.viewport.y1)and(X1<=BC.viewport.x2)and(Y1<=BC.viewport.y2) then begin | ||
|
||
readbit:=$80 shr (x1 and 7); | ||
picoffset:=(y1 * BC.offsw)+(x1 shr 3); | ||
for planelop:=0 to BC.bitplanes-1 do begin | ||
adrs:=pointer(BC.scrptrs[planelop]); | ||
inc(adrs,picoffset); | ||
if readbit and adrs^<>0 then | ||
inc(currbyte,1 shl planelop); | ||
end; | ||
end; | ||
getpixel:=currbyte; | ||
end; | ||
|
||
{These are generic routines for writing contingous | ||
block fast to bitmaps. Good for loading in from files} | ||
Procedure QSetXY(x1,y1:integer); | ||
begin | ||
BC.qoffset:=y1*BC.offsw+(x1 shr 3); | ||
BC.qbitoffset:=x1 and 7; | ||
|
||
end; | ||
|
||
function Qget:byte; | ||
var | ||
colour:byte; | ||
var planeloop:byte; | ||
qadrs:byteptr; | ||
begin | ||
|
||
colour:=0; | ||
for planeloop:=0 to BC.bitplanes-1 do begin | ||
qadrs:=pointer(BC.scrptrs[planeloop]); | ||
inc(qadrs,BC.qoffset); | ||
if qadrs^ and BC.qbitoffset <> 0 then | ||
inc(colour,1 shl planeloop); | ||
end; | ||
asm | ||
shr bc.qbitoffset,1 | ||
adc word ptr bc.qoffset,0 | ||
end; | ||
qget:=colour; | ||
end; | ||
|
||
Procedure Qwrite(count:word); | ||
var lop,oldqoff:word; | ||
planelop,oldqmask:byte; | ||
oldxpos:integer; | ||
adrs:^byte; | ||
begin | ||
{oldqoff:=q | ||
oldxpos:=BC.qxpos; | ||
for planelop:=0 to BC.bitplanes-1 do begin | ||
qoff:=oldqoff; | ||
qmask:=oldqmask; | ||
BC.qxpos:=oldxpos; | ||
adrs:=pointer(pic[planelop]); | ||
inc(adrs,Qoff); | ||
for lop:=1 to count do begin | ||
if t_col and (1 shl planelop)<>0 then | ||
adrs^:=adrs^ or Qmask | ||
else | ||
adrs^:=adrs^ and not Qmask; | ||
begin | ||
qmask:=qmask shr 1; | ||
if Qmask=0 then begin | ||
inc(adrs); | ||
inc(Qoff); | ||
Qmask:=128; | ||
end; | ||
end; | ||
end; | ||
end;} | ||
end; | ||
|
||
Procedure ClearDevice; | ||
var bitlop:byte; | ||
begin | ||
for bitlop:=0 to BC.bitplanes-1 do | ||
fillchar(BC.scrptrs[bitlop]^,BC.pagesize,0); | ||
end; | ||
|
||
end. |
Oops, something went wrong.