Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Save-feature on the Easy Flash
2018-02-20 16:30
TWW

Registered: Jul 2009
Posts: 541
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....
 
2018-02-22 13:53
TWW

Registered: Jul 2009
Posts: 541
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.
2018-02-22 15:02
Knight Rider

Registered: Mar 2005
Posts: 114
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
2018-02-23 01:56
TWW

Registered: Jul 2009
Posts: 541
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.
2018-02-26 11:55
Maxlide

Registered: Apr 2003
Posts: 29
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.
2018-02-26 13:22
TWW

Registered: Jul 2009
Posts: 541
Indeed ;-) Thanks.
2018-03-02 05:43
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 ?
2018-03-02 07:43
Count Zero

Registered: Jan 2003
Posts: 1825
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.
2018-03-02 08:18
enthusi

Registered: May 2004
Posts: 675
Yeah, that is sort of the weak spot.
Also they need to be in one chip (obviously), so not spread across high and low.
2018-03-02 10:42
Majikeyric

Registered: Sep 2002
Posts: 83
Thanks for your explanations, incremental writes seem a good idea, I gonna implement that! :)
2018-03-02 12:36
Mr. SID

Registered: Jan 2003
Posts: 421
FWIW, Prince of Persia uses a single 8KB bank for saving (each save data is 3 bytes, iirc), so it just adds the saves incrementally until the bank is full, it doesn't erase data at all.
Previous - 1 | 2 | 3 | 4 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
WVL/Xenon
MMS_Z
jmin
Eddie
Xiny6581/Dees Produc..
Matt
Higgie/Kraze/Onslaught
wil
Guests online: 161
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Memento Mori  (9.6)
10 Bromance  (9.5)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Rainbow Connection  (9.5)
7 Wafer Demo  (9.5)
8 Dawnfall V1.1  (9.5)
9 Quadrants  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Nostalgia  (9.3)
2 Oxyron  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Webmasters
1 Slaygon  (9.7)
2 Perff  (9.6)
3 Morpheus  (9.5)
4 Sabbi  (9.5)
5 CreaMD  (9.1)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.042 sec.