mirror of
https://github.com/antoinevignau/source.git
synced 2024-10-31 22:06:40 +00:00
1 line
16 KiB
Plaintext
1 line
16 KiB
Plaintext
|
****************************************************************
* ;
* Pixelmap flipping and rotation routines ;
*______________________________________________________________*
* ;
* Pixelmaps are flipped and rotated with 4-bit Q_Pixels. ;
* (For once, I'm glad that there ISN'T a 640x400 one bit- ;
* per-pixel mode!!) 640 pixel maps that are an odd number ;
* of (640) Q_Pixels wide will lose a column when rotated. ;
* TANSTAAFL. Shit happens. ;
* ;
* It's rather strange, but the SCB for a pixelmap in a ;
* picture is ALWAYS the same as the picture's SCB. This is ;
* incredibly fortuitous, since we only have to worry about ;
* one mode at a time now. ;
* ;
* (At least, I've never SEEN them different....) ;
* ;
****************************************************************
LOAD 'Macros.dump'
INCLUDE 'Pict.equ'
INCLUDE 'Driver.equ'
IMPORT D_BeachBall
IMPORT Q_ChangePictSize
IMPORT Q_Copy2
IMPORT Q_Copy4
IMPORT Q_FixRect
IMPORT Q_JustRect
IMPORT Q_JustRgn
IMPORT Q_manglePt
IMPORT Q_Nop
IMPORT Q_PixelTable
IMPORT Q_addbytes
IMPORT Q_center
IMPORT Q_dstpixsize
IMPORT newptr
IMPORT oldptr
IMPORT Q_picterr
IMPORT Q_pixSCB
IMPORT Q_pixbounds
IMPORT Q_srcpixsize
IMPORT thepoint
IMPORT what
****************************************************************
*
* Q_PixOps -- handle picture opcodes Q_PixRect and Q_PixRgn
*
****************************************************************
Q_PixOps PROC EXPORT
;Using Q_PictData
EXPORT Q_PixRgn
EXPORT Q_PixRect
Q_Mask DS.B 2 ; is there a Q_Mask Q_Region?
toppt DS.B 4 ; upper left of old bounds
*--------------------------------------------------------------*
* Copy a pixelmap opcode and mangle its data ;
*--------------------------------------------------------------*
Q_PixRgn ;
inc Q_Mask
bra dopixels
Q_PixRect ;
stz Q_Mask
dopixels jsl Q_Nop ; copy opcode
lda [<oldptr]
and #$80 ; D_Save mode
sta Q_pixSCB
jsl Q_Copy4 ; copy SCB and BWvsColor
spacelong ; get the size of the old pixelmap
pushword [<oldptr] ; old width
subword [<oldptr]:#6,[<oldptr]:#2,s ; old height
_Multiply
pulllong Q_srcpixsize
movelong [<oldptr]:#2,toppt ; get upper left Q_Point of bounds
cmpw <what,#Q_rotr ; am I rotating?
jlt pixflip ; must not be
*--------------------------------------------------------------*
* ROTATE ;
*--------------------------------------------------------------*
subword [<oldptr]:#6,toppt,a ; get height of bounds
dec a ; convert Q_Pixels->bytes
lsr a
inc a
sta [<newptr] ; this is the width of the rotated map
movelong #0,[<newptr]:#2 ; adjust first pt. to 0
subword [<oldptr]:#6,toppt,<thepoint ; get the bounds
subword [<oldptr]:#8,toppt+2,<thepoint+2 ; and adjust
ldx <thepoint ; flip the Q_Point diagonally
lda <thepoint+2
sta <thepoint
stx <thepoint+2
movelong <thepoint,Q_pixbounds ; remember the D_New bounds NOW
lda Q_pixSCB ; adjust for 640 mode?
beq newboundsok
lsr <thepoint ; if so, halve the old width
asl <thepoint+2 ; and double the D_New width
newboundsok movelong <thepoint,[<newptr]:#6 ; store D_New (adjusted) bounds
spacelong ; compute the size of the dest. map
pushword [<newptr] ; D_New width
pushword [<newptr]:#6 ; D_New height
_Multiply
pulllong Q_dstpixsize
addwl #10,<oldptr ; adjust the pointers
addwl #10,<newptr
sublong Q_dstpixsize,Q_srcpixsize,Q_addbytes
jsl Q_ChangePictSize
jcc rotsrcrect
sta Q_picterr
brl bye
rotsrcrect pushlong Q_center ; Flip around the pixelmap's
movelong Q_pixbounds,Q_center ; Q_center, not the picture's
noshift subword [<oldptr],toppt,<thepoint+2 ; adjust upper left pt
subword [<oldptr]:#2,toppt+2,<thepoint ; and flip diagonally
getsrc1 lda <what ; Now r-rotation becomes HACK
dec a ; h-flipping, and l-rotation
|