Jump to content
IGNORED

BIN/CAR/ROM Format: What's the difference?


Recommended Posts

I want to start converting a fairly large application from disk to cartridge-based format (MaxFlash 1Mbit), but I'm confused by the BIN, CAR and ROM formats. During development, it will be important to quickly test a freshly generated, bank-switched binary in Atari800WinPlus. My confusion stems from a poor understanding of the various cartridge emulation formats (never having programmed for a cart before). I have the MaxFlash studio software, which will apparently translate a BIN file into an ATR MaxFlash programmer. But do BIN images have binary headers, or not? And what are the differences between BIN, CAR and ROM files? Is there a quick way (if indeed any preprocessing is necessary) to turn an XEX file generated by, say, ATASM, into a bank-switching ROM image I can test on the emulator and ultimately flash to a cart?

 

And on the same subject, can someone point me to a description of the MaxFlash 1MB cart banking registers? I've seen some discussions floating around in the past but I can't seem to locate them now.

Edited by flashjazzcat
Link to comment
Share on other sites

Hi,

 

I want to start converting a fairly large application from disk to cartridge-based format (MaxFlash 1Mbit), but I'm confused by the BIN, CAR and ROM formats. During development, it will be important to quickly test a freshly generated, bank-switched binary in Atari800WinPlus. My confusion stems from a poor understanding of the various cartridge emulation formats (never having programmed for a cart before). I have the MaxFlash studio software, which will apparently translate a BIN file into an ATR MaxFlash programmer. But do BIN images have binary headers, or not? And what are the differences between BIN, CAR and ROM files?

No, just the CAR files should have the header which is used by the emulators to automatically choose the correct way to treat the data/banks. The BIN and ROM files are the 'dumps' of the cartridges and so are typically 8K, 16K, 64K, 128K etc. In Atari800WinPLus you have a menu option to 'convert' a cart image to a CAR file, i.e. it tacks the header onto it.

Is there a quick way (if indeed any preprocessing is necessary) to turn an XEX file generated by, say, ATASM, into a bank-switching ROM image I can test on the emulator and ultimately flash to a cart?

Yes, but not relevent for what you are trying I think. E.g. The MaxFlash menu software will 'boot' an XEX file but effectively you are loading this into memory and switching out the cart when transfer is passed to the file's code. Therefore you would not be taking any advantage of, say, bank switching to free yourself up more working RAM or, as another example, make the thing run in 48K rather than 64K.

And on the same subject, can someone point me to a description of the MaxFlash 1MB cart banking registers? I've seen some discussions floating around in the past but I can't seem to locate them now.

These are in the Atari800WinPLus help files, e.g. when you attach a BIN/ROM file it will ask you which type of cart model you are using and the lower part of this window changes with the description you require as you select different models.

 

<edit> Just found an old post with this information:

 

AtariMax 1 Mb Flash cartridge - This bank-switched cartridge occupies 8 KB of address space between $A000 and $BFFF. The cartridge memory is divided into 16 banks, 8 KB each. The 4 lowest bits of the address written to $D500-$D50F select the bank mapped to $A000-$BFFF. Writing to $D510-$D51F disables the cartridge and any write to $D520-$D5FF is ignored.

 

AtariMax 8 Mb Flash cartridge - This bank-switched cartridge occupies 8 KB of address space between $A000 and $BFFF. The cartridge memory is divided into 128 banks, 8 KB each. The seven lowest bits of the address written to $D500-$D57F select the bank mapped to $A000-$BFFF, bit 7 disables the cartridge."

</edit>

 

This post contains a couple of links to other relevent posts.

 

Good luck!

 

Regards,

Mark

Edited by Wrathchild
  • Like 1
Link to comment
Share on other sites

These are support routines Steve had given me way back. It may require putting them in some context but I can't find a test app I'd made in the past, however if you check the MaxFlashKit sources you may find them being used there as IIRC these are embedded in there somewhere. Shawn may have some examples too.

 

[Edit] Found this:

 

wr2ce	jsr init					;; c4a -> cea9 -> pos 4da
lda #$08					;; flash sector 8
jsr erasebk					;; 02 sectors from 6320 to sector 2CE/2CF

lda #$20
sta copysrc
lda #$63
sta copysrc+1

lda #$FF
sta count
lda #$00
sta count+1

lda #$08
jsr prgsec	
jsr cleanup
rts

 

Regards,

Mark

fcode.zip

Edited by Wrathchild
Link to comment
Share on other sites

There is also a difference between the 1mb and 8mb flashcarts as to which bank is automatically selected at boot time (ie. the one you need your run and init vectors in!). I believe that on the 1mb cart, this is bank 0, and on the 8mb cart it is the last bank, $7F. I could be wrong, but that's what I remember.

 

I'm not sure why Steve has not publically released the flashing routines... I would rather he do it, or at least give his permission to do so, since it is his code.

 

On the subject of flashing, I believe that on the 1mb cart you have to erase a 16k "block" at a time, and on the 8mb cart, it is a 64k block. This makes it somewhat difficult to save small pieces of data to the cart, since you probably want to save data from cart block, erase, make changes to the data, reflash. Designing an app from scratch for the flashcart would make this much simpler than trying to hack an existing program to use it though. In the U2, U3 and Temple of Apshai carts that I converted, I took up an entire block (several in the case of Ultima actual!) to store a small amount of data that would normally be written to the disk.

Link to comment
Share on other sites

These are support routines Steve had given me way back. It may require putting them in some context but I can't find a test app I'd made in the past, however if you check the MaxFlashKit sources you may find them being used there as IIRC these are embedded in there somewhere. Shawn may have some examples too.

 

[Edit] Found this:

 

wr2ce	jsr init					;; c4a -> cea9 -> pos 4da
lda #$08					;; flash sector 8
jsr erasebk					;; 02 sectors from 6320 to sector 2CE/2CF

lda #$20
sta copysrc
lda #$63
sta copysrc+1

lda #$FF
sta count
lda #$00
sta count+1

lda #$08
jsr prgsec	
jsr cleanup
rts

 

Regards,

Mark

Thanks Mark. It could be pretty awesome to actually save data to the cart. Can't wait to get stuck into this.

 

There is also a difference between the 1mb and 8mb flashcarts as to which bank is automatically selected at boot time (ie. the one you need your run and init vectors in!). I believe that on the 1mb cart, this is bank 0, and on the 8mb cart it is the last bank, $7F. I could be wrong, but that's what I remember.

 

I'm not sure why Steve has not publically released the flashing routines... I would rather he do it, or at least give his permission to do so, since it is his code.

 

On the subject of flashing, I believe that on the 1mb cart you have to erase a 16k "block" at a time, and on the 8mb cart, it is a 64k block. This makes it somewhat difficult to save small pieces of data to the cart, since you probably want to save data from cart block, erase, make changes to the data, reflash. Designing an app from scratch for the flashcart would make this much simpler than trying to hack an existing program to use it though. In the U2, U3 and Temple of Apshai carts that I converted, I took up an entire block (several in the case of Ultima actual!) to store a small amount of data that would normally be written to the disk.

Great info - thanks. icon_smile.gif

 

So can base code in low RAM switch out the 8K ROM space altogether and use the "Shadow RAM" underneath, then turn the cart back on again? Clearly SDX's "X" command does exactly this, so it must be possible.

 

Question: Does anyone have a script which will strip off all the binary headers (both at the top of the executable and embedded segment headers) - just in case ATASM won't do it (and it's not practical to change assemblers just at the moment).

 

Long term plan is to arrange program in logical blocks where possible: i.e. main loop, refresh, etc in bank 0, print processor in bank 1, disk menu in bank 2, etc. Code which is in the same bank can use normal JSRs, while "long" JSRs (written as macros which call a routine in low RAM) will be used to transparently call routines in different banks.

 

EDIT: Looks like ATASM will compile to a "RAW" binary image with the "-r" directive, which hopefully means no headers. Any script-processing should be unnecessary, if that's the case.

Edited by flashjazzcat
Link to comment
Share on other sites

 

So can base code in low RAM switch out the 8K ROM space altogether and use the "Shadow RAM" underneath, then turn the cart back on again? Clearly SDX's "X" command does exactly this, so it must be possible.

 

EDIT: Looks like ATASM will compile to a "RAW" binary image with the "-r" directive, which hopefully means no headers. Any script-processing should be unnecessary, if that's the case.

 

yep, raw is no headers

 

$d580-$d5ff turns off 8mbit cart for RAM access, think the 1mbit is different though

just write $d500-$d7ff as usual when you want a bank back in again

 

check out the .bank directive on ATasm - really useful for assembling a whole cart in one hit (although the example in the doc doesn't have cart headers like it should - that's partly my fault :P - sorry gauntman)

Edited by Sheddy
Link to comment
Share on other sites

yep, raw is no headers

 

$d580-$d5ff turns off 8mbit cart for RAM access, think the 1mbit is different though

just write $d500-$d7ff as usual when you want a bank back in again

 

check out the .bank directive on ATasm - really useful for assembling a whole cart in one hit (although the example in the doc doesn't have cart headers like it should - that's partly my fault icon_razz.gif - sorry gauntman)

