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 > how do i load and run a program from another?
2006-04-11 13:59
Trifox
Account closed

Registered: Mar 2006
Posts: 108
how do i load and run a program from another?

...have made a reader programm for my upcoming 1k game, now i want this reader to load the game and start it !
2006-04-11 16:04
Oswald

Registered: Apr 2002
Posts: 5094
Fixup #$00

you can find here some fastloader sources, to be used in c64 turbo assembler.

Notice that the 1541 has an own cpu and memory, and all fastloader works with uploading code into the drive.

This means, that you have to call a install routine before you can use the loader.

check the sources, and the note on the disk, it should be self explanatory.
2006-04-11 16:15
hannenz
Account closed

Registered: Nov 2002
Posts: 24
if speed is not crucial you might want to just use the kernal-load routine:


lda #1
ldx #8
ldy #0 ;load
jsr $ffba ;setlfs
lda #fend-filename
ldx #<filename
ldy #>filename
jsr $ffbd ;setnam
lda #0 ;flag for 'load'
jsr $ffd5 ;kernal load routine
jmp startadress

filename .text "program"
fend

this will load just like ",8,1" at the BASIC prompt (to file adress)
then jump to that adress. (Well, won't work if loading overwrites your code, of course, you might put the small loader into some safe memory area...)

btw, trifox: i am very curious about your 1k-game developping!! go ahead!!! (we have a little 1k-game-competition at german forum-64.de btw...)
2006-04-11 16:52
Trifox
Account closed

Registered: Mar 2006
Posts: 108
hi hannenz,
hmm i am using vice, what is the correct statement for filenames ?


!text ?
or
!scr

and the load adress is determined by the rom function through the *= statement at the beginning of each asm program ?!

somehow this routine does simply nothing .... i used it like this:
LOADER:

lda #1
ldx #8
ldy #0 ;load
jsr $ffba ;setlfs
lda #5
ldx #<filename
ldy #>filename
jsr $ffbd ;setnam
lda #0 ;flag for 'load'
jsr $ffd5 ;kernal load routine
jmp $0810

filename !text "spiel"
fend
2006-04-11 18:11
Oswald

Registered: Apr 2002
Posts: 5094
if you're using turbo assembler in vice you should write .text

notice that .scr is most likely used for screen codes, and screen codes and petscii is two different codeset. .text gives you petscii codes, which you need in this case.

maybe the filename should be 4 "long"?

try to add the line as suggested: "lda #fend-filename"

check the track and drive led indicator in emulator. if the track is not on 18.0 when you start the code, and it goes to 18.0 afterwards and the led is flashing, you have a "?file not found error" :)
2006-04-11 18:33
Trifox
Account closed

Registered: Mar 2006
Posts: 108
aha, i have an file not found error ... ;)

how do i declare the filename ?


a)"spiel.prg"
b) "spiel"
or
c) "SPIEL"
or
d) "SPIEL.PRG"

the acme compiler knows the !pet statement, this should work i think
2006-04-11 19:13
Trifox
Account closed

Registered: Mar 2006
Posts: 108
help, it simply does not work, the lamp is blinking and 18 is standing there ... ;(((
2006-04-11 20:06
Oswald

Registered: Apr 2002
Posts: 5094
the extension doesnt belongs to the filename string on c64, the type of the file (prg/seq/etc) is stored in the directory structure seperately.

try print asc("s") and the rest of the characters in c64 basic to find out the petscii codes, compare that to what acme compiled.

btw maybe I led you to a wrong path, blinking led singals any error, but if the track changes to 18.0 that means the drive understood the command, and is scanning the directory for the file, so it can find out the starting track/sector.

try to google for load with c64 kernal, maybe the example by hannenz has some bugs.
2006-04-11 21:31
tlr

Registered: Sep 2003
Posts: 1790
Quote: help, it simply does not work, the lamp is blinking and 18 is standing there ... ;(((


It sounds like you are running in vice with a d64-image, but the file is not actually on that image. Maybe you are auto starting from a .prg but have true drive emulation forced on?
Anyway, if you want it to work on a real c64 you'd better stick the files onto a d64 and run everything through the drive emulation.
2006-04-12 00:33
Trifox
Account closed

Registered: Mar 2006
Posts: 108
@all thx for helping

but i actually put it all on to a d64 image...:(
2006-04-12 05:38
Oswald

Registered: Apr 2002
Posts: 5094
test your code with having ONLY the instructions needed to call the kernal load, and put an rts to the end. This makes sure you dont destroy the OS, and the rts will return you to the basic prompt.

(try to avoid using the common cross assembling method: prepacked code, the depacker might kill the OS, you may start your code with a SYS [decimalnumber] from the basic prompt)

then when u're back to the prompt enter this:

OPEN 15,8,15:INPUT #15,EN,EM$,ET,ES:PRINT EN,EM$,ET,ES:CLOSE

it will read and print the 1541 error channel for you, so you will get an exact description on what went wrong.

(en:error number, em$: error message, et: track, es: sector)




(edit: if you do some cruel thing under the memory area $400, you might destroy OS variables thats needed by kernal load to work correctly)
2006-04-12 06:59
TNT
Account closed

Registered: Oct 2004
Posts: 189
INPUT# doesn't work in direct mode, but you can POKE58,254 before it to work around that.
2006-04-12 08:16
hannenz
Account closed

Registered: Nov 2002
Posts: 24
i tried it and THIS must(!) work: (it works for me in vice with a d64 image attached containig a file called "game", compiling with ACME):

!to "c:/test.prg"
!ct pet

*=$1000

		lda #1
		ldx #8
		ldy #0
		jsr $ffba
		lda #fend-filename
		ldx #<filename
		ldy #>filename
		jsr $ffbd
		lda #0
		jsr $ffd5
		rts
		
filename		!tx "game"
fend

2006-04-14 01:01
Wyndex
Account closed

Registered: Apr 2006
Posts: 1
Hi guys,

If you're using 0 as the secondary address/command (ldy #00 before SETLFS), you need to specify the load address in XY before the call to LOAD:

LDA #08 ;File no.
LDX $BA ;Current device number
LDY #00 ;Secondary address
JSR SETLFS
LDA #0
LDX LOADADDR
LDY LOADADDR+1
JSR LOAD

If you want to use the address stored in the file, use LDY #1 (like load ,x,1).

-Wyn-
2008-07-23 12:06
El Topo

Registered: Jun 2006
Posts: 43
Ok, a related question. I've written a program that loads a couple of SEQ-files to memory. I get it to work when running it from TASM (compile+execute option) but when I do a sys to my program at the basic prompt I get a file not found flashing.

Filenames are stored like this: label .text "filename,s,r"
Correct?

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
Rick/F4CG
Da Snake
Grue/Extend
BYB/Hokuto Force
Paul Bearer
rexbeng
WVL/Xenon
Guests online: 135
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 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (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 Graphicians
1 Mirage  (9.8)
2 Archmage  (9.7)
3 Pal  (9.6)
4 Carrion  (9.6)
5 Sulevi  (9.6)

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