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 > Loading files
2008-07-27 18:44
Bregalad
Account closed

Registered: Jul 2008
Posts: 42
Loading files

I'm a total newbie on the C64 but not on the 6502.

I'm trying to do a simple programm and I'm trying to sucessfully load a separate file into memory manually exactly as describled here
But I keep getting error #4 (file not found) although the file exists, I tried both with and without the " symbols arround the filename.

BTW if anyone know something better than the Kernal routines for loading files let me know, so that I can use zero page without worrying about anything, which is something I'd really like to do. I found a couple of so-called "fastloaders" arround but they are hard to understand for a newbie and I don't know howell emulators supports them (Metal Warrior freezes in Vice if I enable the fastloader).
2008-07-27 19:07
hollowman

Registered: Dec 2001
Posts: 474
Perhaps its just the wrong case on the filename? Check in memory with a machine code monitor that the name looks exactly as on disk, or try with "*" as filename and see if that loads anything

Pretty much all loaders work fine in latest version of vice, is true drive emulation turned on?

If you are comfortable with crossassemblers you can try dreamload or ask Krill for the latest version of his loadersystem.
But for something easier to just try out and get started there's the older versions of Krills loaders Plushdos which has a nice interface and Fixup #$00 which has the loaders as source code for tass.
2008-07-27 21:33
Bregalad
Account closed

Registered: Jul 2008
Posts: 42
You are right it was the wrong case ! (as PC uppercase = C64 lowercase this is a headache)

However it skips the 2 first bytes, and that regardless if the file is a PRG file or a SEQ file. Any idea how to bypass this ?
2008-07-27 21:59
chatGPZ

Registered: Dec 2001
Posts: 11386
normally the first two bytes are used as the load address, the kernal routines will either use that, or let you ignore it. (other custom loaders might let you use it for data though)
2008-07-27 22:00
Monte Carlos

Registered: Jun 2004
Posts: 359
The first two bytes point on the memory location the file is loaded. They are not written into ram, they are just read to initialize the destination pointers.

Monte
2008-07-27 22:01
Monte Carlos

Registered: Jun 2004
Posts: 359
Hey Groepaz,

two .... the same thought, heh?
2008-07-29 20:53
Bregalad
Account closed

Registered: Jul 2008
Posts: 42
Okay now I can load files. However, as long as I use Kernal I have risk of conflicting variables with my program and this is bothering.

Which memory locations should be considered safe to use, and which ones should be keept intact for the kernal ? It seems the Kernal uses most of zero pages, and that it also use some memory at $200-$3ff range (software interrupt vectors for instance, altough they're undocumented in the official docs it seems).

Something that comes in mind is that I could have a copy of the zero page somewhere else, and every time I use Kernal I exchange the true zero page with the Kernal one, and when it's done I change them back so that I can continue to use zero page in my programm. This sounds cheap but I guess that would work.

Does anyone how well this fastloader works ? It seems like very doccumented and I like that. (btw I've got Metal Warrior's fasloader working in Vice playing with the options randomly)

About the first 2 bytes : I trought SEQ files did not have a loading adress but start immediately with data. Then what is the difference between SEQ and PRG ?
2008-07-29 21:29
AlexC

Registered: Jan 2008
Posts: 299
I don't think that swapping in and out content of zero page is the right solution. As for safe memory area it all depends what you will need: location and size of address space + size and starting address of your code. Using kernel routines you can safely switch out BASIC and additionally use memory staring from C000 (you can use it even with BASIC still on). If you really need all the memory you can consider switching int/out D000 I/O area - I believe this has been described in one of C=Hacking issues. Additionally you can use lower parts of stack - assuming you will not use a lot of subroutines (JSR) and you are not using some decrunching routine. You can also use $02A7-$02FF (often used by simple autostart code) area and $033C-$03FB (tape buffer).

I'm not sure about what vectors are you talking about but all starting from $300 are very well documented. Take a look at this document:
http://unusedino.de/ec64/technical/aay/c64/zpmain.htm

As for CovertBitOps loader it has few drawbacks if I remember correctly - one is that it will crash during NMI.
2008-07-30 08:37
Bregalad
Account closed

Registered: Jul 2008
Posts: 42
Thanks for pointing to some more Kernal doccumentation, I found the official documentation to be quite lacking about which variables are used.
I'm going to write video games so definitely Basic won't be used at all, and I guess I will make very minor use of the Kernal as well.

I don't want to start a new thread just for that, but I canot found a list of all sources of interrupts. What I know so far :
- Raster IRQ interrupt (use on scanline #0 for VBlank, other scanlines for rester effects ?)
- Timer IRQ (poorly doccumented at first glance, most things I see arround just mention to disable it before using Raster IRQ)
- Other devices that directly connects to C64's bus can probably do IRQs as well (cartridges, serial port)
- Run/Stop+Restore NMI (it this correct ?)

I can't find a Reset button on my C64 so I don't know if there is any Rest interrupt source other than turning off then on, but Vice has a soft reset option...

As long as the loader runs with Kernal disabled I can set my own NMI vector at $fffa, and make it do whanever I want to not freeze the loading (this may also be possible with the secondary software vector if Kernal is enabled).
2008-07-30 08:54
Oswald

Registered: Apr 2002
Posts: 5094
fffe-ffff: cia #x generated irqs, VICII generated irqs, brk
fffa-fffb: cia #y generated irqs, restore key,
(fffc-fffd: reset ?:)
2008-07-30 15:59
AlexC

Registered: Jan 2008
Posts: 299
Quote: Thanks for pointing to some more Kernal doccumentation, I found the official documentation to be quite lacking about which variables are used.
I'm going to write video games so definitely Basic won't be used at all, and I guess I will make very minor use of the Kernal as well.

I don't want to start a new thread just for that, but I canot found a list of all sources of interrupts. What I know so far :
- Raster IRQ interrupt (use on scanline #0 for VBlank, other scanlines for rester effects ?)
- Timer IRQ (poorly doccumented at first glance, most things I see arround just mention to disable it before using Raster IRQ)
- Other devices that directly connects to C64's bus can probably do IRQs as well (cartridges, serial port)
- Run/Stop+Restore NMI (it this correct ?)

I can't find a Reset button on my C64 so I don't know if there is any Rest interrupt source other than turning off then on, but Vice has a soft reset option...

As long as the loader runs with Kernal disabled I can set my own NMI vector at $fffa, and make it do whanever I want to not freeze the loading (this may also be possible with the secondary software vector if Kernal is enabled).


Talking about loaders and interrupts keep in mind that fastloading is cycle exact so any uncontrolled interrupt trigger can in fact ruin whole loading process. Even if you setup your own IRQ and NMI handlers you will still loose cycles due to interupt request and RTI. This is why disabling NMI is better option. You can use CIA timers to better handle IRQ and NMI (including disabling NMI despite it's name). For the same reason some loaders also disable screen ($D011).

 
... 2 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
kbs/Pht/Lxt
Andy/AEG
XmikeX
Peacemaker/CENSOR/Hi..
Sulevi/Virtual Dreams
slimeysmine
megasoftargentina
grass/LETHARGY
Hagar/The Supply Team
t0m3000/hf^boom!^ibx
Mibri/ATL^MSL^PRX
Guests online: 170
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 Original Suppliers
1 Derbyshire Ram  (9.7)
2 Fungus  (9.3)
3 Black Beard  (9.2)
4 Baracuda  (9.2)
5 hedning  (9.1)

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