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 > Saving from one memory location, loading to another!
2005-11-02 13:28
Laxity

Registered: Aug 2005
Posts: 459
Saving from one memory location, loading to another!

Ok.. Maybe some'o you guys know how to do this:

I wan't to save a file, say from $c000 to $ce00. The file should however load to adress $1000 to $1e00 when loaded normally (like: load "foo",8,1). How am I going about this problem?

I was thinking that I could write each byte of the data to disk, and since the two first bytes of a file is the destination memory pointer I could start by writing $00 $10 in this case and then the data from $c000 to $ce00!.. Is this correct?

Cheers!
2005-11-02 13:43
hollowman

Registered: Dec 2001
Posts: 474
this has been discussed before, unfortunately without any good answers, http://noname.c64.org/csdb/forums/?roomid=11&topicid=10710&show.. Saving files using Kernal
2005-11-02 13:46
HCL

Registered: Feb 2003
Posts: 728
If you're using the kernal saver, it woun't work. I had the same idea in ByteBoozer, but then i ended up transfering all data (to where it should be when loading) before saving. Totally lame :/.
2005-11-02 14:06
tlr

Registered: Sep 2003
Posts: 1790
Quote: Ok.. Maybe some'o you guys know how to do this:

I wan't to save a file, say from $c000 to $ce00. The file should however load to adress $1000 to $1e00 when loaded normally (like: load "foo",8,1). How am I going about this problem?

I was thinking that I could write each byte of the data to disk, and since the two first bytes of a file is the destination memory pointer I could start by writing $00 $10 in this case and then the data from $c000 to $ce00!.. Is this correct?

Cheers!


This is exactly correct!

example:
        lda     #$00
        sta     $90     ;status
        lda     #$61
        sta     $b9     ;secondary address
        jsr     $f3d5   ;iec-open
        lda     $ba     ;device number
        jsr     $ffb1   ;LISTEN
        lda     $b9
        jsr     $ff93   ;SECOND

        lda     #<ADDRESS
        jsr     $ffa8   ;CIOUT
        lda     #>ADDRESS
        jsr     $ffa8   ;CIOUT


;* the main write loop
lp1:
        lda     (currzp),y

;* write byte to IEC-bus
        jsr     $ffa8   ;CIOUT

;* check status, exit if fail
        lda     $90
        and     #%10000011
        bne     fail1

;* increase address and check for end
        inc     currzp
        bne     skp1
        inc     currzp+1
skp1:
        lda     currzp
        cmp     endzp
        bne     lp1
        lda     currzp+1
        cmp     endzp+1
        bne     lp1

;* Normal exit, clean up and CLEAR carry.
        jsr     $ffae   ;UNLSN
        jsr     $f642   ;iec-close
        clc
        rts

;* Failure exit, clean up and SET carry.
fail1:
        jsr     $ffae   ;UNLSN
        jsr     $f642   ;iec-close
        sec
        rts


2005-11-02 16:46
Laxity

Registered: Aug 2005
Posts: 459
Oh.. Thanks a lot.. Example code even.. Makes it so easy I don't even have to think for myself ;)
2005-11-02 17:12
tlr

Registered: Sep 2003
Posts: 1790
I'm home with a cold, so I have nothing better to do. :)
Sorry for spoiling the fun...
2005-11-03 00:08
Krill

Registered: Apr 2002
Posts: 2980
Using Action Replay or comparable,

s"file",8,c000,ce00,1000

will do the trick.

From within a program, what tlr said.
But if you want it faster than plain kernel, 1541/40/70/71-only and with playing a tune while saving,
check: Plushdos for the irq1bit saver.
2005-11-03 06:40
TNT
Account closed

Registered: Oct 2004
Posts: 189
It might be nicer for IDE64 & MMC64 folks if you used standard open/chkout/chrout/clrchn/close instead of IEC-specific routines.
2005-11-03 08:12
tlr

Registered: Sep 2003
Posts: 1790
Quote: It might be nicer for IDE64 & MMC64 folks if you used standard open/chkout/chrout/clrchn/close instead of IEC-specific routines.

I always did this with straight IEC-stuff, but I kind of figured it could be a problem with stuff like IDE64, MMC64 and similar...
Could you post a version doing the same as my code, but with straight I/O?
2005-11-03 10:16
TNT
Account closed

Registered: Oct 2004
Posts: 189
I will try to remember to do that tonight with IDE64. There is currently no device emulation for MMC64, but I'm writing one for MMC64+RR combo. If everything works as planned all IDE64 fixed programs should work with it (as long as they don't overwrite $DExx as I'm running code in Retro Replay RAM).
2005-11-03 10:35
tlr

Registered: Sep 2003
Posts: 1790
Great!
A related question: doesn't the IDE64/MMC64 supply a patched kernal? I believe that a lot of (old) software does direct IEC-calls, but uses no turbo, or other stuff that will make it impossible to run without patching.
 
... 10 posts hidden. Click here to view all posts....
 
Previous - 1 | 2 - 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
Mr. Lee
leonofsgr/Singular C..
jicas/Patagonia
Alakran_64
WVL/Xenon
MCM/ONSLAUGHT
Hydrogen/Glance
Andy/AEG
Martin Piper
Rico/Pretzel Logic
BANDIT/BANDIT-COOL-S..
Guests online: 96
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 The Demo Coder  (9.6)
6 Edge of Disgrace  (9.6)
7 What Is The Matrix 2  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.7)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 X-Mas Demo 2024  (9.5)
7 Dawnfall V1.1  (9.5)
8 Rainbow Connection  (9.5)
9 Onscreen 5k  (9.5)
10 Morph  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Triad  (9.3)
Top Diskmag Editors
1 Magic  (9.8)
2 hedning  (9.6)
3 Jazzcat  (9.5)
4 Elwix  (9.1)
5 Remix  (9.1)

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