Smooth terrain working!!

This commit is contained in:
blondie7575 2017-09-17 13:39:10 -07:00
parent 32f7d99c33
commit 3db012d2c0
2 changed files with 70 additions and 22 deletions

Binary file not shown.

View File

@ -16,7 +16,7 @@ VISIBLETERRAINWINDOW = 80 ; In words
; ;
; No stack operations permitted here! ; No stack operations permitted here!
; ;
; Current implementation: X cycles per row ; Current implementation: Unknown cycles per row
; Trashes all registers ; Trashes all registers
; ;
renderTerrain: renderTerrain:
@ -32,9 +32,10 @@ renderTerrain:
sta PARAML0 sta PARAML0
renderTerrainLoop: renderTerrainLoop:
lda #$0000 ; BG/BG ; Note that DP register is normally $0000, so that is used as the BG/BG case
lda #$0011 ; BG/FG
ldx #$1111 ; FG/FG ldx #$1111 ; FG/FG
ldy #$1100 ; BG/FG ldy #$1100 ; FG/BG
jmp (PARAML0) jmp (PARAML0)
renderRowComplete: renderRowComplete:
@ -230,9 +231,9 @@ compileTerrainDone:
; PARAML1 = Row index ; PARAML1 = Row index
; ;
; Note: DA = PHX = FG/FG ; Note: DA = PHX = FG/FG
; 48 = PHA = BG/BG ; 48 = PHA = FG/BG
; 5A = PHY = BG/FG ; 5A = PHY = BG/FG
; 0B = PHD = ; 0B = PHD = BG/BG
compileTerrainRow: compileTerrainRow:
SAVE_AXY SAVE_AXY
@ -242,30 +243,43 @@ compileTerrainRow:
compileTerrainColumnLoop: compileTerrainColumnLoop:
stz compileTerrainOpcode stz compileTerrainOpcode
; Rightmost byte ; Check column 0
lda terrainData,x lda terrainData,x
cmp PARAML1 cmp PARAML1
bcc compileTerrainColumnBG0 bcc compileTerrainColumn0BG
beq compileTerrainColumnBG0 beq compileTerrainColumn0BG
; Column 0 is FG, so check column 1
inx inx
inx inx
lda terrainData,x lda terrainData,x
cmp PARAML1 cmp PARAML1
bcc compileTerrainColumnBG1 bcc compileTerrainColumn1BG
beq compileTerrainColumnBG1 beq compileTerrainColumn1BG
; Columns 0 and 1 are FG/FG, so PHX ; Columns 0 and 1 are FG/FG, so PHX
lda #$00da lda #$00da
compileTerrainColumn2: compileTerrainColumn2:
sta compileTerrainOpcode sta compileTerrainOpcode ; Cache results so far
; Check column 2
inx inx
inx inx
lda terrainData,x lda terrainData,x
cmp PARAML1 cmp PARAML1
bcc compileTerrainColumnBG2 bcc compileTerrainColumn2BG
beq compileTerrainColumnBG2 beq compileTerrainColumn2BG
; Column 2 is FG, so check column 3
inx
inx
lda terrainData,x
cmp PARAML1
bcc compileTerrainColumn3BG
beq compileTerrainColumn3BG
; Columns 2 and 3 are FG/FG, so PHX
lda compileTerrainOpcode lda compileTerrainOpcode
ora #$da00 ora #$da00
@ -273,8 +287,6 @@ compileTerrainColumnStore:
sta (PARAML0),y sta (PARAML0),y
inx inx
inx inx
inx
inx
iny iny
iny iny
cpy #VISIBLETERRAINWIDTH cpy #VISIBLETERRAINWIDTH
@ -283,25 +295,61 @@ compileTerrainColumnStore:
RESTORE_AXY RESTORE_AXY
rts rts
compileTerrainColumnBG0: compileTerrainColumn0BG:
; Columns 0 and 1 are BG/BG, so PHA ; Column 0 is BG, so check column 1
lda #$0048
inx ; PHD check goes here?
inx inx
inx
lda terrainData,x
cmp PARAML1
bcc compileTerrainColumn01BG
beq compileTerrainColumn01BG
; Columns 0 and 1 are BG/FG, so PHA
lda #$0048
bra compileTerrainColumn2 bra compileTerrainColumn2
compileTerrainColumnBG1: compileTerrainColumn01BG:
; Columns 0 and 1 are BG/FG, so PHY ; Columns 0 and 1 are BG/BG, so PHD
lda #$000b
bra compileTerrainColumn2
compileTerrainColumn1BG:
; Columns 0 and 1 are FG/BG, so PHY
lda #$005a lda #$005a
bra compileTerrainColumn2 bra compileTerrainColumn2
compileTerrainColumnBG2: compileTerrainColumn2BG:
; Column 2 is BG, so check column 3
inx
inx
lda terrainData,x
cmp PARAML1
bcc compileTerrainColumn23BG
beq compileTerrainColumn23BG
; Columns 2 and 3 are BG/FG, so PHA
lda compileTerrainOpcode lda compileTerrainOpcode
ora #$4800 ora #$4800
bra compileTerrainColumnStore bra compileTerrainColumnStore
compileTerrainColumn23BG:
; Columns 2 and 3 are BG, so PHD
lda compileTerrainOpcode
ora #$0b00
bra compileTerrainColumnStore
compileTerrainColumn3BG:
; Columns 2 and 3 are FG/BG, so PHY
lda compileTerrainOpcode
ora #$5a00
bra compileTerrainColumnStore
compileTerrainOpcode: compileTerrainOpcode:
.word 0 .word 0