Tested out mark queueing code.

This commit is contained in:
Martin Haye 2018-04-01 07:55:13 -07:00
parent fa6454fdfb
commit 94f5ab3a7e
3 changed files with 183 additions and 27 deletions

View File

@ -0,0 +1,11 @@
;****************************************************************************************
; Copyright (C) 2018 The 8-Bit Bunch. Licensed under the Apache License, Version 1.1
; (the "License"); you may not use this file except in compliance with the License.
; You may obtain a copy of the License at <http://www.apache.org/licenses/LICENSE-1.1>.
; Unless required by applicable law or agreed to in writing, software distributed under
; the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
; ANY KIND, either express or implied. See the License for the specific language
; governing permissions and limitations under the License.
;****************************************************************************************
saveMarks = $DB00 ; in aux LC, bank 1

View File

@ -0,0 +1,143 @@
;****************************************************************************************
; Copyright (C) 2018 The 8-Bit Bunch. Licensed under the Apache License, Version 1.1
; (the "License"); you may not use this file except in compliance with the License.
; You may obtain a copy of the License at <http://www.apache.org/licenses/LICENSE-1.1>.
; Unless required by applicable law or agreed to in writing, software distributed under
; the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
; ANY KIND, either express or implied. See the License for the specific language
; governing permissions and limitations under the License.
;****************************************************************************************
* = $DB00
; Use hi-bit ASCII for Apple II
!convtab "../include/hiBitAscii.ct"
tmp = $4 ; len 2
pTmp = $6 ; len 2
jmp saveMarks
;Input: A-reg = row stride
; X-reg = width
; Y-reg = height
; TOS-2 = pointer to map data, lo byte...
; TOS-1 = ...and hi byte
; TOS = map number (with hi bit set if 3D)
saveMarks: !zone
sta .adStrd+1
stx .cmpWd+1
sty lineCt
pla
clc
adc #1
sta .ret+1
pla
adc #0
sta .ret+2
txa
adc #7 ; carry already clear from above
lsr
lsr
lsr
sta .addBSz+1
lda #0
- clc
.addBSz adc #11 ; self-modified above
dey ; multiply height * size-of-encoded-row
bne .addBSz ; Y=0 at end of loop (used below)
tax ; X is now the total # of encoded bytes
inx
inx ; plus header size
lda #<bufStart
sta pTmp
lda #>bufStart
sta pTmp+1
.scan pla
pha
cmp (pTmp),y
beq .found
lda (pTmp),y
beq .notfnd
iny
lda (pTmp),y
dey
clc
adc pTmp
sta pTmp
bcc .scan
inc pTmp+1
bne .scan ; always taken
.notfnd pla
sta (pTmp),y
iny
txa
sta (pTmp),y
tay ; save offset for end-of-buffer marking
clc
adc pTmp
bcc +
lda pTmp+1
cmp #>(bufEnd-256)
bcs .full
+ lda #0 ; end-of-buffer mark, and also mask
sta (pTmp),y ; mark new end of buffer
beq .go
.found pla
lda #$FF
.go sta .mask1+1
sta .mask2+1
ldy #2
pla ; source data addr hi...
sta .get+2
pla ; ...and lo
sta .get+1
lda #$80
sta tmp
.nxtrow ldx #0
.get lda $1111,x ; self-modified above
asl
asl ; shift $40 bit (automap) into carry
ror tmp ; save the bit
bcc +
lda (pTmp),y
.mask1 and #11 ; self-modified above
ora tmp
sta (pTmp),y
iny
lda #$80 ; restore sentinel
sta tmp
+ inx
.cmpWd cpx #11 ; check width (self-modified above)
bne .get ; loop until row width is complete
lda tmp
bmi + ; skip final store if no bits
- lsr tmp ; low-align last set of bits in row
bcc -
lda (pTmp),y
.mask2 and #11 ; self-modified above
ora tmp
sta (pTmp),y
iny
+ lda .get+1
clc
.adStrd adc #11 ; add stride (self-modified above)
sta .get+1
bcc +
inc .get+2
+ dec lineCt
bne .nxtrow
.ret jmp $1111 ; self-modified above
.full brk ; TODO
lineCt !byte 0
bufStart = *
!byte 0
bufEnd = $E000

View File

@ -54,6 +54,8 @@ DEBUG_COLUMN = -1
!source "../include/fontEngine.i"
; PLASMA
!source "../include/plasma.i"
; Automap marks
!source "../include/marks.i"
; Local constants
MAX_SPRITES = 64 ; max # sprites visible at once
@ -1748,6 +1750,29 @@ pl_texControl: !zone {
inx
cpx nTextures
bne -
; This is also our signal to save the automap bits
ldx mapWidth
ldy mapHeight
lda mapBase
sec ; skip sentinel at start of row
adc mapWidth ; plus skip row of sentinels
sta setAuxZP
pha
lda mapBase+1
adc #0
pha
lda mapNum
ora #$80 ; map number: hi bit to mark 3D maps
pha
dey ; height: adjust for two sentinel rows
dey
txa ; stride is unadjusted width
dex ; width: adjust for two sentinel columns
dex
bit setLcRW+lcBank1
jsr saveMarks
bit setLcRW+lcBank2
sta clrAuxZP
rts
}
@ -2242,6 +2267,7 @@ pl_setAvatar: !zone {
;-------------------------------------------------------------------------------
; The real action
; Parameters: mapPartition, mapNum, pMapData, x, y, dir
pl_initMap: !zone
; Figure out PLASMA stack for calling script init
txa
@ -2251,6 +2277,9 @@ pl_initMap: !zone
; Record partition number of the map and textures
lda evalStkL+5,x
sta mapPartition
; Record the map number
lda evalStkL+4,x
sta mapNum
; Record the address of the map
lda evalStkL+3,x
sta mapHeader
@ -2283,33 +2312,6 @@ pl_initMap: !zone
jsr setExpansionCaller
jmp renderFrame
; Save automap bits
saveAutomap: !zone
lda mapBase
sec ; skip sentinel at start of row
adc mapWidth ; plus skip row of sentinels
pha
lda mapBase+1
adc #0
pha
lda mapNum
ora #$80 ; map number: hi bit to mark 3D maps
pha
ldx mapWidth
ldy mapHeight
dey ; height: adjust for two sentinel rows
dey
txa
dex ; width: adjust for two sentinel columns
dex
sta setAuxZP
;jsr saveMarks
sta clrAuxZP
rts
; Following are log/pow lookup tables. For speed, align them on a page boundary.
!align 255,0