This commit is contained in:
Christian Groessler
2013-09-27 22:01:54 +02:00
parent c88e0818b4
commit 39a98f250b
10 changed files with 809 additions and 809 deletions

View File

@@ -9,12 +9,12 @@
; by the screen memory afterwards.
;
; inputs:
; __STARTADDRESS__ - load address of the program
; __STARTADDRESS__ - load address of the program
; outputs:
; lodadr - (high byte only) value to
; write into RAMTOP
; lowadr - lowest address occupied by
; screen data
; lodadr - (high byte only) value to
; write into RAMTOP
; lowadr - lowest address occupied by
; screen data
;
@@ -35,85 +35,85 @@
; available memory, boundary crossing cannot happen.
SCRBUFSZ = (40 * 24) ; size of mode 0 screen buffer
DLSZ = 32 ; size of mode 0 display list
SCRBUFSZ = (40 * 24) ; size of mode 0 screen buffer
DLSZ = 32 ; size of mode 0 display list
scrmemtst:
; subtract screen memory size from our load address
lda lodadr
sec
sbc #<SCRBUFSZ
sta tstadr
lda lodadr+1
sbc #>SCRBUFSZ
sta tstadr+1
lda lodadr
sec
sbc #<SCRBUFSZ
sta tstadr
lda lodadr+1
sbc #>SCRBUFSZ
sta tstadr+1
; check if a 4K boundary is crossed
lda lodadr+1
and #$f0
sta tmp
lda tstadr+1
and #$f0
cmp tmp
beq scrmemok
lda lodadr+1
and #$f0
sta tmp
lda tstadr+1
and #$f0
cmp tmp
beq scrmemok
; if lodadr is at an exact 4K boundary, it's still ok
lda lodadr+1
and #$0f
beq scrmemok
lda lodadr+1
and #$0f
beq scrmemok
; 4K boundary will be crossed, use this 4K boundary address as lodadr
al4k: lda lodadr+1
and #$f0
sta lodadr+1
bne scrmemtst
al4k: lda lodadr+1
and #$f0
sta lodadr+1
bne scrmemtst
; not reached
.ifdef DEBUG
.byte "XLMEMCHK:>"
.endif
lodadr: .word __STARTADDRESS__ & $FF00 ; our program's load address, rounded down to page boundary
tstadr: .res 2
lowadr: .res 2
tmp: .res 1
lodadr: .word __STARTADDRESS__ & $FF00 ; our program's load address, rounded down to page boundary
tstadr: .res 2
lowadr: .res 2
tmp: .res 1
; subtract display list size from calculated screen address
scrmemok:
lda tstadr
sec
sbc #<DLSZ
sta lowadr
lda tstadr+1
sbc #>DLSZ
sta lowadr+1
lda tstadr
sec
sbc #<DLSZ
sta lowadr
lda tstadr+1
sbc #>DLSZ
sta lowadr+1
.if 0 ; this cannot happen
.if 0 ; this cannot happen
; check if a 1K boundary is crossed
lda tstadr+1
and #$fc
sta tmp
lda lowadr+1
and #$fc
cmp tmp
bne al4k ; 1K boundary will be crossed, decrease lodadr
lda tstadr+1
and #$fc
sta tmp
lda lowadr+1
and #$fc
cmp tmp
bne al4k ; 1K boundary will be crossed, decrease lodadr
.endif
; address of display list is ok
; decrease lowadr by two
lda lowadr
sec
sbc #2
sta lowadr
bcs dec_cont
dec lowadr+1
lda lowadr
sec
sbc #2
sta lowadr
bcs dec_cont
dec lowadr+1
dec_cont: