| |
TWW
Registered: Jul 2009 Posts: 545 |
Save-feature on the Easy Flash
According to what I have (superficially) have read, the EasyFlash allows you to save data on the fly to the cartridge. I don't know of any other HW which allows this.
I was wondering if this could have been used as a "save game" functionality or is this a bad idea?
Reason I ask is due to a crack project I'm working on (for ages) which is made for the "C64 Game System Cartridge" and I was wondering if I could get rid of the need for any disk IO by porting it to EasyFlash. |
|
... 17 posts hidden. Click here to view all posts.... |
| |
Knight Rider
Registered: Mar 2005 Posts: 131 |
It looks like you are trying to reinvent the wheel. See here http://codebase64.org/doku.php?id=base:code_sample&s[]=easyflash |
| |
TWW
Registered: Jul 2009 Posts: 545 |
In order to understand the wheel you have to reinvent the wheel ;-)
I had seen that framework but it (as far as I can tell) does not build the .crt fram around the binary. |
| |
Knight Rider
Registered: Mar 2005 Posts: 131 |
Maybe you are overthinking it ? At the end you need a $FF padded 1024mb file.
Take C64 FIBR as an example. 1st your "standard" code and:
;64TASS
;
; =============================================================================
; 01;0;0000 (LOROM, bank 1)
bankStart_01_0
.logical $8000
Bank01x
.logical $0801
Bank01i
.binary "fibr.prg",$02
.here
Bank01L = * - Bank01x
.rept $c000-*
.byte $FF
.next
.here
.fill $f7fff,$ff
* = $fffff
.byte $ff
Built:
"...\64tass-1.53.1515\64tass" --long-address --no-warn ef.tas -b -o fibr.bin
"...\WinVICE-3.1-x86\cartconv" -i fibr.bin -t easy -o fibr_ef.crt
|
| |
TWW
Registered: Jul 2009 Posts: 545 |
Got it working once I setup the binary file correctly. here's the framework in case it could be of use to someone:
/*-----------------------------------------------------------------------------
EasyFlash Cartridge Framework
-----------------------------------------------------------------------------*/
// Cartridge Parameters
// ====================
// Cartridge Header Parameters
// ---------------------------
.const CartridgeHeaderSize = $40 // #$40 is default Double Word (Big endian)
.const CartridgeVersion = 1.000 // High/Low Order Fixed Point Word
.const CartridgeType = 32 // 32 = EasyFlash (Big Endian)
.const CartridgeEXROM = 0 // 0 = Inactive & 1 = Active.
.const CartridgeGAME = 1 // 0 = Inactive & 1 = Active.
.const CartridgeName = "EasyFlash Cartridge" // Maximum 32 bytes.
// Chip Header Parameters
// ----------------------
.const CartridgeChipHeaderSize = $10 // Size of Bank Header Integer (#$10 is default)
.const CartridgeChipSize = $2000 // Size of Cartridge Banks Integer
.const CartridgeChipType = 2 // 0 = ROM, 1 = RAM, 2 = Flash. Word (Big Endian)
.var CartridgeChipNumber = 0 // ID Number for the Chips
.const CartridgeLocationLo = $8000 // Cartridge ROM address on the C64 Word (Big Endian)
.const CartridgeLocationHi = $a000 // Cartridge ROM address on the C64 Word (Big Endian)
.var CartridgeLocation = CartridgeLocationLo
// Cartridge Header File
// =====================
.pc = $0000 "Cartridge Header"
.text "C64 CARTRIDGE "
.dword _SwitchEndian32(CartridgeHeaderSize)
.byte CartridgeVersion, round([CartridgeVersion-floor(CartridgeVersion)]*1000)
.word _SwitchEndian16(CartridgeType)
.byte CartridgeGAME, CartridgeEXROM
.fill 6,0
.encoding "petscii_upper"
.text CartridgeName
.encoding "screencode_mixed"
.fill 32-CartridgeName.size(),0
// Macros
// ======
// Macro to set chip header for each bank (to be called at each bank)
.macro ChipHeader() {
.text "CHIP"
.dword _SwitchEndian32(CartridgeChipHeaderSize + CartridgeChipSize)
.word _SwitchEndian16(CartridgeChipType)
.word _SwitchEndian16(CartridgeChipNumber)
.word _SwitchEndian16(CartridgeLocation)
.if (CartridgeLocation==CartridgeLocationLo) {
.eval CartridgeLocation = CartridgeLocationHi
} else {
.eval CartridgeLocation = CartridgeLocationLo
.eval CartridgeChipNumber++
}
.word _SwitchEndian16(CartridgeChipSize)
}
// Functions
// =========
// Switches endian on a 16 bit argument
.function _SwitchEndian16(argument) {
.return floor(argument / $100) + floor([argument/$100-floor(argument / $100)]*256)*256
}
// Switches endian on a 32 bit argument
.function _SwitchEndian32(argument) {
.return floor(argument / $1000000) + [floor(argument / $10000) - floor(argument / $1000000)*256]*256 + [floor(argument / $100) - floor(argument / $10000)*256]*$10000 + [argument - floor(argument / $100)*256]*$1000000
}
// LoBank #00 - Asset Manager
// ==========================
:ChipHeader() // Write the chip header for Bank #00
.import source "Asset Manager.asm" // Import Bank #00 which contains all the code to handle the startup and memory management etc.
// HiBank #00 - EasyFlash Startup Bank
//====================================
:ChipHeader()
!Bank_Begin:
.fill $1800,0
// EAPI
.import source "EasyAPI.asm"
.encoding "petscii_upper"
.text "EF-Name:KOL@@@@@@@@@@@@@"
.encoding "screencode_mixed"
.fill CartridgeChipSize - [* - !Bank_Begin-] - 2, $00
.word $8000
// Fill remaining banks with headers and 'null' data
//==================================================
.for (var i = 0 ; i < 190 - CartridgeChipNumber ; i++) {
:ChipHeader()
!Begin:
.byte $00
!End:
.fill CartridgeChipSize - [!End- - !Begin-], $00
}
Thanks for your input gents. |
| |
Maxlide
Registered: Apr 2003 Posts: 31 |
Quoting TWW(...)
.fill $1800,0
// EAPI
.import source "EasyAPI.asm"
.encoding "petscii_upper"
.text "EF-Name:KOL@@@@@@@@@@@@@"
.encoding "screencode_mixed"
.fill CartridgeChipSize - [* - !Bank_Begin-] - 2, $00
.word $8000
// Fill remaining banks with headers and 'null' data
//==================================================
.for (var i = 0 ; i < 190 - CartridgeChipNumber ; i++) {
:ChipHeader()
!Begin:
.byte $00
!End:
.fill CartridgeChipSize - [!End- - !Begin-], $00
}
[/code]
Thanks for your input gents.
Unused areas should be filled with $FF, not $00. |
| |
TWW
Registered: Jul 2009 Posts: 545 |
Indeed ;-) Thanks. |
| |
Majikeyric
Registered: Sep 2002 Posts: 83 |
Is 64KB (8 banks) the smallest amount of flash rom to erase (with EAPIEraseSector) in order to save a high score table or I misunderstood something in the docs ? |
| |
Count Zero
Registered: Jan 2003 Posts: 1932 |
Indeed, 64kb to erase as minimum. When working somewhat incremental you can always add to those 64kb as a large save bank and only need to erase and re-save whenever the 64kb block is full.
Given that one is using a complete 64kb bank as save bank that is. |
| |
enthusi
Registered: May 2004 Posts: 677 |
Yeah, that is sort of the weak spot.
Also they need to be in one chip (obviously), so not spread across high and low. |
| |
Majikeyric
Registered: Sep 2002 Posts: 83 |
Thanks for your explanations, incremental writes seem a good idea, I gonna implement that! :) |
Previous - 1 | 2 | 3 - Next |