mirror of
https://github.com/lscharen/iigs-game-engine.git
synced 2025-02-17 01:30:52 +00:00
Add untested framework for handling fringe tile rendering
This commit is contained in:
parent
5cfb32c4b1
commit
a82c1248db
66
src/Anim.s
Normal file
66
src/Anim.s
Normal file
@ -0,0 +1,66 @@
|
||||
; Animation helpers
|
||||
;
|
||||
; These provide animation sequencing and pathing support for animations. Some function are
|
||||
; sprite-specific, but the functions are generally applicable to any kind of animation support
|
||||
; by the engine, such as swapping tiles or even just having an asynchronous method of updating
|
||||
; game data.
|
||||
;
|
||||
; Depends on the Timers and Script sub-systems
|
||||
|
||||
|
||||
; AnimatePath
|
||||
;
|
||||
; Moves a sprite between two keyframe point over a specificed number of steps
|
||||
;
|
||||
; X = YYXX ; start position
|
||||
; A = YYXX ; end position
|
||||
; Y = duration ; number of steps from start to end (must be > 0)
|
||||
AnimatePath
|
||||
|
||||
pha ; Store the starting point
|
||||
and #$00FF
|
||||
sta AnimX0
|
||||
pla
|
||||
xba
|
||||
and #$00FF
|
||||
sta AnimY0
|
||||
|
||||
txa ; Store the ending point
|
||||
and #$00FF
|
||||
sta AnimX1
|
||||
txa
|
||||
xba
|
||||
and #$00FF
|
||||
sta AnimY1
|
||||
|
||||
sty AnimDuration
|
||||
|
||||
; Calculate the steps for the X and Y positions. This is line drawing two lines
|
||||
; at a time . The slope of the lines are (X1 - X0) / Duration and (Y1 - Y0) / Duration.
|
||||
;
|
||||
; The tricky bit is that we *always* single-step in the "Y" direction (duration), so we
|
||||
; actaully need to use two differenct algorithms.
|
||||
;
|
||||
; If |X1 - X0| <= Duration, use a standard line-drawing approach (Bresenham's, DDA, etc.)
|
||||
; If |X1 - X0| > Duration, use the Run-Length Slice algorithm (https://www.phatcode.net/res/224/files/html/ch36/36-02.html)
|
||||
|
||||
lda AnimY
|
||||
|
||||
:stepx lda
|
||||
|
||||
|
||||
cmp AnimDuration ; Handle the two cases
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -226,6 +226,8 @@ EngineReset
|
||||
stz TileMapHeight
|
||||
stz TileMapPtr
|
||||
stz TileMapPtr+2
|
||||
stz FringeMapPtr
|
||||
stz FringeMapPtr+2
|
||||
|
||||
stz BG1TileMapWidth
|
||||
stz BG1TileMapHeight
|
||||
@ -378,4 +380,3 @@ ReadControl ENT
|
||||
put blitter/BG0.s
|
||||
put blitter/BG1.s
|
||||
put TileMap.s
|
||||
|
||||
|
@ -70,12 +70,13 @@ OldBG1TileOriginY equ 68
|
||||
TileMapWidth equ 70
|
||||
TileMapHeight equ 72
|
||||
TileMapPtr equ 74
|
||||
FringeMapPtr equ 78
|
||||
|
||||
BG1TileMapWidth equ 78
|
||||
BG1TileMapHeight equ 80
|
||||
BG1TileMapPtr equ 82
|
||||
BG1TileMapWidth equ 82
|
||||
BG1TileMapHeight equ 84
|
||||
BG1TileMapPtr equ 86
|
||||
|
||||
Next equ 86
|
||||
Next equ 90
|
||||
|
||||
BankLoad equ 128
|
||||
|
||||
|
57
src/Sprite.s
57
src/Sprite.s
@ -3,60 +3,3 @@
|
||||
;
|
||||
; The main point of this file to to establish calling conventions and provide a framework
|
||||
; for blitting a range of sprite lines, instead of always the full sprite.
|
||||
|
||||
; A = address, X = scroll_mask offset, Y = HHLL, LL = first line, HH = last line
|
||||
draw
|
||||
sei
|
||||
|
||||
cli
|
||||
rts
|
||||
|
||||
lines dw line0,line1,line2,line3,line4,line5,line6,line7
|
||||
|
||||
line0
|
||||
lda 0
|
||||
and #$FF00
|
||||
ora #$00DD
|
||||
sta 0
|
||||
|
||||
line1
|
||||
lda 0
|
||||
and #$FF00
|
||||
ora #$00DD
|
||||
sta 0
|
||||
|
||||
line2
|
||||
lda 0
|
||||
and #$FF00
|
||||
ora #$00DD
|
||||
sta 0
|
||||
|
||||
line3
|
||||
lda 0
|
||||
and #$FF00
|
||||
ora #$00DD
|
||||
sta 0
|
||||
|
||||
line4
|
||||
lda 0
|
||||
and #$FF00
|
||||
ora #$00DD
|
||||
sta 0
|
||||
|
||||
line5
|
||||
lda 0
|
||||
and #$FF00
|
||||
ora #$00DD
|
||||
sta 0
|
||||
|
||||
line6
|
||||
lda 0
|
||||
and #$FF00
|
||||
ora #$00DD
|
||||
sta 0
|
||||
|
||||
line7
|
||||
lda 0
|
||||
and #$FF00
|
||||
ora #$00DD
|
||||
sta 0
|
||||
|
@ -313,9 +313,24 @@ _UpdateBG0TileMap
|
||||
:xloop
|
||||
ldy :Offset ; Set up the arguments and call the tile blitter
|
||||
lda [TileMapPtr],y
|
||||
iny ; pre-increment the address. A bit faster than two "INC DP" instructions
|
||||
iny
|
||||
sty :Offset
|
||||
|
||||
; Handle fringe tiles -- if the fringe bit is set, then we need to get the fringe tile index
|
||||
; and merge the tiles before rendering
|
||||
bit #$TILE_FRINGE_BIT
|
||||
beq :no_fringe
|
||||
jsr _GetTileAddr
|
||||
tax
|
||||
lda FringeMapPtr
|
||||
ora FringeMapPtr+2
|
||||
beq :no_fringe
|
||||
lda [FringeMapPtr],y
|
||||
jsr _GetTileAddr
|
||||
tay
|
||||
jsr _MergeTiles
|
||||
|
||||
:no_fringe
|
||||
inc :Offset ; pre-increment the address.
|
||||
inc :Offset
|
||||
|
||||
ldx :BlkX
|
||||
ldy :BlkY
|
||||
|
1163
src/blitter/Tiles.s
1163
src/blitter/Tiles.s
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user