mirror of
https://github.com/lscharen/iigs-game-engine.git
synced 2024-12-29 09:33:23 +00:00
Add in new variants for sprite and priority tiles
This commit is contained in:
parent
5fdb4bcf06
commit
44cbba3f23
@ -414,8 +414,9 @@ ReadControl ENT
|
||||
put blitter/Tiles10000.s ; normal tiles + sprites
|
||||
put blitter/Tiles10001.s
|
||||
put blitter/Tiles10010.s ; normal masked tiles + sprites
|
||||
; put blitter/Tiles10011.s
|
||||
put blitter/Tiles11000.s ; normal high priority tile + sprites
|
||||
put blitter/Tiles10011.s
|
||||
put blitter/Tiles11000.s ; normal high priority tiles + sprites
|
||||
put blitter/Tiles11010.s ; normal high priority masked tiles + sprites
|
||||
put blitter/TilesBG1.s
|
||||
put blitter/Vert.s
|
||||
put blitter/BG0.s
|
||||
|
@ -189,7 +189,8 @@ TileProcs dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolid
|
||||
dw _TBDynamicSpriteTile_00,_TBDynamicSpriteTile_00 ; 10001 : dynamic tiles w/sprite
|
||||
dw _TBMaskedSpriteTile_00,_TBMaskedSpriteTile_0H
|
||||
dw _TBMaskedSpriteTile_V0,_TBMaskedSpriteTile_VH ; 10010 : masked normal tiles w/sprite
|
||||
dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolidTile_VH ; 10011 : masked dynamic tiles w/sprite
|
||||
dw _TBDynamicMaskedSpriteTile_00,_TBDynamicMaskedSpriteTile_00
|
||||
dw _TBDynamicMaskedSpriteTile_00,_TBDynamicMaskedSpriteTile_00 ; 10011 : masked dynamic tiles w/sprite
|
||||
|
||||
dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolidTile_VH ; 10100 : fringed normal tiles w/sprite
|
||||
dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolidTile_VH ; 10101 : fringed dynamic tiles w/sprite
|
||||
@ -199,7 +200,8 @@ TileProcs dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolid
|
||||
dw _TBSolidPrioritySpriteTile_00,_TBSolidPrioritySpriteTile_0H,
|
||||
dw _TBSolidPrioritySpriteTile_V0,_TBSolidPrioritySpriteTile_VH ; 11000 : high-priority normal tiles w/sprite
|
||||
dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolidTile_VH ; 11001 : high-priority dynamic tiles w/sprite
|
||||
dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolidTile_VH ; 11010 : high-priority masked normal tiles w/sprite
|
||||
dw _TBMaskedPrioritySpriteTile_00,_TBMaskedPrioritySpriteTile_0H
|
||||
dw _TBMaskedPrioritySpriteTile_V0,_TBMaskedPrioritySpriteTile_VH ; 11010 : high-priority masked normal tiles w/sprite
|
||||
dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolidTile_VH ; 11011 : high-priority masked dynamic tiles w/sprite
|
||||
|
||||
dw _TBSolidTile_00,_TBSolidTile_0H,_TBSolidTile_V0,_TBSolidTile_VH ; 11100 : high-priority fringed normal tiles w/sprite
|
||||
|
@ -39,10 +39,8 @@ _TBDynamicDataAndMask
|
||||
CopyMaskedDWord $7003
|
||||
|
||||
ldx _X_REG
|
||||
inx
|
||||
inx
|
||||
clc
|
||||
ldal JTableOffset,x ; Get the address offset and add to the base address
|
||||
ldal JTableOffset+2,x ; Get the address offset and add to the base address
|
||||
adc _BASE_ADDR ; of the current code field line
|
||||
sta _JTBL_CACHE
|
||||
|
||||
@ -117,7 +115,7 @@ CopyMaskedDWord MAC
|
||||
sta: $0000,x ; LDA (00),y
|
||||
lda _T_PTR
|
||||
sta: $0002,x ; AND $80,x
|
||||
eor #$2080 ; Switch the opcode to an ORA and remove the high bit of the operand
|
||||
eor #$8020 ; Switch the opcode to an ORA and remove the high bit of the operand
|
||||
sta: $0004,x ; ORA $00,x
|
||||
lda #$0F80 ; branch to the prologue (BRA *+17)
|
||||
sta: $0006,x
|
||||
|
@ -4,7 +4,6 @@
|
||||
_TBMaskedSpriteTile_00
|
||||
sta _X_REG ; Immedately stash the parameters
|
||||
sty _Y_REG
|
||||
; stx _T_PTR
|
||||
|
||||
jsr _TBCopyTileDataToCBuff ; Copy the tile data into the compositing buffer (using correct x-register)
|
||||
jsr _TBCopyTileMaskToCBuff ; Copy the tile mask into the compositing buffer (using correct x-register)
|
||||
|
135
src/blitter/Tiles10011.s
Normal file
135
src/blitter/Tiles10011.s
Normal file
@ -0,0 +1,135 @@
|
||||
; _TBDynamicMaskedSpriteTile
|
||||
;
|
||||
; This tile type does not explicitly support horizontal or vertical flipping. An appropriate tile
|
||||
; descriptor should be passed into CopyTileToDyn to put the horizontally or vertically flipped source
|
||||
; data into the dynamic tile buffer
|
||||
;
|
||||
; When rendering, the background, via lda (dp),y, is shown behind the animate sprite
|
||||
_TBDynamicMaskedSpriteTile_00
|
||||
sty _Y_REG ; This is restored in the macro
|
||||
|
||||
sta _X_REG ; Cache some column values derived from _X_REG
|
||||
tax
|
||||
ora #$B100 ; Pre-calc the LDA (dp),y opcode + operand
|
||||
xba
|
||||
sta _OP_CACHE
|
||||
|
||||
clc
|
||||
ldal JTableOffset,x ; Get the address offset and add to the base address
|
||||
adc _BASE_ADDR ; of the current code field line
|
||||
sta _JTBL_CACHE
|
||||
|
||||
lda _TILE_ID ; Get the original tile descriptor
|
||||
and #$007F ; clamp to < (32 * 4)
|
||||
ora #$3580 ; Pre-calc the AND $80,x opcode + operand
|
||||
xba
|
||||
sta _T_PTR ; This is an op to load the dynamic tile data
|
||||
|
||||
ldx _SPR_X_REG
|
||||
|
||||
CopyDynMaskedSpriteWord {0*SPRITE_PLANE_SPAN};$0003
|
||||
CopyDynMaskedSpriteWord {1*SPRITE_PLANE_SPAN};$1003
|
||||
CopyDynMaskedSpriteWord {2*SPRITE_PLANE_SPAN};$2003
|
||||
CopyDynMaskedSpriteWord {3*SPRITE_PLANE_SPAN};$3003
|
||||
CopyDynMaskedSpriteWord {4*SPRITE_PLANE_SPAN};$4003
|
||||
CopyDynMaskedSpriteWord {5*SPRITE_PLANE_SPAN};$5003
|
||||
CopyDynMaskedSpriteWord {6*SPRITE_PLANE_SPAN};$6003
|
||||
CopyDynMaskedSpriteWord {7*SPRITE_PLANE_SPAN};$7003
|
||||
|
||||
ldx _X_REG
|
||||
clc
|
||||
ldal JTableOffset+2,x ; Get the address offset and add to the base address
|
||||
adc _BASE_ADDR ; of the current code field line
|
||||
sta _JTBL_CACHE
|
||||
|
||||
lda _OP_CACHE
|
||||
adc #$0200
|
||||
sta _OP_CACHE
|
||||
lda _T_PTR
|
||||
adc #$0200
|
||||
sta _T_PTR
|
||||
|
||||
ldx _SPR_X_REG
|
||||
|
||||
CopyDynMaskedSpriteWord {0*SPRITE_PLANE_SPAN}+2;$0000
|
||||
CopyDynMaskedSpriteWord {1*SPRITE_PLANE_SPAN}+2;$1000
|
||||
CopyDynMaskedSpriteWord {2*SPRITE_PLANE_SPAN}+2;$2000
|
||||
CopyDynMaskedSpriteWord {3*SPRITE_PLANE_SPAN}+2;$3000
|
||||
CopyDynMaskedSpriteWord {4*SPRITE_PLANE_SPAN}+2;$4000
|
||||
CopyDynMaskedSpriteWord {5*SPRITE_PLANE_SPAN}+2;$5000
|
||||
CopyDynMaskedSpriteWord {6*SPRITE_PLANE_SPAN}+2;$6000
|
||||
CopyDynMaskedSpriteWord {7*SPRITE_PLANE_SPAN}+2;$7000
|
||||
|
||||
rts
|
||||
|
||||
|
||||
; Masked renderer for a masked dynamic tile with sprite data overlaid.
|
||||
;
|
||||
; ]1 : sprite plane offset
|
||||
; ]2 : code field offset
|
||||
CopyDynMaskedSpriteWord MAC
|
||||
|
||||
; Need to fill in the first 14 bytes of the JMP handler with the following code sequence where
|
||||
; the data and mask from from the sprite plane
|
||||
;
|
||||
; lda ($00),y
|
||||
; and $80,x
|
||||
; ora $00,x
|
||||
; and #MASK
|
||||
; ora #DATA
|
||||
; bra *+15
|
||||
;
|
||||
; If MASK == 0, then we can do a PEA. If MASK == $FFFF, then fall back to the simple Dynamic Tile
|
||||
; code and eliminate the constanct AND/ORA instructions.
|
||||
|
||||
ldal spritemask+]1,x ; load the mask value
|
||||
bne mixed ; a non-zero value may be mixed
|
||||
|
||||
; This is a solid word
|
||||
lda #$00F4 ; PEA instruction
|
||||
sta: ]2,y
|
||||
ldal spritedata+]1,x ; load the sprite data
|
||||
sta: ]2+1,y ; PEA operand
|
||||
bra next
|
||||
|
||||
; We will always do a JMP to the eception handler, so set that up, then check for sprite
|
||||
; transparency
|
||||
mixed
|
||||
lda #$004C ; JMP to handler
|
||||
sta: ]2,y
|
||||
lda _JTBL_CACHE ; Get the offset to the exception handler for this column
|
||||
ora #{]2&$F000} ; adjust for the current row offset
|
||||
sta: ]2+1,y
|
||||
tay ; This becomes the new address that we use to patch in
|
||||
|
||||
lda _OP_CACHE
|
||||
sta: $0000,y ; LDA (00),y
|
||||
lda _T_PTR
|
||||
sta: $0002,y ; AND $80,x
|
||||
eor #$8020 ; Switch the opcode to an ORA and remove the high bit of the operand
|
||||
sta: $0004,y ; ORA $00,x
|
||||
|
||||
ldal spritemask+]1,x
|
||||
cmp #$FFFF ; All 1's in the mask is a fully transparent sprite word
|
||||
beq transparent ; so we can use the Tile00011 method
|
||||
|
||||
sta: $0007,y
|
||||
lda #$0029 ; AND #SPRITE_MASK
|
||||
sta: $0006,y
|
||||
|
||||
lda #$0009 ; ORA #SPRITE_DATA
|
||||
sta: $0009,y
|
||||
ldal spritedata+]1,x
|
||||
sta: $000A,y
|
||||
|
||||
lda #$0980 ; branch to the prologue (BRA *+11)
|
||||
sta: $000C,y
|
||||
bra next
|
||||
|
||||
; This is a transparent word, so just show the dynamic data
|
||||
transparent
|
||||
lda #$0F80 ; branch to the epilogue (BRA *+17)
|
||||
sta: $0006,y
|
||||
next
|
||||
ldy _Y_REG ; restore original y-register value and move on
|
||||
eom
|
61
src/blitter/Tiles11010.s
Normal file
61
src/blitter/Tiles11010.s
Normal file
@ -0,0 +1,61 @@
|
||||
; _TBMaskedPrioritySpriteTile
|
||||
;
|
||||
; Renders a composited tile with masking to the code field. The sprite is underlaid
|
||||
_TBMaskedPrioritySpriteTile_00
|
||||
sta _X_REG ; Immedately stash the parameters
|
||||
sty _Y_REG
|
||||
|
||||
jsr _TBCopyTileDataToCBuff ; Copy the tile data into the compositing buffer (using correct x-register)
|
||||
jsr _TBCopyTileMaskToCBuff ; Copy the tile mask into the compositing buffer (using correct x-register)
|
||||
jsr _TBUnderlaySpriteDataAndMask ; Underlay the data and mask from the sprite plane into the compositing buffer
|
||||
jmp _TBMaskedCBuff ; Render the masked tile from the compositing buffer into the code field
|
||||
|
||||
_TBMaskedPrioritySpriteTile_0H
|
||||
sta _X_REG
|
||||
sty _Y_REG
|
||||
jsr _TBCopyTileDataToCBuffH
|
||||
jsr _TBCopyTileMaskToCBuffH
|
||||
jsr _TBUnderlaySpriteDataAndMask
|
||||
jmp _TBMaskedCBuff
|
||||
|
||||
_TBMaskedPrioritySpriteTile_V0
|
||||
sta _X_REG
|
||||
sty _Y_REG
|
||||
jsr _TBCopyTileDataToCBuffV
|
||||
jsr _TBCopyTileMaskToCBuffV
|
||||
jsr _TBUnderlaySpriteDataAndMask
|
||||
jmp _TBMaskedCBuff
|
||||
|
||||
_TBMaskedPrioritySpriteTile_VH
|
||||
sta _X_REG
|
||||
sty _Y_REG
|
||||
jsr _TBCopyTileDataToCBuffVH
|
||||
jsr _TBCopyTileMaskToCBuffVH
|
||||
jsr _TBUnderlaySpriteDataAndMask
|
||||
jmp _TBMaskedCBuff
|
||||
|
||||
_TBUnderlaySpriteDataAndMask
|
||||
ldx _SPR_X_REG ; set to the unaligned tile block address in the sprite plane
|
||||
|
||||
]line equ 0
|
||||
lup 8
|
||||
ldal spritedata+{]line*SPRITE_PLANE_SPAN},x
|
||||
and blttmp+{]line*4}+32
|
||||
ora blttmp+{]line*4} ; Maybe this can be a TSB???
|
||||
sta blttmp+{]line*4}
|
||||
|
||||
ldal spritemask+{]line*SPRITE_PLANE_SPAN},x
|
||||
and blttmp+{]line*4}+32
|
||||
sta blttmp+{]line*4}+32
|
||||
|
||||
ldal spritedata+{]line*SPRITE_PLANE_SPAN}+2,x
|
||||
and blttmp+{]line*4}+32+2
|
||||
ora blttmp+{]line*4}+2
|
||||
sta blttmp+{]line*4}+2
|
||||
|
||||
ldal spritemask+{]line*SPRITE_PLANE_SPAN}+2,x
|
||||
and blttmp+{]line*4}+32+2
|
||||
sta blttmp+{]line*4}+32+2
|
||||
]line equ ]line+1
|
||||
--^
|
||||
rts
|
Loading…
Reference in New Issue
Block a user