mirror of
https://github.com/cc65/cc65.git
synced 2024-10-06 01:55:47 +00:00
Remove screen flicker while mapping ROM out and in.
Some cleanups.
This commit is contained in:
parent
1e8e998991
commit
4a0bdf871b
@ -43,7 +43,7 @@ cont: ldx #0 ; channel 0
|
|||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
; ------------------------------------------------------------------------
|
; ------------------------------------------------------------------------
|
||||||
; Chunk header
|
; EXE load chunk header
|
||||||
|
|
||||||
.segment "SRPREPHDR"
|
.segment "SRPREPHDR"
|
||||||
|
|
||||||
@ -112,11 +112,11 @@ sramprep:
|
|||||||
sta APPMHI+1
|
sta APPMHI+1
|
||||||
|
|
||||||
|
|
||||||
; ... issue a GRAPHICS 0 call (copied'n'pasted from TGI drivers)
|
; issue a GRAPHICS 0 call (copied'n'pasted from TGI drivers) to move screen memory down
|
||||||
|
|
||||||
|
|
||||||
jsr findfreeiocb
|
jsr findfreeiocb
|
||||||
.ifdef DEBUG ; only check in debug version, this shouldn't happen normally(tm)
|
.ifdef DEBUG ; only check in debug version, this shouldn't really happen(tm)
|
||||||
beq iocbok
|
beq iocbok
|
||||||
print_string "Internal error, no free IOCB!"
|
print_string "Internal error, no free IOCB!"
|
||||||
jsr delay
|
jsr delay
|
||||||
@ -164,7 +164,6 @@ scrok: ; now close it again -- we don't need it anymore
|
|||||||
|
|
||||||
.ifdef DEBUG
|
.ifdef DEBUG
|
||||||
print_string "copy chargen to low memory"
|
print_string "copy chargen to low memory"
|
||||||
print_string "set up high memory"
|
|
||||||
.endif
|
.endif
|
||||||
|
|
||||||
lda #>(__SRPREP_LOAD__ + __SRPREP_SIZE__ + __SHADOW_RAM_SIZE__)
|
lda #>(__SRPREP_LOAD__ + __SRPREP_SIZE__ + __SHADOW_RAM_SIZE__)
|
||||||
@ -179,6 +178,20 @@ scrok: ; now close it again -- we don't need it anymore
|
|||||||
sta ptr3
|
sta ptr3
|
||||||
|
|
||||||
cg_addr_ok:
|
cg_addr_ok:
|
||||||
|
|
||||||
|
lda ptr3+1
|
||||||
|
and #3
|
||||||
|
beq cg_addr_ok2
|
||||||
|
|
||||||
|
; align to next 1K boundary
|
||||||
|
lda ptr3+1
|
||||||
|
and #$fc
|
||||||
|
clc
|
||||||
|
adc #4
|
||||||
|
sta ptr3+1
|
||||||
|
|
||||||
|
cg_addr_ok2:
|
||||||
|
|
||||||
lda #<DCSORG
|
lda #<DCSORG
|
||||||
sta ptr1
|
sta ptr1
|
||||||
lda #>DCSORG
|
lda #>DCSORG
|
||||||
@ -186,22 +199,33 @@ cg_addr_ok:
|
|||||||
lda ptr3
|
lda ptr3
|
||||||
sta ptr2
|
sta ptr2
|
||||||
lda ptr3+1
|
lda ptr3+1
|
||||||
|
pha ; needed later to set CHBAS/CHBASE
|
||||||
sta ptr2+1
|
sta ptr2+1
|
||||||
lda #>__CHARGEN_SIZE__
|
lda #>__CHARGEN_SIZE__
|
||||||
sta tmp2
|
sta tmp2
|
||||||
lda #<__CHARGEN_SIZE__
|
lda #<__CHARGEN_SIZE__
|
||||||
sta tmp2+1
|
sta tmp1
|
||||||
jsr memcopy
|
jsr memcopy
|
||||||
|
|
||||||
; TODO: switch to this temp. chargen
|
.ifdef DEBUG
|
||||||
|
print_string "now setting up high memory"
|
||||||
|
.endif
|
||||||
|
|
||||||
; disable ROMs
|
; disable ROM
|
||||||
sei
|
sei
|
||||||
ldx #0
|
ldx #0
|
||||||
stx NMIEN ; disable NMI
|
stx NMIEN ; disable NMI
|
||||||
lda PORTB
|
lda PORTB
|
||||||
and #$fe
|
and #$fe
|
||||||
sta PORTB ; now ROM is mapped out
|
tax
|
||||||
|
pla ; get temp. chargen address
|
||||||
|
sta WSYNC ; wait for horiz. retrace
|
||||||
|
stx PORTB ; now ROM is mapped out
|
||||||
|
|
||||||
|
; switch to temporary chargen
|
||||||
|
|
||||||
|
sta CHBASE
|
||||||
|
sta CHBAS
|
||||||
|
|
||||||
; copy shadow RAM contents to their destination
|
; copy shadow RAM contents to their destination
|
||||||
|
|
||||||
@ -248,21 +272,26 @@ no_copy:
|
|||||||
|
|
||||||
lda PORTB
|
lda PORTB
|
||||||
ora #1
|
ora #1
|
||||||
|
ldx #>DCSORG
|
||||||
|
sta WSYNC ; wait for horiz. retrace
|
||||||
sta PORTB
|
sta PORTB
|
||||||
|
stx CHBASE
|
||||||
|
stx CHBAS
|
||||||
lda #$40
|
lda #$40
|
||||||
sta NMIEN ; enable VB again
|
sta NMIEN ; enable VB again
|
||||||
cli ; and enable IRQs
|
cli ; and enable IRQs
|
||||||
|
|
||||||
.ifdef DEBUG
|
.ifdef DEBUG
|
||||||
print_string "Stage #2 OK"
|
print_string "Stage #2 OK"
|
||||||
|
print_string "loading main chunk"
|
||||||
jsr delay
|
jsr delay
|
||||||
.endif
|
.endif
|
||||||
rts
|
rts
|
||||||
|
|
||||||
.include "findfreeiocb.inc"
|
.include "findfreeiocb.inc"
|
||||||
|
|
||||||
; my 6502 fu is rusty, so I took a routine from the internet (http://www.obelisk.demon.co.uk/6502/algorithms.html)
|
; routine taken from http://www.obelisk.demon.co.uk/6502/algorithms.html
|
||||||
|
;
|
||||||
; copy memory
|
; copy memory
|
||||||
; ptr1 - source
|
; ptr1 - source
|
||||||
; ptr2 - destination
|
; ptr2 - destination
|
||||||
@ -307,6 +336,8 @@ restore:lda RAMTOP_save
|
|||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
.ifdef DEBUG
|
||||||
|
|
||||||
.byte "HERE ****************** HERE ***************>>>>>>"
|
.byte "HERE ****************** HERE ***************>>>>>>"
|
||||||
|
|
||||||
sramsize:
|
sramsize:
|
||||||
@ -332,10 +363,14 @@ loop: dey
|
|||||||
|
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
|
.endif ; .ifdef DEBUG
|
||||||
|
|
||||||
screen_device: .byte "S:",0
|
screen_device: .byte "S:",0
|
||||||
screen_device_length = * - screen_device
|
screen_device_length = * - screen_device
|
||||||
|
|
||||||
|
.ifdef DEBUG
|
||||||
.byte " ** srprep ** end-->"
|
.byte " ** srprep ** end-->"
|
||||||
|
.endif
|
||||||
|
|
||||||
; ------------------------------------------------------------------------
|
; ------------------------------------------------------------------------
|
||||||
; Provide an empty SHADOW_RAM segment in order that the linker is happy
|
; Provide an empty SHADOW_RAM segment in order that the linker is happy
|
||||||
@ -345,7 +380,7 @@ screen_device_length = * - screen_device
|
|||||||
|
|
||||||
|
|
||||||
; ------------------------------------------------------------------------
|
; ------------------------------------------------------------------------
|
||||||
; Chunk "trailer" - sets INITAD
|
; EXE load chunk "trailer" - sets INITAD
|
||||||
|
|
||||||
.segment "SRPREPTRL"
|
.segment "SRPREPTRL"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user