Wolf3D-Mac/Wolf.ppc
2013-12-20 01:25:00 -05:00

1 line
4.6 KiB
Plaintext

;
; Assembly language functions for wolf 3-D PPC version
; Written by Bill Heineman
; 9-12-94 (Rev for removing scalers and using direct code)
;
;
; Bullshit to make the PPC Mac environment know I'm here
;
import VideoWidth ; global variable from C program
import MacViewHeight
import ArtData
import VideoPointer
import ScaleDiv
toc
tc VideoWidth[TC],VideoWidth
tc MacViewHeight[TC],MacViewHeight
tc ArtData[TC],ArtData
tc VideoPointer[TC],VideoPointer
tc ScaleDiv[TC],ScaleDiv
export IO_ScaleWallColumn[DS]
export .IO_ScaleWallColumn[PR]
export SpriteGlue[DS]
export .SpriteGlue[PR]
toc ;Table of contents for the subroutines
tc IO_ScaleWallColumn[TC], IO_ScaleWallColumn[DS]
tc SpriteGlue[TC], SpriteGlue[DS]
csect IO_ScaleWallColumn[DS]
dc.l .IO_ScaleWallColumn[PR]
dc.l TOC[tc0]
csect SpriteGlue[DS]
dc.l .SpriteGlue[PR]
dc.l TOC[tc0]
;
; This routine will draw a scaled wall column.
;
; void IO_ScaleWallColumn(Word x,Word scale,LongWord column)
;
WALLHEIGHT EQU 128+1
; Passed from "C"
X equ R3 ;X coord
Scale equ R4 ;Scale factor
Tile equ R5 ;Tile to draw
Column equ R6 ;Packed wall column #
; Locals
ArtStart EQU R7 ;Pointer to wall art
ScreenPtr EQU R8 ;Pointer to screen memory column
Frac EQU R9 ;Fractional scaler
Integer EQU R10 ;Fractional integer
VWidth EQU R11 ;Video of the video screen in bytes
Delta EQU R6 ;Delta factor and temp
VHeight EQU R12 ;Height of mac screen
Temp EQU R3 ;Temp (Use AFTER X is added)
csect .IO_ScaleWallColumn[PR]
CMPLWI Scale,0 ;Is the scale factor zero?
BEQLR ;Exit NOW!
LWZ ScreenPtr,VideoPointer[TC](RTOC) ;Get handle to video
LWZ ArtStart,ArtData[TC](RTOC) ;Get handle to art data list
LWZ VWidth,VideoWidth[TC](RTOC) ;Get handle to video width
LWZ Frac,ScaleDiv[TC](RTOC)
LWZ VHeight,MacViewHeight[TC](RTOC) ;Get pointer to view height
LWZ ScreenPtr,0(ScreenPtr) ;I have the base pointer
LWZ VWidth,0(VWidth) ;Init video width
LWZ VHeight,0(VHeight) ;Get the number of lines visible
SLWI Scale,Scale,1 ;Mul scale by 2 (Get true pixel value
ADD ScreenPtr,ScreenPtr,X ;Add the X coord (Frees Temp)
SLWI Temp,Scale,1 ;Get low word index
SLWI Tile,Tile,2 ;Get the wall shape pointer
LWZX Frac,Frac,Temp ;Get the scale factor
SLWI Column,Column,7 ;Mul by 128 pixels
LWZX ArtStart,ArtStart,Tile ;Get pointer to the shape
ADD ArtStart,ArtStart,Column ;I have the shape ptr
CMPLW Scale,VHeight ;Too big?
BGE ClipTop ;Clip the top
;
; No clipping needed!
; Adjust the dest screen for the starting Y coord
;
MTCTR Scale ;Init counter
SUB Temp,VHeight,Scale ;How many lines to jump down?
LI Delta,0 ;Init the delta factor
SRWI Temp,Temp,1 ;Divide by to center vertically
SRWI Integer,Frac,24 ;Isolate the integer
MULLW Temp,VWidth,Temp ;Adjust the Y coord
SLWI Frac,Frac,8 ;Isolate the fraction
ADD ScreenPtr,ScreenPtr,Temp ;Create the dest screen pointer
;
; Tight loop
; Grab byte, adjust fractional scaler values and store to screen
;
More:
LBZ R0,0(ArtStart) ;Fetch a shape byte
ADDC. Delta,Delta,Frac ;Add the scaler fractional
STB R0,0(ScreenPtr) ;Store on the screen
ADDE ArtStart,ArtStart,Integer ;Add the constant
ADD ScreenPtr,ScreenPtr,VWidth ;Go down a line
BDNZ More ;All lines done?
BLR ;Exit routine
;
; Clip the top and bottom
; Calc the number of lost lines by clipping and "Fake"
; the numbers as if I processed those missing lines
;
ClipTop:
MTCTR VHeight ;I will draw a screen line full
SUB Temp,Scale,VHeight ;How many lines to jump down?
SRWI Integer,Frac,24 ;Isolate the integer
SRWI Temp,Temp,1 ;Divide by to center vertically
MULLW Temp,Frac,Temp ;Adjust the scaler by lost lines
SRWI Delta,Temp,24 ;How many bytes are lost?
ADD ArtStart,ArtStart,Delta ;Create the SOURCE art pointer
SLWI Frac,Frac,8 ;Isolate the fraction
SLWI Delta,Temp,8 ;Init the adjusted delta
B More ;Jump to the code
;
; Call the compiled scaler to draw a run of the line
;
csect .SpriteGlue[PR]
SGArtStart EQU R3 ;Pointer to the 6 byte run structure
SGFrac EQU R4 ;Pointer to the scaler
SGInteger EQU R5 ;Pointer to the video
SGScreenPtr EQU R6 ;Pointer to the run base address
SGCount EQU R7
SGDelta EQU R8
SGVWidth EQU R9
LWZ SGVWidth,VideoWidth[TC](RTOC)
LWZ SGVWidth,0(SGVWidth)
MTCTR SGCount
SMore:
LBZ R0,0(SGArtStart) ;Fetch a shape byte
ADDC. SGDelta,SGDelta,SGFrac ;Add the scaler fractional
STB R0,0(SGScreenPtr) ;Store on the screen
ADDE SGArtStart,SGArtStart,SGInteger ;Add the constant
ADD SGScreenPtr,SGScreenPtr,SGVWidth ;Go down a line
BDNZ SMore ;All lines done?
BLR ;Exit routine