Stencil blitting works on the IIgs!
This commit is contained in:
parent
cd094cf23a
commit
436314f3f8
2 changed files with 11 additions and 123 deletions
|
@ -125,118 +125,6 @@ blitTop ldy source ; Load Y register with source pixel offset
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
;----------------------------------------
|
|
||||||
; Blit an 8x8 block with alpha to (almost) anywhere on a surface.
|
|
||||||
;----------------------------------------
|
|
||||||
asmB88ax start
|
|
||||||
|
|
||||||
source equ 1 ; Source Pixels Offset
|
|
||||||
target equ 3 ; Target Pixels Offset
|
|
||||||
mask equ 5 ; Mask Offset
|
|
||||||
t equ 7 ; Temp
|
|
||||||
xc equ 9 ; X Counter
|
|
||||||
yc equ 11 ; Y Counter
|
|
||||||
|
|
||||||
jsubroutine (4:surface,4:tiles,2:sx,2:sy,2:tx,2:ty,2:offset),12
|
|
||||||
using GlobalData
|
|
||||||
|
|
||||||
; Find offset into tile memory
|
|
||||||
lda sx ; Multiply sx by 4 to get offset (two pixels per byte)
|
|
||||||
asl a
|
|
||||||
asl a
|
|
||||||
sta t
|
|
||||||
clc
|
|
||||||
lda sy ; Multiply sy by 16 to get index into scanline table
|
|
||||||
asl a
|
|
||||||
asl a
|
|
||||||
asl a
|
|
||||||
asl a ; y screen location is now in the accumulator
|
|
||||||
tay
|
|
||||||
clc
|
|
||||||
lda ScTable,y ; Load byte offset of y position from table
|
|
||||||
adc t ; Add t to scanline offset
|
|
||||||
sta source ; Offset to start of source pixels
|
|
||||||
|
|
||||||
; Find offset into tile memory for mask data
|
|
||||||
lda offset ; Load offset
|
|
||||||
asl a ; Multiply by 4
|
|
||||||
asl a
|
|
||||||
clc
|
|
||||||
adc source ; Add to source pixel offset
|
|
||||||
sta mask ; Offset to start of mask pixels
|
|
||||||
|
|
||||||
; Divide target horizontal position by two since there are two pixels per byte
|
|
||||||
lda tx ; Load X target position into accumulator
|
|
||||||
lsr a ; Shift Right - divide by 2
|
|
||||||
clc
|
|
||||||
sta tx ; Store it back into tx
|
|
||||||
|
|
||||||
; Find offset into target surface memory
|
|
||||||
lda ty ; Load ty to get index into scanline table
|
|
||||||
asl a ; Multiply by two to get offset into scanline table (two bytes per entry in table)
|
|
||||||
tay
|
|
||||||
lda ScTable,y ; Load byte offset of y position from table
|
|
||||||
adc tx ; Add x position to scanline offset
|
|
||||||
sta target ; Offset to start of target pixels
|
|
||||||
|
|
||||||
lda #0 ; Load 0 into X and Y counters
|
|
||||||
sta xc
|
|
||||||
sta yc
|
|
||||||
|
|
||||||
blitTop ldy target ; Load Y register with target pixel offset
|
|
||||||
lda [surface],y ; Load target pixels
|
|
||||||
ldy mask ; Load Y register with mask pixel offset
|
|
||||||
and [tiles],y ; AND with mask
|
|
||||||
ldy source ; Load Y register with source pixel offset
|
|
||||||
ora [tiles],y ; OR with source pixels
|
|
||||||
ldy target ; Load Y register with target pixel offset
|
|
||||||
sta [surface],y ; Store 4 pixels into screen
|
|
||||||
|
|
||||||
clc ; Increment to next pixel target quad
|
|
||||||
lda #2
|
|
||||||
adc target
|
|
||||||
sta target
|
|
||||||
clc ; Increment to next pixel source quad
|
|
||||||
lda #2
|
|
||||||
adc source
|
|
||||||
sta source
|
|
||||||
clc ; Increment to next pixel mask quad
|
|
||||||
lda #2
|
|
||||||
adc mask
|
|
||||||
sta mask
|
|
||||||
|
|
||||||
clc
|
|
||||||
lda xc ; Increment X counter
|
|
||||||
adc #1
|
|
||||||
sta xc
|
|
||||||
cmp #2 ; End of X pixels?
|
|
||||||
bcc blitTop ; Nope!
|
|
||||||
|
|
||||||
lda #0 ; Reset X counter
|
|
||||||
sta xc
|
|
||||||
clc ; Increment target offset
|
|
||||||
lda #156
|
|
||||||
adc target
|
|
||||||
sta target
|
|
||||||
clc ; Increment source offset
|
|
||||||
lda #156
|
|
||||||
adc source
|
|
||||||
sta source
|
|
||||||
clc ; Increment mask offset
|
|
||||||
lda #156
|
|
||||||
adc mask
|
|
||||||
sta mask
|
|
||||||
clc
|
|
||||||
lda yc ; Increment Y counter
|
|
||||||
adc #1
|
|
||||||
sta yc
|
|
||||||
cmp #8 ; End of Y pixels?
|
|
||||||
bcc blitTop ; Nope!
|
|
||||||
|
|
||||||
jreturn
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
;----------------------------------------
|
;----------------------------------------
|
||||||
; Blit an 8x8 block with stencil to (almost) anywhere on a surface.
|
; Blit an 8x8 block with stencil to (almost) anywhere on a surface.
|
||||||
;----------------------------------------
|
;----------------------------------------
|
||||||
|
@ -285,9 +173,6 @@ maskW equ 15 ; Actual mask bytes for pixels
|
||||||
adc tx ; Add x position to scanline offset
|
adc tx ; Add x position to scanline offset
|
||||||
sta target ; Offset to start of target pixels
|
sta target ; Offset to start of target pixels
|
||||||
|
|
||||||
|
|
||||||
brk
|
|
||||||
|
|
||||||
; Find starting stencil byte
|
; Find starting stencil byte
|
||||||
clc
|
clc
|
||||||
lda sy ; Vertical cell position
|
lda sy ; Vertical cell position
|
||||||
|
@ -307,19 +192,21 @@ stenTop ldy stenO ; Load byte at stencil offset
|
||||||
xba ; Shift it into the high byte
|
xba ; Shift it into the high byte
|
||||||
sta stenB ; Put it in to the stencil byte
|
sta stenB ; Put it in to the stencil byte
|
||||||
|
|
||||||
|
|
||||||
; Convert stencil byte to mask word (4 pixels)
|
; Convert stencil byte to mask word (4 pixels)
|
||||||
blitTop ldx #4 ; How many pixels to process?
|
blitTop ldx #4 ; How many pixels to process?
|
||||||
lda #0 ; Initially, the mask word is all zero bits
|
lda #$ffff ; Initially, the mask word is all one bits
|
||||||
sta maskW
|
sta maskW
|
||||||
nextNib lda stenB ; Load stencil byte into accumulator
|
nextNib lda stenB ; Load stencil byte into accumulator
|
||||||
asl a ; Shift first bit out of stencil byte into C
|
asl a ; Shift first bit out of stencil byte into C
|
||||||
bcs pixOn ; If C is set, we draw the pixel
|
sta stenB ; Update stencil byte
|
||||||
|
bcc pixOn ; If C is clear, we draw the pixel (opposite of the mask data)
|
||||||
lda maskW ; Load mask word into accumulator
|
lda maskW ; Load mask word into accumulator
|
||||||
asl a ; Shift mask word over a pixel (4 bits)
|
asl a ; Shift mask word over a pixel (4 bits)
|
||||||
asl a
|
asl a
|
||||||
asl a
|
asl a
|
||||||
asl a
|
asl a
|
||||||
and #$fff0 ; Do not draw pixel - mask it off
|
; or #$0000 ; Do not draw pixel - mask it off
|
||||||
sta maskW ; Store updated mask word
|
sta maskW ; Store updated mask word
|
||||||
jmp nextPix ; Start next pixel
|
jmp nextPix ; Start next pixel
|
||||||
pixOn lda maskW ; Load mask word into accumulator
|
pixOn lda maskW ; Load mask word into accumulator
|
||||||
|
@ -327,15 +214,16 @@ pixOn lda maskW ; Load mask word into accumulator
|
||||||
asl a
|
asl a
|
||||||
asl a
|
asl a
|
||||||
asl a
|
asl a
|
||||||
and #$ffff ; Draw pixel
|
ora #$000f ; Draw pixel
|
||||||
sta maskW ; Store updated mask word
|
sta maskW ; Store updated mask word
|
||||||
nextPix dex ; Decrement pixel counter in X
|
nextPix dex ; Decrement pixel counter in X
|
||||||
bne nextNib ; Not zero? Do next nibble/pixel
|
bne nextNib ; Not zero? Do next nibble/pixel
|
||||||
|
|
||||||
; Draw four pixels
|
; Draw four pixels
|
||||||
|
lda maskW ; Load mask word
|
||||||
|
xba ; Flip MSB and LSB
|
||||||
ldy target ; Load Y register with target pixel offset
|
ldy target ; Load Y register with target pixel offset
|
||||||
lda [surface],y ; Load target pixels
|
and [surface],y ; AND target pixels with mask word
|
||||||
and maskW ; AND with mask word
|
|
||||||
ldy source ; Load Y register with source pixel offset
|
ldy source ; Load Y register with source pixel offset
|
||||||
ora [tiles],y ; OR with source pixels
|
ora [tiles],y ; OR with source pixels
|
||||||
ldy target ; Load Y register with target pixel offset
|
ldy target ; Load Y register with target pixel offset
|
||||||
|
@ -368,7 +256,7 @@ nextPix dex ; Decrement pixel counter in X
|
||||||
adc source
|
adc source
|
||||||
sta source
|
sta source
|
||||||
clc ; Increment stencil mask offset
|
clc ; Increment stencil mask offset
|
||||||
lda #39
|
lda #40
|
||||||
adc stenO
|
adc stenO
|
||||||
sta stenO
|
sta stenO
|
||||||
clc
|
clc
|
||||||
|
|
|
@ -333,7 +333,7 @@ extern void asmPoint(jlSurfaceT target, jint16 color, jint16 x, jint16 y);
|
||||||
|
|
||||||
// Inlined functions
|
// Inlined functions
|
||||||
#define jlDrawBlit8x8(source, cx1, cy1, cx2, cy2) asmB88(_jlDrawTargetActual, source, cx1, cy1, cx2, cy2)
|
#define jlDrawBlit8x8(source, cx1, cy1, cx2, cy2) asmB88(_jlDrawTargetActual, source, cx1, cy1, cx2, cy2)
|
||||||
#define jlDrawBlit8x8a(source, stencil, cx1, cy1, cx2, cy2) asmB88a(_jlDrawTargetActual, source, (byte *)stencil, cx1, cy1, cx2, cy2)
|
#define jlDrawBlit8x8a(source, stencil, cx1, cy1, cx2, cy2) asmB88a(_jlDrawTargetActual, source, (byte *)stencil->pixels, cx1, cy1, cx2, cy2)
|
||||||
#define jlDrawBlitMap(startX, startY, width, height, mapData, stride, source) asmDrawBM(_jlDrawTargetActual, startX, startY, width, height, (byte *)mapData, stride, source)
|
#define jlDrawBlitMap(startX, startY, width, height, mapData, stride, source) asmDrawBM(_jlDrawTargetActual, startX, startY, width, height, (byte *)mapData, stride, source)
|
||||||
#define jlDrawPixelGet(x, y) asmGetPoint(_jlDrawTargetActual, x, y)
|
#define jlDrawPixelGet(x, y) asmGetPoint(_jlDrawTargetActual, x, y)
|
||||||
#define jlDrawPixelSet(x, y) asmPoint(_jlDrawTargetActual, _jlDrawColorNibbles, x, y)
|
#define jlDrawPixelSet(x, y) asmPoint(_jlDrawTargetActual, _jlDrawColorNibbles, x, y)
|
||||||
|
|
Loading…
Add table
Reference in a new issue