mirror of
https://github.com/badvision/lawless-legends.git
synced 2025-02-23 09:29:00 +00:00
Finished outer drawing loop, now to get the code working... :-)
This commit is contained in:
parent
0dcf9d31e2
commit
bc47e0bc04
@ -50,17 +50,19 @@ EAST =1
|
|||||||
SOUTH =2
|
SOUTH =2
|
||||||
WEST =3
|
WEST =3
|
||||||
|
|
||||||
;-- Variables used in drawing
|
;-- Variables used in drawing which can not be changed by the inner drawing loop
|
||||||
DRAW_X_START = $5E ; Starting column being drawn (between 0 and VIEWPORT_WIDTH)
|
DRAW_X_START = $5E ; Starting column being drawn (between 0 and VIEWPORT_WIDTH)
|
||||||
DRAW_Y_START = $5F ; Starting row being drawn (between 0 and VIEWPORT_WIDTH)
|
DRAW_Y_START = $5F ; Starting row being drawn (between 0 and VIEWPORT_WIDTH)
|
||||||
SECTION_X_START = $60 ; X Offset relative to current section being drawn
|
|
||||||
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
|
||||||
|
;-- These variables are set in the outer draw section but can be destroyed by the inner routine
|
||||||
|
SECTION_X_START = $60 ; X Offset relative to current section being drawn
|
||||||
|
SECTION_Y_START = $61 ; Y Offset relative to current section being drawn
|
||||||
X_COUNTER = $66 ; Loop counter used during drawing
|
X_COUNTER = $66 ; Loop counter used during drawing
|
||||||
Y_COUNTER = $67 ; 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
|
ROW_LOCATION = $68 ; Used for pointing at row offset in map data
|
||||||
|
Y_LOC = $67 ; Current row being drawn (between 0 and VIEWPORT_WIDTH)
|
||||||
|
|
||||||
; >> INIT (reset map drawing vars)
|
; >> INIT (reset map drawing vars)
|
||||||
INIT
|
INIT
|
||||||
@ -399,9 +401,14 @@ DRAW
|
|||||||
COL_OFFSET = 2
|
COL_OFFSET = 2
|
||||||
ROW_OFFSET = 3
|
ROW_OFFSET = 3
|
||||||
|
|
||||||
|
LDA DRAW_HEIGHT
|
||||||
|
STA Y_COUNTER
|
||||||
|
LDA DRAW_Y_START
|
||||||
|
STA Y_LOC
|
||||||
|
.rowLoop
|
||||||
; Identify start of map data (upper left)
|
; Identify start of map data (upper left)
|
||||||
; 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
|
LDY Y_LOC
|
||||||
LDA tblHGRl+ROW_OFFSET, Y
|
LDA tblHGRl+ROW_OFFSET, Y
|
||||||
ADC #COL_OFFSET
|
ADC #COL_OFFSET
|
||||||
TAX
|
TAX
|
||||||
@ -431,7 +438,7 @@ ROW_OFFSET = 3
|
|||||||
CLC
|
CLC
|
||||||
LDA SECTION_Y_START ;row * 2
|
LDA SECTION_Y_START ;row * 2
|
||||||
ASL
|
ASL
|
||||||
ADC #HEADER_LENGTH
|
ADC #HEADER_LENGTH ; +6
|
||||||
ADC SECTION_X_START
|
ADC SECTION_X_START
|
||||||
STA ROW_LOCATION
|
STA ROW_LOCATION
|
||||||
LDA SECTION_Y_START ; row * 4
|
LDA SECTION_Y_START ; row * 4
|
||||||
@ -449,24 +456,15 @@ ROW_OFFSET = 3
|
|||||||
LDA DRAW_SECTION + 1
|
LDA DRAW_SECTION + 1
|
||||||
ADC #$00 ; This is a short way for handling carry without a branch
|
ADC #$00 ; This is a short way for handling carry without a branch
|
||||||
STA ROW_LOCATION + 1
|
STA ROW_LOCATION + 1
|
||||||
LDA DRAW_SECTION
|
LDA DRAW_SECTION ; DRAW_SECTION is done at the very end in case it causes an overflow
|
||||||
ADC ROW_LOCATION
|
ADC ROW_LOCATION
|
||||||
STA ROW_LOCATION
|
STA ROW_LOCATION
|
||||||
; Handle carry if needed
|
; Handle carry if needed
|
||||||
BCC .doneCalculatingLocation
|
BCC .doneCalculatingLocation
|
||||||
INC ROW_LOCATION + 1
|
INC ROW_LOCATION + 1
|
||||||
.doneCalculatingLocation
|
.doneCalculatingLocation
|
||||||
CLC
|
LDA DRAW_WIDTH
|
||||||
LDA SECTION_Y_START
|
STA X_COUNTER
|
||||||
ASL
|
|
||||||
ADC ROW_LOCATION
|
|
||||||
STA ROW_LOCATION
|
|
||||||
LDA SECTION_Y_START
|
|
||||||
ASL
|
|
||||||
ASL
|
|
||||||
ADC ROW_LOCATION
|
|
||||||
STA ROW_LOCATION
|
|
||||||
|
|
||||||
LDX DRAW_X_START
|
LDX DRAW_X_START
|
||||||
; Display row of tiles
|
; Display row of tiles
|
||||||
.next_col
|
.next_col
|
||||||
@ -479,15 +477,15 @@ ROW_OFFSET = 3
|
|||||||
ASL
|
ASL
|
||||||
ASL
|
ASL
|
||||||
STA TILE_SOURCE
|
STA TILE_SOURCE
|
||||||
LDA TILE_BASE
|
LDA TILE_BASE + 1
|
||||||
ADC #$00
|
ADC #$00
|
||||||
STA TILE_SOURCE+1
|
STA TILE_SOURCE+1
|
||||||
LDA TILE_BASE
|
LDA TILE_BASE
|
||||||
ADC TILE_SOURCE
|
ADC TILE_SOURCE
|
||||||
STA TILE_SOURCE
|
STA TILE_SOURCE
|
||||||
BCC .doenCalculatingTileLocation
|
BCC .doneCalculatingTileLocation
|
||||||
INC TILE_SOURCE+1
|
INC TILE_SOURCE+1
|
||||||
.doenCalculatingTileLocation
|
.doneCalculatingTileLocation
|
||||||
; 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
|
||||||
@ -516,13 +514,19 @@ ROW_OFFSET = 3
|
|||||||
}
|
}
|
||||||
DEC X_COUNTER
|
DEC X_COUNTER
|
||||||
BMI .next_row
|
BMI .next_row
|
||||||
|
INX
|
||||||
TXA ; Outside the drawing part we need to put X back (divide by 2)
|
TXA ; Outside the drawing part we need to put X back (divide by 2)
|
||||||
LSR
|
LSR
|
||||||
TAX
|
TAX
|
||||||
BNE .next_col
|
BNE .next_col ;Should always branch
|
||||||
; Increment row
|
; Increment row
|
||||||
.next_row
|
.next_row
|
||||||
|
DEC Y_COUNTER
|
||||||
|
BPL .notDone
|
||||||
|
RTS
|
||||||
|
INC Y_LOC
|
||||||
|
INC SECTION_Y_START
|
||||||
|
JMP .rowLoop
|
||||||
; Draw player
|
; Draw player
|
||||||
|
|
||||||
tblHGRl
|
tblHGRl
|
||||||
|
Loading…
x
Reference in New Issue
Block a user