| |
Rattus Account closed
Registered: Apr 2004 Posts: 34 |
load + save = copy ???
Is it possible to make a program that copies files by just using kernal calls ?
Let's say I have a file that has a load address of $0900...
So when you type load "file",8,1 it is loaded to $0900 and is runnable...
But... If you load the file using kernal call LOAD... And want it to load to $4000 it goes nicely there. The problem is here: How to save the file from $4000 so, that it will load to $0900 next time you load it from BASIC ?
Are there routines in kernal to figure out files start-address, end-address, length etc... ?
It would be really nice if someone could bother helping me...
|
|
| |
yago
Registered: May 2002 Posts: 333 |
I hate to say it, but these Questions are way to basic to be answered here in detail. If you want better answers, you might check out the newsgroup comp.sys.cbm
If you do not load and save, but simply open that file, read the bytes, close the file, open another file, save the bytes, and close that second file, you are done.
No matter what the load-address is.
There are enough kernel-routines for this kind of stuff.
Zed Yago
--
If everything is worth money
money is worth nothing |
| |
hollowman
Registered: Dec 2001 Posts: 474 |
dont know if there is a pretty way of getting the loadadress. anyway, this worked for me to copy a file
*= $1000
loadad = $fd
end = $fb
setnam = $ffbd
setlfs = $ffba
load = $ffd5
save = $ffd8
lda #8
ldx #8
ldy #0
jsr setlfs
lda #name2-name
ldx #<name
ldy #>name
jsr setnam
lda #$60
sta $b9
jsr $f3d5
lda $ba
jsr $ed09
lda $b9
jsr $edc7
jsr $ee13
sta loadad
jsr $ee13
sta loadad+1
lda #0
jsr load
stx end
sty end+1
lda #8
ldx #8
ldy #0
jsr setlfs
lda #sname2-sname
ldx #<sname
ldy #>sname
jsr setnam
ldx end
ldy end+1
lda #loadad
jsr save
rts
name
.text "gnu.draz"
name2
sname
.text "test7"
sname2
|
| |
iopop
Registered: Dec 2001 Posts: 317 |
This have been discussed in this topic already Saving files using Kernal
But no conculsion was find back then. One method would be to load the file. Then to save use $FFD2 to write onto disk. The first two bytes written contains the new low and high adress of the files starting adress and then the data. This method is however really slow. I used this method in ATTAC to be able to save data $0801-$ffff without any problems. |
| |
Rattus Account closed
Registered: Apr 2004 Posts: 34 |
Thank you...
Sorry if I have asked stupid questions, but not all people are genius...
|
| |
Richard
Registered: Dec 2001 Posts: 621 |
Quote: dont know if there is a pretty way of getting the loadadress. anyway, this worked for me to copy a file
*= $1000
loadad = $fd
end = $fb
setnam = $ffbd
setlfs = $ffba
load = $ffd5
save = $ffd8
lda #8
ldx #8
ldy #0
jsr setlfs
lda #name2-name
ldx #<name
ldy #>name
jsr setnam
lda #$60
sta $b9
jsr $f3d5
lda $ba
jsr $ed09
lda $b9
jsr $edc7
jsr $ee13
sta loadad
jsr $ee13
sta loadad+1
lda #0
jsr load
stx end
sty end+1
lda #8
ldx #8
ldy #0
jsr setlfs
lda #sname2-sname
ldx #<sname
ldy #>sname
jsr setnam
ldx end
ldy end+1
lda #loadad
jsr save
rts
name
.text "gnu.draz"
name2
sname
.text "test7"
sname2
This routine should be useful for packer routines or something like that as well as copiers, depending on where these routines go :) |
| |
hollowman
Registered: Dec 2001 Posts: 474 |
Quote: Thank you...
Sorry if I have asked stupid questions, but not all people are genius...
i dont think the question is stupid, atleast i dont know a
smooth way of changing the startadress using
kernalroutines. perhaps yago could enlighten us? |
| |
iopop
Registered: Dec 2001 Posts: 317 |
Quote: i dont think the question is stupid, atleast i dont know a
smooth way of changing the startadress using
kernalroutines. perhaps yago could enlighten us?
Same here. I find it very interesting to see a smooth solution to this.
Another not-that-smooth way would be too save the file with normal kernel calls. Then find the Track/Sector containing the first 254 bytes of the file. Read that sector into mem, change the first two bytes (which contains the startadress) and re-write that sector. |
| |
yago
Registered: May 2002 Posts: 333 |
Quote: i dont think the question is stupid, atleast i dont know a
smooth way of changing the startadress using
kernalroutines. perhaps yago could enlighten us?
/me and my big mouth!
I am using a (selfwritten) crossdevelopment-tool for manipulating loadaddresses, but that does certainly not use kernal-routines!
What I tried to explain above is the following code:
Open File
Read until EOF, buffer into memory.
Close File
Change 1st+2nd byte in memory to new loadaddress
Open File
Write File from buffer
Close File
I did not want to scare rattus away, I just wanted to point him to another community, if there would be not enough answers from here.
BTW, there is a Program called "change loadaddress" (or similar) on the 1541Disk, which is delivered by cbm with every 1541 Drive. Its a Basic-Program.
|
| |
Graham Account closed
Registered: Dec 2002 Posts: 990 |
@hollowman:
it would be better if you used jump table calls instead of direct rom calls.
$FFB4 instead of $ED09
$FF96 instead of $EDC7
$FFA5 instead of $EE13
also, you should UNTALK the device again etc. |
| |
cadaver
Registered: Feb 2002 Posts: 1160 |
Also it should be noted that TALK/UNTALK, CIOUT etc. won't be IDE64 compatible. It'll be a bit more pain to OPEN, CHKIN/CHKOUT and then CHRIN/CHROUT the file byte by byte but at least then you're compatible and are in exact control of what happens (including startaddress). |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
AFAIK you can set a new loadadress with the kernal save... |
| |
Stryyker
Registered: Dec 2001 Posts: 468 |
You can Oswald? Enlighten me. I know AR had a save file with different load address.
If you are messing with something funky it can be a bit of hassle but search for start track + sector. Use the U1 and U2 command to read to drive buffer, change 2 bytes (B-P first) and write back. Maybe even spend a little time using the open command with certain thingy (I'm getting dumb!), like lda #$03,ldx #$08, ldy #thingy, jsr $ffba then open. See what drive locations are used then close, B-P then write with suitable U command. Check AR loader as this uses similar method to setup the loader. Use kernel open command then start some drive code (unsure if it uses open, then writes to drive memory then executes or what). That atleast happens with 1581 fast loader.
Bad formatting but ideas.
If your code was tidy enough, you could make something a drive mem multiple start address changer. Just dump a queue to drive and use similar filename parsing like some IRQ loaders then return.
|
| |
Graham Account closed
Registered: Dec 2002 Posts: 990 |
@cadaver: IDE64 shouldnt use IEC device numbers then. |