Seppuku Arts,
Quote: "Assembly looks awfully confusing"
Well.. If you looking at 8bit / 16bit examples that are hitting hardware all over the place, then yeah.. it can be very difficult to follow exactly what's going on. Since we've no way of knowing what some odd looking addressing mode or what setting a particular value into memory does. The latter is important as other chips in the system, map themselves into or over the cpu's address space. So setting up the graphics hardware for example, is just a matter of writing the required values to wherever the graphics hardware expects them. Which is perfectly fine in a world where the hardware configuration never changes, but not so much today. If you're bored and feeling nostalgic, then track down some old C64 (8bit) / Amiga 16/32bit
demo/game assembly source codes.
Today things are vastly different, not only have assemblers grown up a lot, but the 'dirty' low level hardware hitting stuff has been replaced with the familiar API programming that high level desk top programmers enjoy. So you often end up with something that's a bit more approachable, in particular if you're familiar with the api in question, if not, then your still stuffed
For example,
The following source is from a project I wrote back in 2000/2001 for DB called
Kyruss (back when i had free time to do whatever I wanted, whenever i wanted..

). Basically the environment gives provides a GUI / assembler and simple API. Kyruss CPU emulation uses a 'dumbed' down version of the 68000 cpu instruction set, meaning it's core instructions are similar, but a lot of fat has been trimmed away. The idea was to make Virus war simulation game.. But anyway..
; *=------------------------------------------------------------------------------=*
;
; >> Wire Frame Frames <<
;
; By Kevin Picone
;
; (c) copyright 2001, Kevin Picone, Underware Design
;
; *=------------------------------------------------------------------------------=*
; Set Programs NAME, AUTHOR's Name and SIZE of memory for the assembler to allocate
Appname = Wire Vectors
Authorname = Kev
Programsize = 3000
; *=------------------------------------------------------------------------------=*
; >> Start of Program <<
; *=------------------------------------------------------------------------------=*
acc=1024
START:
call get_window_size
move d0,ScreenWidth
move d1,ScreenHeight
lsr #1,d0
lsr #1,d1
move d0,ScreenCentX
move d1,ScreenCentY
; Activate Manual Sync control. (double buffering)
call user_sync_on
move #0,d0
move #0,d5
MainLP:
call cls ; CLEAR The Hidden window
lea Rotation_AngleS,a6
move Rot_angleX(a6),d0
move Rot_angleY(a6),d1
move Rot_angleZ(a6),d2
add #1,d0
add #1,d1
add #2,d2
cmp #360,d0
bhi nowrapx
sub #360,d0
nowrapx:
cmp #360,d1
bhi nowrapy
sub #360,d1
nowrapy:
cmp #360,d2
bhi nowrapz
sub #360,d2
nowrapz:
move d0,Rot_angleX(a6)
move d1,Rot_angleY(a6)
move d2,Rot_angleZ(a6)
bsr Rotate_points ; rotate and draw points
bsr _draw_wire_frame
call swap_buffer ; Show Hidden Buffer
bra MainLP
; *=------------------------------------------------------------------------------=*
; >> Draw Stars <<
; *=------------------------------------------------------------------------------=*
ScreenWidth:
data 0
ScreenHeight:
data 0
ScreenCentX:
data 0
ScreenCentY:
data 0
Rot_angleX=0
Rot_angleY=1
Rot_angleZ=2
CosX=0
SinX=1
CosY=2
SinY=3
CosZ=4
SinZ=5
Xcord=0
Ycord=1
Zcord=2
Rotate_points:
bsr _UPDATE_ZOOM
lea rotate_cos_sinValues,a7
bsr Calc_rotation_constants
lea ObjectVertex,a0 ; Source Points
lea RotateVertexBUffer,a1 ; Rotated Projected Points
lea Rotate_temp_values,a2 ; Used for temp store of values
lea ScreenCentX,a6
move (a0),d7 ; Get Number of points to rotate
inc a0
Rotate_points_lp:
; Get Point Coord
move Xcord(a0),d0
move Ycord(a0),d1
move Zcord(a0),d2
; Rotate Around X axis
move d1,d3 ; d3 = y
move d2,d4 ; d4 = z
move d1,d5 ; d5 = y
;y#=(cx#*Ypos#)-(sx#*zpos#)
mult CosX(a7),d3
mult SinX(a7),d4
sub d4,d3 ; d3 = Y
;z#=(cx#*Zpos#)+(sx#*ypos#)
mult CosX(a7),d2 ; CosX * z
mult SinX(a7),d5 ; SinX * Y
add d5,d2 ; d2 = NEW
move d3,d1 ; d1 = new y
div #acc,d1
div #acc,d2
; Rotate Around Y axis
; x#=(cY#*Z#)-(sy#*Xpos#)
move d0,d3 ; d3 = x
move d2,d4 ; d4 = z
move d0,d5 ; d5 = x
mult CosY(a7),d4 ; CosY * z
mult SinY(a7),d3 ; SinY * x
sub d3,d4 ; d4 = (CosY*z) - (SinY * x)
; z#=(cy#*Xpos#)+(sy#*Z#)
mult CosY(a7),d5 ; CosY * x
mult SinY(a7),d2 ; SinY * z
add d5,d2 ; d2 = (CosY * x) + (SinY * z)
move d4,d0
div #acc,d0
div #acc,d2
; Rotate Around Z axis
move d0,d3 ; d3 = x
move d0,d4 ; d4 = x
move d1,d5 ; d5 = y
move d1,d6 ; d6 = y
; x2#=(cz#*X#)-(sz#*Y#)
; Y#=(cz#*Y#)+(sz#*X#)
mult CosZ(a7),d3 ; CosZ * X
mult SinZ(a7),d5 ; SinZ * Y
sub d5,d3 ; d3 = (CosZ*X)-(SinZ*Y)
; Y#=(cz#*Y#)+(sz#*X#)
mult CosZ(a7),d6 ; CosZ * Y
mult SinZ(a7),d4 ; SinZ * X
add d6,d4 ; d3 = (CosZ*X)-(SinZ*Y)
move d3,d0
move d4,d1
; lsr #bits,d0
; lsr #bits,d1
; div #acc,d0
; div #acc,d1
; project into 2d space
move zoom,d3
add d3,d2
div d2,d0
div d2,d1
add (a6),d0
add 1(a6),d1
;call dot
move d0,(a1)
move d1,1(a1)
add #2,a1
add #3,a0
decbne d7,Rotate_points_lp
rts
;
; ` Around X axis
; y#=(cx#*Ypos#)-(sx#*zpos#)
; z#=(cx#*Zpos#)+(sx#*ypos#)
;
; ` Around Y axis
; x#=(cY#*Z#)-(sy#*Xpos#)
; z#=(cy#*Xpos#)+(sy#*Z#)
;
; ` Around Z axis
; x2#=(cz#*X#)-(sz#*Y#)
; Y#=(cz#*Y#)+(sz#*X#)
; x#=x2#
_draw_wire_frame:
lea RotateVertexBUffer,a6
lea Join_list,a7
move (a7),d7
inc a7
drawlp:
move (a7),a0
inc a7
move (a7),a1
inc a7
lsl #1,a0
lsl #1,a1
add a6,a0
move (a0),d0
inc a0
move (a0),d1
add a6,a1
move (a1),d2
inc a1
move (a1),d3
call line
decbne d7,drawlp
rts
Calc_rotation_constants:
lea Costable,a0
lea Sintable,a1
; Calc Rotate constants
lea Rotation_AngleS,a6
move Rot_angleX(a6),d0
bsr _get_cos_sin
move d0,CosX(a7)
move d1,SinX(a7)
move Rot_angleY(a6),d0
bsr _get_cos_sin
move d0,CosY(a7)
move d1,SinY(a7)
move Rot_angleZ(a6),d0
bsr _get_cos_sin
move d0,CosZ(a7)
move d1,SinZ(a7)
rts
_get_cos_sin:
move d0,d1
add a0,d0
add a1,d1
move (d0),d0
move (d1),d1
rts
ObjectVertex:
data 8
data -50,-50,50
data 50,-50,50
data 50,50,50
data -50,50,50
data -50,-50,-50
data 50,-50,-50
data 50,50,-50
data -50,50,-50
Join_list:
data 12
data 0,1
data 1,2
data 2,3
data 3,0
data 4,5
data 5,6
data 6,7
data 7,4
data 0,4
data 1,5
data 2,6
data 3,7
_UPDATE_ZOOM:
move #450,d1
lea sintable,a0
move ZoomAngle,d5
add #15,d5
cmp #360,d5
bne skip1
sub #360,d5
skip1:
move d5,zoomangle
add d5,a0
mult (a0),d1
div #acc,d1
add #1800,d1
move d1,Zoom
rts
Zoom:
data 0
ZoomAngle:
data 0
RotateVertexBUffer:
block 100,0
Rotation_AngleS:
data 0,0,0
rotate_cos_sinValues:
data 0,0,0,0,0,0
Rotate_temp_values:
block 50,0
; *=------------------------------------------------------------------------------=*
; >> Cos & Sin tables - Tables are premulted by 1024 <<
; *=------------------------------------------------------------------------------=*
CosTable:
data 1024,1024,1023,1023,1022,1020,1018,1016,1014,1011
data 1008,1005,1002,998,994,989,984,979,974,968
data 962,956,949,943,935,928,920,912,904,896
data 887,878,868,859,849,839,828,818,807,796
data 784,773,761,749,737,724,711,698,685,672
data 658,644,630,616,602,587,573,558,543,527
data 512,496,481,465,449,433,416,400,384,367
data 350,333,316,299,282,265,248,230,213,195
data 178,160,143,125,107,89,71,54,36,18
SinTable:
data 0,-18,-36,-54,-71,-89,-107,-125,-143,-160
data -178,-195,-213,-230,-248,-265,-282,-299,-316,-333
data -350,-367,-384,-400,-416,-433,-449,-465,-481,-496
data -512,-527,-543,-558,-573,-587,-602,-616,-630,-644
data -658,-672,-685,-698,-711,-724,-737,-749,-761,-773
data -784,-796,-807,-818,-828,-839,-849,-859,-868,-878
data -887,-896,-904,-912,-920,-928,-935,-943,-949,-956
data -962,-968,-974,-979,-984,-989,-994,-998,-1002,-1005
data -1008,-1011,-1014,-1016,-1018,-1020,-1022,-1023,-1023,-1024
data -1024,-1024,-1023,-1023,-1022,-1020,-1018,-1016,-1014,-1011
data -1008,-1005,-1002,-998,-994,-989,-984,-979,-974,-968
data -962,-956,-949,-943,-935,-928,-920,-912,-904,-896
data -887,-878,-868,-859,-849,-839,-828,-818,-807,-796
data -784,-773,-761,-749,-737,-724,-711,-698,-685,-672
data -658,-644,-630,-616,-602,-587,-573,-558,-543,-527
data -512,-496,-481,-465,-449,-433,-416,-400,-384,-367
data -350,-333,-316,-299,-282,-265,-248,-230,-213,-195
data -178,-160,-143,-125,-107,-89,-71,-54,-36,-18
data 0,18,36,54,71,89,107,125,143,160
data 178,195,213,230,248,265,282,299,316,333
data 350,367,384,400,416,433,449,465,481,496
data 512,527,543,558,573,587,602,616,630,644
data 658,672,685,698,711,724,737,749,761,773
data 784,796,807,818,828,839,849,859,868,878
data 887,896,904,912,920,928,935,943,949,956
data 962,968,974,979,984,989,994,998,1002,1005
data 1008,1011,1014,1016,1018,1020,1022,1023,1023,1024
data 1024,1024,1023,1023,1022,1020,1018,1016,1014,1011
data 1008,1005,1002,998,994,989,984,979,974,968
data 962,956,949,943,935,928,920,912,904,896
data 887,878,868,859,849,839,828,818,807,796
data 784,773,761,749,737,724,711,698,685,672
data 658,644,630,616,602,587,573,558,543,527
data 512,496,481,465,449,433,416,400,384,367
data 350,333,316,299,282,265,248,230,213,195
data 178,160,143,125,107,89,71,54,36,18
data 0