home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dream 44
/
Amiga_Dream_44.iso
/
RiscPc
/
jeux
/
biohazard.arc
/
s
/
FloorVGA
< prev
next >
Wrap
Text File
|
1995-01-02
|
14KB
|
518 lines
; Use the GET directive to include register definitions as if typed here
KEEP
GET h.WolfReg
; Use the GET directive to include a list of SWI names as if typed here
GET h.SWInames
; Area name C$$code advisable as wanted to link with C output
AREA |C$$code|, CODE, READONLY
; Export global symbols
EXPORT |PlotFloorVGA|
PltFloorX DCB "PlotFloor", 0
ALIGN
PltFloorY DCD &ff000000 + PltFloorY - PltFloorX
;on entry
;
; r0 = pointer to data block where :-
;
; 0 = pointer to perspective plot data
; format of plot data is :-
; word 1...x1 x start position
; word 2...y1 y start position
; word 3...xg x increment value (per screen pixel)
; word 4...yg y increment value (per screen pixel)
; 1 = screen address (of the first line to draw on)
; 2 = pointer to sprite data to use as floor.
; This is simply a 64x64 block of data
; 3 = counter (number of lines to draw)
; 4 = x offset
; 5 = y offset
; 6 = screen width
; 7 = screen height
; 8 = cos theta
; 9 = sin theta
|PlotFloorVGA|
STMFD r13!,{r0-r12,link}
;load up block data
MOV r14,r0
LDMIA r14,{r0-r9}
;combine x & y offsets
MOV r12,r4,LSR #16
MOV r12,r12,LSL #16
ADD r4,r12,r5,LSR #16
;move sin theta to r5 to free r9
MOV r5,r9
Plot_Loop
;load up the next block of perspective plot data
LDMIA r0!,{r9-r12}
;store vars on stack
; screen address is updated by line drawing procedure
; source base is used by the line drawing program and not changed
STMFD r13!,{r0,r3-r8}
;rotate x1 & y1 coordinates
MOV r0,r9,ASR #10
MOV r3,r10,ASR #10
MUL r7,r8,r0 ;x * cos theta
MUL r14,r5,r3 ;y * sin theta
SUB r9,r7,r14 ;x = (x * cos theta) - (y * sin theta)
MUL r14,r5,r0 ;x * sin theta
MUL r0,r8,r3 ;y * cos theta
ADD r10,r14,r0 ;y = (x * sin theta) + (y * cos theta)
MOV r9,r9,ASR #6
MOV r10,r10,ASR #6
;rotate xg & yg coordinates
MOV r0,r11,ASR #4
MOV r3,r12,ASR #4
MOV r5,r5,ASR #4
MOV r8,r8,ASR #4
MUL r7,r8,r0 ;x * cos theta
MUL r14,r5,r3 ;y * sin theta
SUB r11,r7,r14 ;x = (x * cos theta) - (y * sin theta)
MUL r14,r5,r0 ;x * sin theta
MUL r0,r8,r3 ;y * cos theta
ADD r12,r14,r0 ;y = (x * sin theta) + (y * cos theta)
MOV r11,r11,ASR #8
MOV r12,r12,ASR #8
;main line drawing procedure
;adjust offsets
MOV r14,r4,ASR #16
SUB r9,r9,r4,LSL #16
ADD r10,r10,r14,LSL #16
;load screen width and 127 register
MOV r4,r6
MOV r3,#127
Draw_Line
;extract x,y positions in sprite data from x & y
AND r0,r3,r9,LSR #16
AND r14,r3,r10,LSR #16
;construct address from x & y values
ADD r0,r0,r14,LSL #7
;load byte from source_base + (x + 128(y))
LDRB r5,[r2,r0]
;update x & y
ADD r9,r9,r11
ADD r10,r10,r12
;load byte 2 word 1
AND r0,r3,r9,LSR #16
AND r14,r3,r10,LSR #16
ADD r0,r0,r14,LSL #7
LDRB r14,[r2,r0]
ADD r5,r5,r14,LSL #8
ADD r9,r9,r11
ADD r10,r10,r12
;load byte 3 word 1
AND r0,r3,r9,LSR #16
AND r14,r3,r10,LSR #16
ADD r0,r0,r14,LSL #7
LDRB r14,[r2,r0]
ADD r5,r5,r14,LSL #16
ADD r9,r9,r11
ADD r10,r10,r12
;load byte 4 word 1
AND r0,r3,r9,LSR #16
AND r14,r3,r10,LSR #16
ADD r0,r0,r14,LSL #7
LDRB r14,[r2,r0]
ADD r5,r5,r14,LSL #24
ADD r9,r9,r11
ADD r10,r10,r12
;load byte 1 word 2
AND r0,r3,r9,LSR #16
AND r14,r3,r10,LSR #16
ADD r0,r0,r14,LSL #7
LDRB r6,[r2,r0]
ADD r9,r9,r11
ADD r10,r10,r12
;load byte 2 word 2
AND r0,r3,r9,LSR #16
AND r14,r3,r10,LSR #16
ADD r0,r0,r14,LSL #7
LDRB r14,[r2,r0]
ADD r6,r6,r14,LSL #8
ADD r9,r9,r11
ADD r10,r10,r12
;load byte 3 word 2
AND r0,r3,r9,LSR #16
AND r14,r3,r10,LSR #16
ADD r0,r0,r14,LSL #7
LDRB r14,[r2,r0]
ADD r6,r6,r14,LSL #16
ADD r9,r9,r11
ADD r10,r10,r12
;load byte 4 word 2
AND r0,r3,r9,LSR #16
AND r14,r3,r10,LSR #16
ADD r0,r0,r14,LSL #7
LDRB r14,[r2,r0]
ADD r6,r6,r14,LSL #24
ADD r9,r9,r11
ADD r10,r10,r12
;load byte 1 word 3
AND r0,r3,r9,LSR #16
AND r14,r3,r10,LSR #16
ADD r0,r0,r14,LSL #7
LDRB r7,[r2,r0]
ADD r9,r9,r11
ADD r10,r10,r12
;load byte 2 word 3
AND r0,r3,r9,LSR #16
AND r14,r3,r10,LSR #16
ADD r0,r0,r14,LSL #7
LDRB r14,[r2,r0]
ADD r7,r7,r14,LSL #8
ADD r9,r9,r11
ADD r10,r10,r12
;load byte 3 word 3
AND r0,r3,r9,LSR #16
AND r14,r3,r10,LSR #16
ADD r0,r0,r14,LSL #7
LDRB r14,[r2,r0]
ADD r7,r7,r14,LSL #16
ADD r9,r9,r11
ADD r10,r10,r12
;load byte 4 word 3
AND r0,r3,r9,LSR #16
AND r14,r3,r10,LSR #16
ADD r0,r0,r14,LSL #7
LDRB r14,[r2,r0]
ADD r7,r7,r14,LSL #24
ADD r9,r9,r11
ADD r10,r10,r12
;load byte 1 word 4
AND r0,r3,r9,LSR #16
AND r14,r3,r10,LSR #16
ADD r0,r0,r14,LSL #7
LDRB r8,[r2,r0]
ADD r9,r9,r11
ADD r10,r10,r12
;load byte 2 word 4
AND r0,r3,r9,LSR #16
AND r14,r3,r10,LSR #16
ADD r0,r0,r14,LSL #7
LDRB r14,[r2,r0]
ADD r8,r8,r14,LSL #8
ADD r9,r9,r11
ADD r10,r10,r12
;load byte 3 word 4
AND r0,r3,r9,LSR #16
AND r14,r3,r10,LSR #16
ADD r0,r0,r14,LSL #7
LDRB r14,[r2,r0]
ADD r8,r8,r14,LSL #16
ADD r9,r9,r11
ADD r10,r10,r12
;load byte 4 word 4
AND r0,r3,r9,LSR #16
AND r14,r3,r10,LSR #16
ADD r0,r0,r14,LSL #7
LDRB r14,[r2,r0]
ADD r8,r8,r14,LSL #24
ADD r9,r9,r11
ADD r10,r10,r12
;write block to screen
ADD r1,r1,#320
STMIA r1,{r5-r8}
SUB r1,r1,#320
STMIA r1!,{r5-r8}
SUBS r4,r4,#16
BNE Draw_Line
;load vars from stack & decrement line counter
LDMFD r13!,{r0,r3-r8}
SUBS r3,r3,#1
;adjust pointer to screen to start of next line
RSB r9,r6,#320
ADD r1,r1,r9
ADD r1,r1,#320
BNE Plot_Loop
LDMFD r13!,{r0-r12,link}
STMFD r13!,{r0-r12,link}
;load up block data
MOV r14,r0
LDMIA r14,{r0-r9}
ADD r2,r2,#16384
;combine x & y offsets
MOV r12,r4,LSR #16
MOV r12,r12,LSL #16
ADD r4,r12,r5,LSR #16
;move sin theta to r5 to free r9
MOV r5,r9
;adjust screen address
RSB r14,r3,r7,LSR #1 ;r14 = screen_height/2 - lines
MOV r10,r14,LSL #7
ADD r9,r10,r14,LSL #9 ;r6 = r14 * 640
SUB r1,r1,r9,LSL #1
SUB r1,r1,#640
Plot_Loop1
;load up the next block of perspective plot data
LDMIA r0!,{r9-r12}
;store vars on stack
; screen address is updated by line drawing procedure
; source base is used by the line drawing program and not changed
STMFD r13!,{r0,r3-r8}
;rotate x1 & y1 coordinates
MOV r0,r9,ASR #10
MOV r3,r10,ASR #10
MUL r7,r8,r0 ;x * cos theta
MUL r14,r5,r3 ;y * sin theta
SUB r9,r7,r14 ;x = (x * cos theta) - (y * sin theta)
MUL r14,r5,r0 ;x * sin theta
MUL r0,r8,r3 ;y * cos theta
ADD r10,r14,r0 ;y = (x * sin theta) + (y * cos theta)
MOV r9,r9,ASR #6
MOV r10,r10,ASR #6
;rotate xg & yg coordinates
MOV r0,r11,ASR #4
MOV r3,r12,ASR #4
MOV r5,r5,ASR #4
MOV r8,r8,ASR #4
MUL r7,r8,r0 ;x * cos theta
MUL r14,r5,r3 ;y * sin theta
SUB r11,r7,r14 ;x = (x * cos theta) - (y * sin theta)
MUL r14,r5,r0 ;x * sin theta
MUL r0,r8,r3 ;y * cos theta
ADD r12,r14,r0 ;y = (x * sin theta) + (y * cos theta)
MOV r11,r11,ASR #8
MOV r12,r12,ASR #8
;main line drawing procedure
;adjust offsets
MOV r14,r4,ASR #16
SUB r9,r9,r4,LSL #16
ADD r10,r10,r14,LSL #16
;load screen width and 127 register
MOV r4,r6
MOV r3,#127
Draw_Line1
;extract x,y positions in sprite data from x & y
AND r0,r3,r9,LSR #16
AND r14,r3,r10,LSR #16
;construct address from x & y values
ADD r0,r0,r14,LSL #7
;load byte from source_base + (x + 64(y))
LDRB r5,[r2,r0]
;update x & y
ADD r9,r9,r11
ADD r10,r10,r12
;load byte 2 word 1
AND r0,r3,r9,LSR #16
AND r14,r3,r10,LSR #16
ADD r0,r0,r14,LSL #7
LDRB r14,[r2,r0]
ADD r5,r5,r14,LSL #8
ADD r9,r9,r11
ADD r10,r10,r12
;load byte 3 word 1
AND r0,r3,r9,LSR #16
AND r14,r3,r10,LSR #16
ADD r0,r0,r14,LSL #7
LDRB r14,[r2,r0]
ADD r5,r5,r14,LSL #16
ADD r9,r9,r11
ADD r10,r10,r12
;load byte 4 word 1
AND r0,r3,r9,LSR #16
AND r14,r3,r10,LSR #16
ADD r0,r0,r14,LSL #7
LDRB r14,[r2,r0]
ADD r5,r5,r14,LSL #24
ADD r9,r9,r11
ADD r10,r10,r12
;load byte 1 word 2
AND r0,r3,r9,LSR #16
AND r14,r3,r10,LSR #16
ADD r0,r0,r14,LSL #7
LDRB r6,[r2,r0]
ADD r9,r9,r11
ADD r10,r10,r12
;load byte 2 word 2
AND r0,r3,r9,LSR #16
AND r14,r3,r10,LSR #16
ADD r0,r0,r14,LSL #7
LDRB r14,[r2,r0]
ADD r6,r6,r14,LSL #8
ADD r9,r9,r11
ADD r10,r10,r12
;load byte 3 word 2
AND r0,r3,r9,LSR #16
AND r14,r3,r10,LSR #16
ADD r0,r0,r14,LSL #7
LDRB r14,[r2,r0]
ADD r6,r6,r14,LSL #16
ADD r9,r9,r11
ADD r10,r10,r12
;load byte 4 word 2
AND r0,r3,r9,LSR #16
AND r14,r3,r10,LSR #16
ADD r0,r0,r14,LSL #7
LDRB r14,[r2,r0]
ADD r6,r6,r14,LSL #24
ADD r9,r9,r11
ADD r10,r10,r12
;load byte 1 word 3
AND r0,r3,r9,LSR #16
AND r14,r3,r10,LSR #16
ADD r0,r0,r14,LSL #7
LDRB r7,[r2,r0]
ADD r9,r9,r11
ADD r10,r10,r12
;load byte 2 word 3
AND r0,r3,r9,LSR #16
AND r14,r3,r10,LSR #16
ADD r0,r0,r14,LSL #7
LDRB r14,[r2,r0]
ADD r7,r7,r14,LSL #8
ADD r9,r9,r11
ADD r10,r10,r12
;load byte 3 word 3
AND r0,r3,r9,LSR #16
AND r14,r3,r10,LSR #16
ADD r0,r0,r14,LSL #7
LDRB r14,[r2,r0]
ADD r7,r7,r14,LSL #16
ADD r9,r9,r11
ADD r10,r10,r12
;load byte 4 word 3
AND r0,r3,r9,LSR #16
AND r14,r3,r10,LSR #16
ADD r0,r0,r14,LSL #7
LDRB r14,[r2,r0]
ADD r7,r7,r14,LSL #24
ADD r9,r9,r11
ADD r10,r10,r12
;load byte 1 word 4
AND r0,r3,r9,LSR #16
AND r14,r3,r10,LSR #16
ADD r0,r0,r14,LSL #7
LDRB r8,[r2,r0]
ADD r9,r9,r11
ADD r10,r10,r12
;load byte 2 word 4
AND r0,r3,r9,LSR #16
AND r14,r3,r10,LSR #16
ADD r0,r0,r14,LSL #7
LDRB r14,[r2,r0]
ADD r8,r8,r14,LSL #8
ADD r9,r9,r11
ADD r10,r10,r12
;load byte 3 word 4
AND r0,r3,r9,LSR #16
AND r14,r3,r10,LSR #16
ADD r0,r0,r14,LSL #7
LDRB r14,[r2,r0]
ADD r8,r8,r14,LSL #16
ADD r9,r9,r11
ADD r10,r10,r12
;load byte 4 word 4
AND r0,r3,r9,LSR #16
AND r14,r3,r10,LSR #16
ADD r0,r0,r14,LSL #7
LDRB r14,[r2,r0]
ADD r8,r8,r14,LSL #24
ADD r9,r9,r11
ADD r10,r10,r12
;write block to screen
ADD r1,r1,#320
STMIA r1,{r5-r8}
SUB r1,r1,#320
STMIA r1!,{r5-r8}
SUBS r4,r4,#16
BNE Draw_Line1
;load vars from stack & decrement line counter
LDMFD r13!,{r0,r3-r8}
;SUB r1,r1,#640
SUBS r3,r3,#1
;adjust pointer to screen to start of next line
SUB r1,r1,r6
SUB r1,r1,#640
BNE Plot_Loop1
EndPlotFloor
LDMFD r13!,{r0-r12,pc}
END