X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libsrc%2Fatari%2Fshadow_ram_prepare.s;h=78e7ba4f0de5c103cc9413c407b89cb78aef6cc8;hb=aac88eac53e3a0dc178a7711741e12f021850de1;hp=6458ffdb121c17cb0faf439d2f0d4a9284fcdde8;hpb=250e26c56e071b59b0613ed07f4387650c834923;p=cc65 diff --git a/libsrc/atari/shadow_ram_prepare.s b/libsrc/atari/shadow_ram_prepare.s index 6458ffdb1..78e7ba4f0 100644 --- a/libsrc/atari/shadow_ram_prepare.s +++ b/libsrc/atari/shadow_ram_prepare.s @@ -19,7 +19,6 @@ DEBUG = 1 .import __SHADOW_RAM_RUN__ .import __CHARGEN_START__, __CHARGEN_SIZE__ .import __SAVEAREA_LOAD__ - .import zpsave .include "zeropage.inc" .include "atari.inc" @@ -44,7 +43,7 @@ cont: ldx #0 ; channel 0 .endmacro ; ------------------------------------------------------------------------ -; Chunk header +; EXE load chunk header .segment "SRPREPHDR" @@ -75,18 +74,6 @@ sramprep: sta APPMHI_save+1 lda PORTB sta PORTB_save - lda CIOV ; zero-page wrapper - sta ZP_CIOV_save - lda CIOV+1 - sta ZP_CIOV_save+1 - lda CIOV+2 - sta ZP_CIOV_save+2 - lda SIOV ; zero-page wrapper - sta ZP_SIOV_save - lda SIOV+1 - sta ZP_SIOV_save+1 - lda SIOV+2 - sta ZP_SIOV_save+2 ; disable BASIC @@ -98,19 +85,26 @@ sramprep: ldx lowadr stx MEMTOP - stx APPMHI lda lowadr+1 sta MEMTOP+1 - sta APPMHI+1 lda lodadr+1 sta RAMTOP + ; set APPMHI to MEMLO (+ 1 for sanity) + lda MEMLO + clc + adc #1 + sta APPMHI + lda MEMLO+1 + adc #0 + 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 -.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 print_string "Internal error, no free IOCB!" jsr delay @@ -154,19 +148,10 @@ scrok: ; now close it again -- we don't need it anymore jsr CIOV_org -; Save the zero page locations we need - - ldx #zpspace-1 -L1: lda sp,x - sta zpsave,x - dex - bpl L1 - ; copy chargen to low memory .ifdef DEBUG print_string "copy chargen to low memory" - print_string "set up high memory" .endif lda #>(__SRPREP_LOAD__ + __SRPREP_SIZE__ + __SHADOW_RAM_SIZE__) @@ -181,6 +166,20 @@ L1: lda sp,x sta ptr3 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 @@ -188,29 +187,40 @@ cg_addr_ok: lda ptr3 sta ptr2 lda ptr3+1 + pha ; needed later to set CHBAS/CHBASE sta ptr2+1 lda #>__CHARGEN_SIZE__ sta tmp2 lda #<__CHARGEN_SIZE__ - sta tmp2+1 + sta tmp1 jsr memcopy -; TODO: switch to this temp. chargen +.ifdef DEBUG + print_string "now setting up high memory" +.endif -; disable ROMs +; disable ROM sei ldx #0 - stx NMIEN ; disable NMI + stx NMIEN ; disable NMI lda PORTB 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 lda #<__SHADOW_RAM_SIZE__ bne do_copy lda #>__SHADOW_RAM_SIZE__ - beq no_copy ; we have no shadow RAM contents + beq no_copy ; we have no shadow RAM contents ; ptr1 - src; ptr2 - dest; tmp1, tmp2 - len do_copy:lda #<__SHADOW_RAM_LOAD__ @@ -250,21 +260,26 @@ no_copy: lda PORTB ora #1 + ldx #>DCSORG + sta WSYNC ; wait for horiz. retrace sta PORTB + stx CHBASE + stx CHBAS lda #$40 sta NMIEN ; enable VB again cli ; and enable IRQs .ifdef DEBUG print_string "Stage #2 OK" + print_string "loading main chunk" jsr delay .endif rts .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 ; ptr1 - source ; ptr2 - destination @@ -309,6 +324,8 @@ restore:lda RAMTOP_save rts +.ifdef DEBUG + .byte "HERE ****************** HERE ***************>>>>>>" sramsize: @@ -334,10 +351,14 @@ loop: dey .endproc +.endif ; .ifdef DEBUG + screen_device: .byte "S:",0 screen_device_length = * - screen_device +.ifdef DEBUG .byte " ** srprep ** end-->" +.endif ; ------------------------------------------------------------------------ ; Provide an empty SHADOW_RAM segment in order that the linker is happy @@ -347,12 +368,12 @@ screen_device_length = * - screen_device ; ------------------------------------------------------------------------ -; Chunk "trailer" - sets INITAD +; EXE load chunk "trailer" - sets INITAD .segment "SRPREPTRL" .word INITAD .word INITAD+1 - .word __SRPREP_LOAD__ + .word sramprep .endif ; .if .defined(__ATARIXL__)