Yeah - I checked it out and I managed to compile a header free executable with "-r". :)

 

It never occured to me that just selecting a bank would re-enable the cart: obvious, when you think about it!

 

I've used the ".bank" directive extensively with the current version of LW, because the two segements which sit under the OS are both loaded at the same address in RAM before being moved. It actually took me a long time to realize that without the ".bank" directive (even in a non-relocating executable), ATASM has a habit of rearranging your segments which ever way it sees fit.

 

Thanks for that info. :)

Link to comment
Share on other sites

  • 6 years later...

I did not have any luck using fcode.zip. I was trying to write to sector 12 and found that it erased but did not program. I noticed that setsec was storing the first bank number in cursec instead of the sector number and with that changed the sector now programmed. However I think I saw some other data changed that I was not expecting so I contacted Steve and he sent me the code he'd used on Ultima IV and said I should post it.

example.s

Link to comment
Share on other sites

Hmmm,

 

not sure if this is the right topic here... I do have the Ultimate Cart. which can execute CAR, ROM and XEX files from an SD cart. One of the many cart types it accepts is the Atarimax 8MBit (1MB) type, as well as the Atarimax 1MBit (128KB) type. But as said before, it must be a CAR or ROM file...

 

Now, I have some ATR images which will program an 8MBit or 1MBit Atarimax cart, but alas not their corresponding ROM or CAR files. Is there a way -other than programming the Atarimax cart with the ATR image - to get a ROM file from this ATR image ?!? Or would it be possible to use an Emulator (e.g. Altirra) to fake the presence of an Atarimax cart and in the end turn the contents of the (programming) ATR image into a ROM ?

 

 

Lords of Conquest (maxflash image).atr

Link to comment
Share on other sites

Chances are the ROM is simply embedded contiguously, so you could likely extract the raw data by skipping X bytes of the "Flasher ATR" file.

Problem might be that the flasher program could have evolved over time so X might be a variable quantity depending on what version of the utility generated it.

Link to comment
Share on other sites

Extracting directly out of the ATR would be fastest, but yes, you can flash in Altirra and then save out the raw cartridge image (File > Save Firmware > Save Cartridge). The flash chip emulated is Am29F010/Am29F040B, so it should be compatible with even older flashers.

 

In theory, it's possible to incrementally flash a block, so that the block only rarely has to be erased if you're only putting a small amount of data into it. Haven't tried it out on real hardware yet.

 

One thing to watch out for is that flash chips from different manufacturers can have the same total size but different sector sizes. This issue crept up with different Ultimate1MB runs, some of which had 64K sector flash chips and others which had 4K sectors. I'm not sure how many different flash chips the AtariMax carts have shipped with.

Link to comment
Share on other sites

Now, I have some ATR images which will program an 8MBit or 1MBit Atarimax cart, but alas not their corresponding ROM or CAR files. Is there a way -other than programming the Atarimax cart with the ATR image - to get a ROM file from this ATR image ?!?

 

Just drop the file into a The!Cart Studio project sand it'll do exactly that.

Link to comment
Share on other sites

In theory, it's possible to incrementally flash a block, so that the block only rarely has to be erased if you're only putting a small amount of data into it. Haven't tried it out on real hardware yet.

 

One thing to watch out for is that flash chips from different manufacturers can have the same total size but different sector sizes. This issue crept up with different Ultimate1MB runs, some of which had 64K sector flash chips and others which had 4K sectors. I'm not sure how many different flash chips the AtariMax carts have shipped with.

Yes, this works on my real atarimax bank 127 startup carts at least. (Space Harrier does this for its high scores)
Link to comment
Share on other sites

  • 3 years later...
On 10/3/2016 at 7:25 PM, CharlieChaplin said:

Now, I have some ATR images which will program an 8MBit or 1MBit Atarimax cart, but alas not their corresponding ROM or CAR files. Is there a way -other than programming the Atarimax cart with the ATR image - to get a ROM file from this ATR image ?!? Or would it be possible to use an Emulator (e.g. Altirra) to fake the presence of an Atarimax cart and in the end turn the contents of the (programming) ATR image into a ROM ?

 

 

Lords of Conquest (maxflash image).atr 202.39 kB · 55 downloads

Mega-bumping this thread. Maybe in that time it was not possible...

 

You can attach a special Empty Maxflash Cartridge (bank 0 or bank 127) and then load the ATR image. You will program into a virtual cartridge the contents of the ATR. Then, with "Save Fimware" -> "Save cartridge" you can make the ROM or CAR file.

 

  • Like 1
Link to comment
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...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...