**************************************************************** * ; * 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 [bytes lsr a inc a sta [ boundsok lda Q_pixbounds ; get source rowsize in bytes dec a lsr a ; (already adjusted for mode) inc a sta srowsize lda Q_pixbounds+2 ; get destination rowsize in bytes dec a lsr a ; (already adjusted for mode) inc a sta drowsize lda Q_pixbounds+2 ; is there an extra pixel on the edge and #1 ; of the destination map? sta slop moveword Q_pixbounds,rcount moveword #1,sside stz soffset ; (start at the left of source) rloop jsl D_BeachBall moveword drowsize,doffset ; initialize the offsets movelong srcpix,srcrow ; (start at the top of source) moveword slop,dside ; and other goodies stz pixel ploop moveword [srcrow]:soffset,a ; get the source byte ldx sside ; which side is the pixel on? bne shipixel and #$f ; it's low. ldx dside ; should it be? beq putpixel asl a asl a asl a asl a bra gotpixel shipixel and #$f0 ; it's high ldx dside ; should it be? bne gotpixel lsr a lsr a lsr a lsr a gotpixel ora pixel putpixel sta pixel lda dside ; am I done with this byte? beq nowrite dec doffset ; move backwards through the dest. row movebyte pixel,[dstpix]:doffset lda doffset ; am I done with this row? jeq rdone stz dside stz pixel bra nextp nowrite inc dside nextp addwl srowsize,srcrow ; next source row. brl ploop rdone dec rcount jeq bye addwl drowsize,dstpix ; next destination row lda sside eor #1 sta sside beq stayput ; if sside = 0, same src byte column addwl #1,soffset ; else, use next one stayput brl rloop bye return ENDP **************************************************************** * * Q_RotLMap(srcpix:l,dstpix:l) -- rotate a pixelmap anticlockwise * * Source is scanned leftwards a column at a time, starting * at the bottom of each column. Destination is scanned * downward a row at a time, starting at the right end * of each row. * **************************************************************** Q_RotLMap PROC EXPORT ;Using Q_PictData input srcpix:l,dstpix:l local srowsize:w,drowsize:w,spicsize:l local soffset:w,doffset:w,rcount:w,srcrow:l local pixel:w,slop:w,dside:w,sside:w begin lda Q_pixSCB beq boundsok dec Q_pixbounds ; adjust OLD width of bounds ONLY lsr Q_pixbounds inc Q_pixbounds ; boundsok lda Q_pixbounds ; get source rowsize in bytes dec a lsr a ; (already adjusted for mode) inc a sta srowsize lda Q_pixbounds+2 ; get destination rowsize in bytes dec a lsr a ; (already adjusted for mode) inc a sta drowsize lda Q_pixbounds+2 ; is there an extra pixel on the edge and #1 ; of the destination map? sta slop moveword Q_pixbounds,rcount lda Q_pixbounds ; how about the source map? and #1 sta sside spacelong ; how big is the whole thing? pushword srowsize subword Q_pixbounds+2,#1,s _Multiply pulllong spicsize moveword srowsize,soffset ; start at right of source map dec soffset rloop jsl D_BeachBall moveword drowsize,doffset ; initialize the offsets addlong srcpix,spicsize,srcrow ; (start at bottom of source) ; subwl srowsize,srcrow moveword slop,dside ; and other goodies stz pixel ploop moveword [srcrow]:soffset,a ; get the source byte ldx sside ; which side is the pixel on? bne shipixel and #$f ; it's low. ldx dside ; should it be? beq gotpixel asl a asl a asl a asl a bra gotpixel shipixel and #$f0 ; it's high ldx dside ; should it be? bne gotpixel lsr a lsr a lsr a lsr a gotpixel ora pixel putpixel sta pixel lda dside ; am I done with this byte? beq nowrite dec doffset ; move backwards through the dest. row movebyte pixel,[dstpix]:doffset lda doffset ; am I done with this row? jeq rdone stz dside stz pixel bra nextp nowrite inc dside nextp subwl srowsize,srcrow ; previous source row. brl ploop rdone dec rcount jeq bye addwl drowsize,dstpix ; next destination row lda sside eor #1 sta sside bne stayput ; if sside = 1, same src byte column dec soffset ; else, use previous one stayput brl rloop bye return ENDP END