mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-10-03 21:55:17 +00:00
Closer to having a workable first draft of tile rendering but not done yet
This commit is contained in:
parent
9dbe9a9656
commit
8f49e482c5
@ -58,8 +58,9 @@ SECTION_Y_START = $61 ; Y Offset relative to current section being drawn
|
|||||||
DRAW_WIDTH = $62 ; Number of columns to draw for current section (cannot be destroyed by drawing loop)
|
DRAW_WIDTH = $62 ; Number of columns to draw for current section (cannot be destroyed by drawing loop)
|
||||||
DRAW_HEIGTH = $63 ; Number of rows to draw for current section (cannot be destroyed by drawing loop)
|
DRAW_HEIGTH = $63 ; Number of rows to draw for current section (cannot be destroyed by drawing loop)
|
||||||
DRAW_SECTION = $64 ; Location of section data being drawn
|
DRAW_SECTION = $64 ; Location of section data being drawn
|
||||||
X_COUNTER = $65 ; Loop counter used during drawing
|
X_COUNTER = $66 ; Loop counter used during drawing
|
||||||
Y_COUNTER = $66 ; Loop counter used during drawing
|
Y_COUNTER = $67 ; Loop counter used during drawing
|
||||||
|
ROW_LOCATION = $68 ; Used for pointing at row offset in map data
|
||||||
|
|
||||||
; >> INIT (reset map drawing vars)
|
; >> INIT (reset map drawing vars)
|
||||||
INIT
|
INIT
|
||||||
@ -328,7 +329,7 @@ CROSS_WEST
|
|||||||
SBC SECTION_Y_START
|
SBC SECTION_Y_START
|
||||||
STA DRAW_HEIGHT
|
STA DRAW_HEIGHT
|
||||||
!move_word ptr, DRAW_SECTION
|
!move_word ptr, DRAW_SECTION
|
||||||
jsr mainDraw
|
jsr mainDraw
|
||||||
}
|
}
|
||||||
|
|
||||||
DRAW
|
DRAW
|
||||||
@ -399,31 +400,94 @@ COL_OFFSET = 2
|
|||||||
ROW_OFFSET = 3
|
ROW_OFFSET = 3
|
||||||
|
|
||||||
; Identify start of map data (upper left)
|
; Identify start of map data (upper left)
|
||||||
;tblHGRl, tblHGRh lookups are 24-row based, successive lines inside there are at 0x0400 offsets
|
|
||||||
|
|
||||||
; Self-modifying code: Update all the STA statements in the drawTile section
|
; Self-modifying code: Update all the STA statements in the drawTile section
|
||||||
|
LDY DRAW_Y_START
|
||||||
LDA tblHGRl+ROW_OFFSET, Y
|
LDA tblHGRl+ROW_OFFSET, Y
|
||||||
ADC #COL_OFFSET
|
ADC #COL_OFFSET
|
||||||
!for store, 32 {
|
TAX
|
||||||
STA drawTile+(store*7)+4
|
INX
|
||||||
|
!for store, 16 {
|
||||||
|
STA .drawTile+(store*14)+3
|
||||||
|
STX .drawTile+(store*14)+10
|
||||||
!if store=16 {
|
!if store=16 {
|
||||||
LDA tblHGRl+ROW_OFFSET+1, Y
|
LDA tblHGRl+ROW_OFFSET+1, Y
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LDA tblHGRh+ROW_OFFSET, Y
|
LDA tblHGRh+ROW_OFFSET, Y
|
||||||
!for store, 32 {
|
!for store, 16 {
|
||||||
STA drawTile+(store*7)+5
|
STA .drawTile+(store*14)+4
|
||||||
!if store=15 {
|
STA .drawTile+(store*14)+11
|
||||||
|
!if store = 7 {
|
||||||
LDA tblHGRh+ROW_OFFSET+1, Y
|
LDA tblHGRh+ROW_OFFSET+1, Y
|
||||||
} else {
|
} else {
|
||||||
!if store < 31 {
|
; We have to calculate the start of the next row but only if we are not already at the last row
|
||||||
|
!if store < 15 {
|
||||||
adc #$04
|
adc #$04
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
;Calculate data offset == DRAW_SECTION + (row * 22) + 6 == DRAW_SECTION + (row * 2 + row * 4 + row * 16) + 6
|
||||||
|
CLC
|
||||||
|
LDA SECTION_Y_START ;row * 2
|
||||||
|
ASL
|
||||||
|
ADC #HEADER_LENGTH
|
||||||
|
ADC SECTION_X_START
|
||||||
|
STA ROW_LOCATION
|
||||||
|
LDA SECTION_Y_START ; row * 4
|
||||||
|
ASL
|
||||||
|
ASL
|
||||||
|
ADC ROW_LOCATION
|
||||||
|
STA ROW_LOCATION
|
||||||
|
LDA SECTION_Y_START ; row * 16 -- possibly carry
|
||||||
|
ASL
|
||||||
|
ASL
|
||||||
|
ASL
|
||||||
|
ASL
|
||||||
|
ADC ROW_LOCATION
|
||||||
|
STA ROW_LOCATION
|
||||||
|
LDA DRAW_SECTION + 1
|
||||||
|
ADC #$00 ; This is a short way for handling carry without a branch
|
||||||
|
STA ROW_LOCATION + 1
|
||||||
|
LDA DRAW_SECTION
|
||||||
|
ADC ROW_LOCATION
|
||||||
|
STA ROW_LOCATION
|
||||||
|
; Handle carry if needed
|
||||||
|
BCC .doneCalculatingLocation
|
||||||
|
INC ROW_LOCATION + 1
|
||||||
|
.doneCalculatingLocation
|
||||||
|
CLC
|
||||||
|
LDA SECTION_Y_START
|
||||||
|
ASL
|
||||||
|
ADC ROW_LOCATION
|
||||||
|
STA ROW_LOCATION
|
||||||
|
LDA SECTION_Y_START
|
||||||
|
ASL
|
||||||
|
ASL
|
||||||
|
ADC ROW_LOCATION
|
||||||
|
STA ROW_LOCATION
|
||||||
|
|
||||||
|
LDX DRAW_X_START
|
||||||
; Display row of tiles
|
; Display row of tiles
|
||||||
|
.next_col
|
||||||
; Get tile
|
; Get tile
|
||||||
|
LDA ROW_LOCATION, X
|
||||||
|
; Calculate location of tile data == tile_base + ((tile & 31) * 16)
|
||||||
|
AND #31
|
||||||
|
ASL
|
||||||
|
ASL
|
||||||
|
ASL
|
||||||
|
ASL
|
||||||
|
STA TILE_SOURCE
|
||||||
|
LDA TILE_BASE
|
||||||
|
ADC #$00
|
||||||
|
STA TILE_SOURCE+1
|
||||||
|
LDA TILE_BASE
|
||||||
|
ADC TILE_SOURCE
|
||||||
|
STA TILE_SOURCE
|
||||||
|
BCC .doenCalculatingTileLocation
|
||||||
|
INC TILE_SOURCE+1
|
||||||
|
.doenCalculatingTileLocation
|
||||||
; Is there a NPC there?
|
; Is there a NPC there?
|
||||||
; No, use map tile
|
; No, use map tile
|
||||||
; Yes, use NPC tile
|
; Yes, use NPC tile
|
||||||
@ -434,20 +498,31 @@ ROW_OFFSET = 3
|
|||||||
; If tile is different then redraw
|
; If tile is different then redraw
|
||||||
; -- unrolled loop for 16 rows at a time
|
; -- unrolled loop for 16 rows at a time
|
||||||
LDY #$00
|
LDY #$00
|
||||||
drawTile !for row, 16 {
|
TXA ; In the drawing part, we need X=X*2
|
||||||
!for col, 2 {
|
ASL
|
||||||
LDA (TILE_SOURCE),Y
|
TAX
|
||||||
STA DRAW_ROW, X
|
.drawTile !for row, 16 {
|
||||||
INY
|
.0 LDA (TILE_SOURCE),Y
|
||||||
!if col = 0 {
|
.2 STA DRAW_ROW, X
|
||||||
INX
|
.5 INY
|
||||||
} else {
|
.6 INX
|
||||||
DEX
|
.7 LDA (TILE_SOURCE),Y
|
||||||
|
.9 STA DRAW_ROW, X
|
||||||
|
!if row < 15 {
|
||||||
|
.12 INY
|
||||||
|
.13 DEX
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
DEC X_COUNTER
|
||||||
|
BMI .next_row
|
||||||
|
TXA ; Outside the drawing part we need to put X back (divide by 2)
|
||||||
|
LSR
|
||||||
|
TAX
|
||||||
|
BNE .next_col
|
||||||
; Increment row
|
; Increment row
|
||||||
|
.next_row
|
||||||
|
|
||||||
; Draw player
|
; Draw player
|
||||||
|
|
||||||
tblHGRl
|
tblHGRl
|
||||||
|
Loading…
Reference in New Issue
Block a user