PR#3 PREFIX /A2OSX.BUILD LOMEM $A00 INC 1 AUTO 6 .LIST OFF *-------------------------------------- * BitBlt * S.CB.X1 : SrcX1 in bitmap/mask * S.CB.Y1 : SrcY1 * S.CB.X2 : SrcX2 * S.CB.Y2 : SrcY2 * S.CB.DestX : Destination X (screen) * S.CB.DestY : Destination Y (screen) * S.CB.SrcPtr : pointer to S.BM * S.CB.DstPtr : pointer to Save Buffer *-------------------------------------- BITBLT >LDYA CB.CACHE+S.CB.SrcPtr >STYA ZPBMDataPtr ldy #S.BM-1 .1 lda (ZPBMDataPtr),y sta BM.Cache,y dey bpl .1 lda ZPBMDataPtr clc adc BM.Cache+S.BM.MASK.OFS sta ZPBMMaskPtr lda ZPBMDataPtr+1 adc BM.Cache+S.BM.MASK.OFS+1 sta ZPBMMaskPtr+1 lda ZPBMDataPtr clc adc #S.BM sta ZPBMDataPtr bcc .2 inc ZPBMDataPtr+1 .2 >LDYA CB.Cache+S.CB.Y1 ldx BM.Cache+S.BM.RowBytes jsr YAMultX pha tya clc adc ZPBMDataPtr sta BLT.BMDataPtr pla pha adc ZPBMDataPtr+1 sta BLT.BMDataPtr+1 tya adc ZPBMMaskPtr sta BLT.BMMaskPtr pla adc ZPBMMaskPtr+1 sta BLT.BMMaskPtr+1 lda CB.Cache+S.CB.X1 pha and #7 sta BLT.BMBitOfs pla lsr CB.Cache+S.CB.X1+1 ror lsr CB.Cache+S.CB.X1+1 ror lsr CB.Cache+S.CB.X1+1 ror pha clc adc BLT.BMDataPtr sta BLT.BMDataPtr bcc .3 inc BLT.BMDataPtr+1 .3 pla adc BLT.BMMaskPtr sta BLT.BMMaskPtr bcc .4 inc BLT.BMMaskPtr+1 .4 lda CB.Cache+S.CB.X2 sec sbc CB.Cache+S.CB.X1 sta BLT.DX lda CB.Cache+S.CB.X2+1 sbc CB.Cache+S.CB.X1+1 sta BLT.DX+1 >LDYA CB.Cache+S.CB.DestX jsr LBUF.SetBounds1YA stx BLT.SCRBitOfs lda CB.Cache+S.CB.DestX clc adc BLT.DX tay lda CB.Cache+S.CB.DestX+1 adc BLT.DX+1 jsr LBUF.SetBounds2YA lda CB.Cache+S.CB.Y2 sec sbc CB.Cache+S.CB.Y1 inc sta BLT.DY ldx BLT.SCRBitOfs beq BITBLT.LOOP ldy Shift.L.LO,x X = 1->6 sty ZPScrShiftPtr ldy Shift.L.HI,x X = 1->6 sty ZPScrShiftPtr+1 BITBLT.LOOP >LDYA BLT.BMDataPtr >STYA ZPBMDataPtr >LDYA BLT.BMMaskPtr >STYA ZPBMMaskPtr lda BLT.BMBitOfs sta BLT.BMBitOfsL stz BLT.BMIdx ldx LBUF.C1 stx BLT.ScrColIdx stz LBUF.DATA,x make sure C1 not ORed with trash in "ora LBUF.DATA,x" ldx BLT.SCRBitOfs bne .2 *------------ Shift 0 .1 jsr BLT.Get7BMDBits we have 0xxxxxxxx in A ldx BLT.ScrColIdx sta LBUF.DATA,x inc BLT.ScrColIdx cpx LBUF.C2 bne .1 bra BITBLT.DRAW *------------ Shift 1->6 Comment : SCRBitOfs=X=3 .2 lda Shift7BitsCol1,x get #%00001111, BM bits that go in Col1 sta .4+1 lda Shift7BitsCol2,x get #%01110000, BM bits that go in Col2 sta .5+1 .3 jsr BLT.Get7BMDBits we have c6543210 in A, destination : COL=3210xxx, COL+1=xxxx654 pha save BM byte for 2nd col .4 and #$ff SELF MODIFIED : MASK WITH #%00001111, keep col1 bits only tay lda (ZPScrShiftPtr),y make 0000dddd Shift left 3 : 0dddd000 ldx BLT.ScrColIdx Get actual COL index ora LBUF.DATA,x Light proper bits : 0dddd??? sta LBUF.DATA,x store 0xdddd??? pla Get back BM Byte .5 and #$ff SELF MODIFIED : #%01110000 get only col2 bites tay lda (ZPScrShiftPtr),y shift right 4 (=shift left 3!!!) : 00000ddd sta LBUF.DATA+1,x inx stx BLT.ScrColIdx cpx LBUF.C2 bne .3 BITBLT.DRAW ldy CB.Cache+S.CB.DestY jsr LBUF.DrawAtY inc CB.Cache+S.CB.DestY lda BLT.BMDataPtr clc adc BM.Cache+S.BM.RowBytes sta BLT.BMDataPtr bcc .6 inc BLT.BMDataPtr+1 .6 lda BLT.BMMaskPtr clc adc BM.Cache+S.BM.RowBytes sta BLT.BMMaskPtr bcc .7 inc BLT.BMMaskPtr+1 .7 dec BLT.DY beq .8 jmp BITBLT.LOOP .8 clc rts *-------------------------------------- * BMD/BMM bits : * 76543210 76543210 * ^ * BMBitOfsL (0->7) * LBUF DATA/MASK Bits * c6543210 c6543210 * ^ * SCRBitOfs (0->6) *-------------------------------------- BLT.Get7BMDBits ldy BLT.BMIdx lda (ZPBMDataPtr),y ldx BLT.BMBitOfsL beq BLT.Get7BMBits0 OFS=0, done! and no need to advance ZPBMDataPtr lsr OFS=1->7, shift one (Range 0->127) dex OFS 0->6 beq BLT.Get7BMBits1 OFS was 1....done and go to next byte, OFS=0 ldy Shift.R.LO,x X = 1->6 sty ZPBMShiftPtr ldy Shift.R.HI,x X = 1->6 sty ZPBMShiftPtr+1 and Mask7BitsH,x Get only left upper X bits tay xxxxx000 lda (ZPBMShiftPtr),y shift'em RIGHT 000xxxxx pha inc BLT.BMIdx Next BM data byte ldy BLT.BMIdx lda (ZPBMDataPtr),y get next byte and Mask7BitsL,x only first Y bits 000000yy tay pla get back right part bits 000xxxxx ora (ZPBMShiftPtr),y shift right 000000yy and ORA with 000xxxxx=0yyxxxxx dec BLT.BMBitOfsL X = 1->6, ADD 7 MOD 8..... rts BLT.Get7BMBits0 and #%01111111 Get only 7 needed bits ldx #7 stx BLT.BMBitOfsL Was 0, add 7 bits rts BLT.Get7BMBits1 stz BLT.BMBitOfsL Was 1, add 7 bits, MOD 8=0 inc BLT.BMIdx go to next byte in BM line rts LSR did already 0xxxxxxx *-------------------------------------- MAN SAVE /A2OSX.SRC/DRV/DHGR.DRV.S.RECT LOAD /A2OSX.SRC/DRV/DHGR.DRV.S ASM