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!
 
... 10 posts hidden. Click here to view all posts....
 
2005-11-03 10:51
cadaver

Registered: Feb 2002
Posts: 1160
At least IDE64 doesn't.
2005-11-03 11:22
TNT
Account closed

Registered: Oct 2004
Posts: 189
Both IDE64 and my patch only touch vectors at $03xx. That's why you can't use direct calls which bypass these vectors. In the easiest case IDE64 fix only requires changing all those calls to their patchable versions.
2005-11-03 20:22
TNT
Account closed

Registered: Oct 2004
Posts: 189
This one works with 1541 and clones as well as with IDE64.

setlfs  = $ffba
setnam  = $ffbd
open    = $ffc0
close   = $ffc3
chkout  = $ffc9
clrchn  = $ffcc
chrout  = $ffd2


;       make some test data

        ldx     #0
init    txa
        sta     buf,x
        inx
        bne     init

;       and save it

        lda     #1
        ldx     $ba             ; use last accessed device
        ldy     #1
        jsr     setlfs

        lda     #4
        ldx     #<name
        ldy     #>name
        jsr     setnam

        jsr     open

        ldx     #1              ; make it default output
        jsr     chkout

        lda     #<address       ; send wanted address
        jsr     chrout
        lda     #>address
        jsr     chrout

        lda     #<memstart      ; set memory start and end addresses
        sta     $ac
        lda     #>memstart
        sta     $ad
        lda     #<memend
        sta     $ae
        lda     #>memend
        sta     $af

        ldy     #0
lp1:
        lda     ($ac),y         ; write byte to device
        jsr     chrout

        lda     $90             ; check status, exit if fail
        and     #%10000011      ; you could use jsr $ffb7 instead
        bne     fail1           ; of directly reading $90, but it 
                                ; really doesn't matter

        jsr     $fcdb           ; bump $ac.w
        jsr     $fcd1           ; compare it to $ae.w
        bcc     lp1             ; loop if not equal

        clc                     ; successful return

        dc.b    $24             ; bit $nn, hides "sec" below

fail1   sec                     ; error flag

        php                     ; remember status

        jsr     clrchn          ; restore default output
        lda     #1
        jsr     close           ; and close file

        plp                     ; restore status
        rts

name    dc.b    "DATA"

buf     ; our data will be here

address         = $c000         ; it will load into this address

memstart        = buf           ; and these are for readability
memend          = buf+256
2005-11-03 20:32
tlr

Registered: Sep 2003
Posts: 1790
@TNT: Clean and compact, nice! :)
2005-11-03 21:04
Wanderer
Account closed

Registered: Apr 2003
Posts: 478
Why not just transfer the code?

T c000 ce00 1000

then save
s "filename" 1000 1e00

Your method of changing the first two bytes will work of course. I've used that myself since the emulator/monitor I use is very unfriendly.
2005-11-03 23:47
Graham
Account closed

Registered: Dec 2002
Posts: 990
Why that complicated? You can use the standard LOAD vector for loading to any adress, and it is compatible with all fastloaders too.
2005-11-04 05:57
Laxity

Registered: Aug 2005
Posts: 459
Quote: Why not just transfer the code?

T c000 ce00 1000

then save
s "filename" 1000 1e00

Your method of changing the first two bytes will work of course. I've used that myself since the emulator/monitor I use is very unfriendly.


Sure that'll work, but would be unusable in a tool. "Press F1 for instructions on how to save"!.. Nah.. don't think so! ;)
2005-11-04 05:57
Laxity

Registered: Aug 2005
Posts: 459
tlr & TNT, thanks for sharing. I appreciate it!
2005-11-04 16:03
TNT
Account closed

Registered: Oct 2004
Posts: 189
Quote: Why that complicated? You can use the standard LOAD vector for loading to any adress, and it is compatible with all fastloaders too.

Load instructions:
poke 43,0:poke 44,16:load"file",8:poke 43,1:poke44,8

?

Rather than have wrong load address I would rather have totally bogus one ($0000 anyone?) so it would be clear what's wrong if I don't jump through all the loops required to load file correctly.
2006-01-08 20:10
hannenz
Account closed

Registered: Nov 2002
Posts: 24
Quote: Why that complicated? You can use the standard LOAD vector for loading to any adress, and it is compatible with all fastloaders too.

yes. just load the file as follows, this method ignores the file's load adress and will uzse the given one. and it uses kernal i/o only.


;load to ANY adress...

load_adress = $xxxx

		lda #1
		ldx $ba         ;last used device
		ldy #0
		jsr $ffba	;setlfn
		lda #fn1-fn
		ldx #<fn
		ldy #>fn
		jsr $ffbd	;setnam
		lda #0
		ldx #<load_adress
		ldy #>load_adress
		jsr $ffd5	;load
fn		.text "filename"
fn1
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
Guests online: 118
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
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 Fullscreen Graphicians
1 Joe  (9.7)
2 Sulevi  (9.6)
3 The Sarge  (9.6)
4 Veto  (9.6)
5 Facet  (9.6)

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