Jump to content

Photo

IntyBASIC Support for ROM Region Swapping?

jlp intybasic save game storage 42k lto flash

5 replies to this topic

#1 First Spear OFFLINE  

First Spear

    Stargunner

  • 1,284 posts
  • Location:Somewhere in Uptown

Posted Thu Jun 23, 2016 7:08 AM

 
 
Hi. Can you clue me in on how to swap in/out 16k of ROM from the $C100 space using IntyBASIC compiling to the JLP architecture?
 
I am using the $C100 section of ROM to hold an audio waveform sample, the rest of the game cartridge ROM I am using for game code and graphics and sounds (42k, its large). Once the waveform plays, I want to play a different one at a later point in the game, so a swap of some kind through IntyBASIC's JLP support I think would be the best move because playing would be transparent to the rest of the game code. Speed is not critical for the swap, just something that works. 
 
All ideas appreciated, if I'm way off in my suppositions I'll try other avenues. 
 
Thanks.
 
 
 
 
 
 
(Based on the question I asked in http://atariage.com/...ram/?p=3535223)
 

Edited by First Spear, Thu Jun 23, 2016 7:09 AM.


#2 Arnauld OFFLINE  

Arnauld

    Space Invader

  • 42 posts
  • Location:Paris / France

Posted Thu Jun 23, 2016 7:34 AM

What you're looking for, I think, is bank switching also known as page flipping. You're not really going to 'swap' the content of a ROM region with the content of another ROM region. Rather, you will make a given page appear at a given memory range, and this is a very fast operation.

 

JLP supports ECS-style page flipping, which allows you to address up to ~120 K-words.

 

However, I don't know if/how this is implemented in IntyBasic, so I'll let the experts explain that.



#3 GroovyBee OFFLINE  

GroovyBee

    Games Developer

  • 9,818 posts
  • Busy bee!
  • Location:England

Posted Thu Jun 23, 2016 7:43 AM

There are no native commands in IntyBASIC to handle bank switching, but you might find these threads a good read :-

http://atariage.com/...ive-and-memory/
http://atariage.com/...s-of-rom-space/

#4 Kiwi OFFLINE  

Kiwi

    Stargunner

  • 1,580 posts

Posted Thu Jun 23, 2016 8:08 AM

IntyBASIC should be able to handle bankswitching like I figured out how to do bankswitching in C for Colecovision(wasn't easy).

 

Only a theory how this would work.

 

poke $6ff9,1  would signal to the logic chip to switch bank.  Or it reading a=peek $6ff9....

 

asm org $10000 will compile set your data to the upper part of the ROM chip to be swap in with C100 or d000 if you want to keep the data even.

 

But I would have to gather information where to place data and how the logic chip works. 



#5 intvnut OFFLINE  

intvnut

    River Patroller

  • 3,054 posts
  • Location:@R6 (top of stack)

Posted Thu Jun 23, 2016 11:56 AM

I'll describe Mattel/ECS-style page flipping, at least how it's implemented in the current as1600, etc.  This is the page-flipping style JLP supports, and I imagine other hardware will support it if it wants.  I believe much of this has been covered in other threads (see Groovy's links above), so I'll summarize the relevant bits here.

 

Note:  You need a recent as1600, such as the one in the stable dev version on the jzIntv website

 

 

The Mattel scheme divides the memory map into 4K word ranges.  In the context of your question, the relevant 4K ranges are $C000 - $CFFF, $D000 - $DFFF, $E000 - $EFFF and $F000 - $FFFF.

 

A given 4K range can either hold flat ROM or be page flipped.  A page flipped range can hold up to 16 different 4K ROM pages, numbered 0 to 15. 

 

To flip a 4K range, you need to write the number $xA5y to location $xFFF in that range, where 'x' is the upper 4 bits of the address range, and 'y' is the page number.  For example, to flip $C000 - $CFFF to page 3, you would POKE $CFFF, $CA53.

 

At reset, all of the paged ROM ranges flip to page #0.

 

If you try to flip to a ROM page that isn't there, you get "dead air" on that range of addresses.  (i.e. it reads as $FFFF)

 

To assemble code into paged ROM, you need to use a slightly different version of the ORG directive:  ORG address:page.  This tells as1600 to place everything it assembles in a Mattel-style page-flipped ROM on page number 'page'.  For example, ORG $C100:3 says to start assembling at $C100, page #3.  If your code spills over from $CFFF to $D000, it will continue in $Dxxx page #3.  It will continue in page #3 until the next ORG statement.

 

In the context of your use case:

 

You could program your audio samples in IntyBASIC with something like this:

.


    ' Sample #0 in page 0
    ASM ORG $C100:0
    DATA $....    ' all the audio data for sample #0 here

    ' Sample #1 in page 1
    ASM ORG $C100:1
    DATA $....    ' all the audio data for sample #1 here

    ' Sample #2 in page 2
    ASM ORG $C100:2
    DATA $....    ' all the audio data for sample #2 here

.

...and so on.  You should only need the one ORG statement per sample even if the sample occupies $C100 - $FFFF. 

 

To flip between audio samples:

.

' Page-flip in the audio data for the sample # in "sample"
' "sample" is 0..15
PageFlipSample  Procedure
                POKE $CFFF, $CA50 + sample
                POKE $DFFF, $DA50 + sample
                POKE $EFFF, $EA50 + sample
                POKE $FFFF, $FA50 + sample
                Return
                End

.

That's it.

 

When you assemble your code, you should see lines in your .CFG file that look like this in the [mapping] section:

.

$3000 - $3FFF = $C000 PAGE 0
$4000 - $4FFF = $C000 PAGE 1
$5000 - $5FFF = $C000 PAGE 2
$6000 - $6FFF = $D000 PAGE 0
$7000 - $7FFF = $D000 PAGE 1
$8000 - $8FFF = $D000 PAGE 2

.

and so on.  The exact lines you get will depend on what else is in your ROM, the actual size of your audio samples and the actual number of audio samples.  But, you get the idea.

 

Note that the .ROM format does not support the Mattel page flipping format.  You need to use BIN+CFG.


Edited by intvnut, Thu Jun 23, 2016 1:23 PM.


#6 intvnut OFFLINE  

intvnut

    River Patroller

  • 3,054 posts
  • Location:@R6 (top of stack)

Posted Thu Jun 23, 2016 12:46 PM

One additional minor caveat:  If you want your game to play while the ECS is attached, avoid $2000 page 1, $7000 page 0 and $E000 page 1. 

 

In the context of your audio samples at $C100 - $FFFF, it would be sufficient to avoid putting an audio sample on page 1.







Also tagged with one or more of these keywords: jlp, intybasic, save game, storage, 42k, lto flash

0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users