Jump to content
Sign in to follow this  
jacobus

Switching off ROM in an XL (using upper 16K RAM)

Recommended Posts

Thanks for the link - I checked it out and with my limited assembly skills the code seems to be doing everything I do with the exception of updating the NMI vectors - which since I'm not changing anything in the ROM, should not need to be updated.

So, consider to copy ROM in some parts.

To do this you will need additional routine for turning ROM on.

 

The code you list here - it looks like it compares the value of $14 (APPMHI) with itself and then calls the routine stored at $FFFE - is that correct? If I have VBI's already disabled, is this required?

No, 'system_off' should be part of your code. To FFFE you should put 'NMI' label (from code provided at atariki).

During turning ROM off you must avoid any interrupts (NMI and IRQ as well). That's why I'm waiting for new value in $14. Memory at $14 is a part of system clock, changed each VBL.

lda $14 - load current value of counter to Accumulator

cmp $14 - compare Accumulator with current value of memory. x

beq *-2 - if value is the same, compare again. That value is changed only by VBL interrupt routine, so this condition will be false just after VBL interrupt. Now you have >30k cycles to change NMI vector.

 

So, in summary, you can resolve your issue this way:

1. Copy part of ROM to RAM.

2. Turn ROM off.

3. Copy data from 1 to final destination inside RAM under ROM.

4. Turn ROM on.

5. Jump to 1 until all done.

Share this post


Link to post
Share on other sites

Success!!!

 

I rewrote the code to perform the ROM->RAM copy operation using smaller (2K) blocks as per Bob_er's excellent instructions.

 

The code now allows the entire ROM code to be successfully copied to RAM (skipping $D000-$D7FF), flipping back and forth every 2K. The problem turned out to be my original code was trying to copy too much data at a time.

 

A big "Thank You" to everyone involved! I have included the working QUICK code for reference.

Quick-Sourcetext
D1:PORTB.QIK   
----------------
Length: $0DF6

Free  : $6975
----------------

************************************
************************************

BYTE
 [
  RTCLOK=20
  SDMA=559
  CONSOL=53279
  PORTB=54017
  NMIEN=54286

  A,C
  BLOCK
 ]

 WORD
 [
  ROM
 ]

************************************
*** MAIN LOOP ***
************************************

MAIN

 BLOCK=0
 ROM=49152              ;start of ROM

 REPEAT
  IF BLOCK<>2 ;copy unless D000-D7FF
   PORTB=255             ;turn on ROM
   PRINT("Copying block # ",BLOCK)

   .JMOVE(ROM,1536,2048) ;copy 2K
  
   *sync with VBL
   C=RTCLOK
   REPEAT
   UNTIL RTCLOK<>C

   NMIEN=0  ;turn off interrupts
   *issue PHP,SEI
   INLINE
   [
    8,120
   ]

   PORTB=254            ;turn off ROM

   .JMOVE(1536,ROM,2048) ;restore block

   *issue CLI,PLP
   INLINE
   [
    88,104
   ]
   NMIEN=192            ;restore NMIEN
  ENDIF
 
  ADD(ROM,2048,ROM)    ;next 2K block
  BLOCK+
 UNTIL BLOCK=8

 PRINT("ROM code restore complete")

 *test
 POKE(52256,0)  ;write 0 to known loc
 PEEK(52256,A)  ;get result
 IF A=0
  PRINT("Success!")
 ELSE
  PRINT("Failure")
 ENDIF

ENDMAIN

************************************
************************************
************************************

PROC JMOVE
IN
 WORD
 [
  SRC,DEST,LN
 ]
 LOCAL
  WORD
  [
   MEM
  ]
  BYTE
  [
   Z
  ]
BEGIN
 
 MEM=0
 
 REPEAT
  PEEK(SRC,Z)      ;read source byte
  POKE(DEST,Z)     ;write dest byte
  ADD(SRC,1,SRC)   ;inc source counter
  ADD(DEST,1,DEST) ;inc dest counter
  ADD(MEM,1,MEM)   ;inc byte counter
 UNTIL MEM=LN

ENDPROC



 

 

 

  • Like 2

Share this post


Link to post
Share on other sites

Could jacobus please remove the Quick user guide from his post. The Quick manual is still subject to copyright and can't be distributed in this way. Anyone wanting Quick can still get it for minimal cost from my website: http://www.dgs.clara.net/

 

Thanks.

Share this post


Link to post
Share on other sites

Could jacobus please remove the Quick user guide from his post. The Quick manual is still subject to copyright and can't be distributed in this way. Anyone wanting Quick can still get it for minimal cost from my website: http://www.dgs.clara.net/

 

Thanks.

Done!

 

Sorry about that!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...