mirror of
https://github.com/cc65/cc65.git
synced 2025-01-11 11:30:13 +00:00
cleanups and add more comments
This commit is contained in:
parent
6ed1b07e59
commit
f16516047a
@ -107,15 +107,15 @@ sramprep:
|
|||||||
ora #2
|
ora #2
|
||||||
sta PORTB
|
sta PORTB
|
||||||
|
|
||||||
.include "xlmemchk.inc"
|
.include "xlmemchk.inc" ; calculate lowest address used and new value for RAMTOP
|
||||||
|
|
||||||
ldx tstadr2
|
ldx lowadr
|
||||||
stx MEMTOP
|
stx MEMTOP
|
||||||
stx APPMHI
|
stx APPMHI
|
||||||
lda tstadr2+1
|
lda lowadr+1
|
||||||
sta MEMTOP+1
|
sta MEMTOP+1
|
||||||
sta APPMHI+1
|
sta APPMHI+1
|
||||||
lda lowadr+1
|
lda lodadr+1
|
||||||
sta RAMTOP
|
sta RAMTOP
|
||||||
|
|
||||||
|
|
||||||
|
@ -92,13 +92,13 @@ fail: jsr delay
|
|||||||
|
|
||||||
|
|
||||||
sys_ok:
|
sys_ok:
|
||||||
.include "xlmemchk.inc"
|
.include "xlmemchk.inc" ; calculate lowest address we will use when we move the screen buffer down
|
||||||
|
|
||||||
sec
|
sec
|
||||||
lda MEMLO
|
lda MEMLO
|
||||||
sbc tstadr2
|
sbc lowadr
|
||||||
lda MEMLO+1
|
lda MEMLO+1
|
||||||
sbc tstadr2+1
|
sbc lowadr+1
|
||||||
bcc memlo_ok
|
bcc memlo_ok
|
||||||
|
|
||||||
; load address was too low
|
; load address was too low
|
||||||
|
@ -1,12 +1,21 @@
|
|||||||
; ... change system memory variables bla
|
;
|
||||||
|
; Christian Groessler, Jun-2013
|
||||||
|
;
|
||||||
jmp cont
|
; This routine is used in preparation to move the screen memory
|
||||||
|
; in front of the program.
|
||||||
lowadr: .word __SAVEAREA_LOAD__ & $FF00 ; our load address, rounded down to page boundary
|
;
|
||||||
tstadr: .res 2
|
; It calculates the value to put into RAMTOP for a subsequent
|
||||||
tstadr2:.res 2
|
; "GRAPHICS 0" call, and the lowest address which will be used
|
||||||
tmp: .res 1
|
; by the screen memory afterwards.
|
||||||
|
;
|
||||||
|
; inputs:
|
||||||
|
; __SAVEAREA_LOAD__ - load address of the program
|
||||||
|
; outputs:
|
||||||
|
; lodadr - (high byte only) value to
|
||||||
|
; write into RAMTOP
|
||||||
|
; lowadr - lowest address occupied by
|
||||||
|
; screen data
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
; When setting a display mode, the ROM takes the RAMTOP value
|
; When setting a display mode, the ROM takes the RAMTOP value
|
||||||
@ -16,27 +25,35 @@ tmp: .res 1
|
|||||||
; This will become the new display list address.
|
; This will become the new display list address.
|
||||||
; Screen memory cannot cross 4K boundaries and a display list
|
; Screen memory cannot cross 4K boundaries and a display list
|
||||||
; cannot cross a 1K boundary.
|
; cannot cross a 1K boundary.
|
||||||
|
;
|
||||||
; Work out a sane value for RAMTOP to prevent boundary crossing.
|
; Work out a sane value for RAMTOP to prevent boundary crossing.
|
||||||
; RAMTOP is only one byte, it counts in memory pages.
|
; RAMTOP is only one byte, it counts in memory pages.
|
||||||
|
;
|
||||||
|
; The ROM doesn't do this boundary checking, since it doesn't
|
||||||
|
; expect RAMTOP to have (rather) arbitrary values. For a
|
||||||
|
; "GRAPHICS 0" call and RAMTOP representing the possible physically
|
||||||
|
; available memory, boundary crossing cannot happen.
|
||||||
|
|
||||||
cont:
|
|
||||||
|
|
||||||
_SCRBUFSZ = (40 * 24) ; size of mode 0 screen buffer
|
SCRBUFSZ = (40 * 24) ; size of mode 0 screen buffer
|
||||||
_DLSZ = 32 ; size of mode 0 display list
|
DLSZ = 32 ; size of mode 0 display list
|
||||||
|
|
||||||
|
|
||||||
|
scrmemtst:
|
||||||
|
|
||||||
; subtract screen memory size from our load address
|
; subtract screen memory size from our load address
|
||||||
|
|
||||||
lda lowadr
|
lda lodadr
|
||||||
sec
|
sec
|
||||||
sbc #<_SCRBUFSZ
|
sbc #<SCRBUFSZ
|
||||||
sta tstadr
|
sta tstadr
|
||||||
lda lowadr+1
|
lda lodadr+1
|
||||||
sbc #>_SCRBUFSZ
|
sbc #>SCRBUFSZ
|
||||||
sta tstadr+1
|
sta tstadr+1
|
||||||
|
|
||||||
; check if a 4K boundary is crossed
|
; check if a 4K boundary is crossed
|
||||||
|
|
||||||
lda lowadr+1
|
lda lodadr+1
|
||||||
and #$f0
|
and #$f0
|
||||||
sta tmp
|
sta tmp
|
||||||
lda tstadr+1
|
lda tstadr+1
|
||||||
@ -44,48 +61,51 @@ _DLSZ = 32 ; size of mode 0 display list
|
|||||||
cmp tmp
|
cmp tmp
|
||||||
beq scrmemok
|
beq scrmemok
|
||||||
|
|
||||||
; 4K boundary will be crossed, take 4K boundary address as lowadr
|
; 4K boundary will be crossed, use this 4K boundary address as lodadr
|
||||||
|
|
||||||
al4k: lda lowadr+1
|
al4k: lda lodadr+1
|
||||||
and #$f0
|
and #$f0
|
||||||
tax
|
tax
|
||||||
dex
|
dex
|
||||||
stx lowadr+1
|
stx lodadr+1
|
||||||
bne cont
|
bne scrmemtst
|
||||||
|
; not reached
|
||||||
|
|
||||||
|
|
||||||
|
lodadr: .word __SAVEAREA_LOAD__ & $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
|
; subtract display list size from calculated screen address
|
||||||
|
|
||||||
scrmemok:
|
scrmemok:
|
||||||
lda tstadr
|
lda tstadr
|
||||||
sec
|
sec
|
||||||
sbc #<_DLSZ
|
sbc #<DLSZ
|
||||||
sta tstadr2
|
sta lowadr
|
||||||
lda tstadr+1
|
lda tstadr+1
|
||||||
sbc #>_DLSZ
|
sbc #>DLSZ
|
||||||
sta tstadr2+1
|
sta lowadr+1
|
||||||
|
|
||||||
; check if a 1K boundary is crossed
|
; check if a 1K boundary is crossed
|
||||||
|
|
||||||
lda tstadr+1
|
lda tstadr+1
|
||||||
and #$fc
|
and #$fc
|
||||||
sta tmp
|
sta tmp
|
||||||
lda tstadr2+1
|
lda lowadr+1
|
||||||
and #$fc
|
and #$fc
|
||||||
cmp tmp
|
cmp tmp
|
||||||
bne al4k ; 1K boundary will be crossed, decrease lowadr
|
bne al4k ; 1K boundary will be crossed, decrease lodadr
|
||||||
|
|
||||||
; address of display list is ok
|
; address of display list is ok
|
||||||
|
; decrease lowadr by two
|
||||||
|
|
||||||
dlok:
|
lda lowadr
|
||||||
|
|
||||||
; decrease tstadr2 by two
|
|
||||||
|
|
||||||
lda tstadr2
|
|
||||||
sec
|
sec
|
||||||
sbc #2
|
sbc #2
|
||||||
sta tstadr2
|
sta lowadr
|
||||||
bcs dec_cont
|
bcs dec_cont
|
||||||
lda tstadr2+1
|
dec lowadr+1
|
||||||
sbc #0
|
|
||||||
sta tstadr2+1
|
|
||||||
dec_cont:
|
dec_cont:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user