pouët.net

Go to bottom

C64 .PRG Autostart (cross-assembler)

category: general [glöplog]
 
Seems like an obvious question to me, yet I can't find the answer anywhere...how is this done? I just want my .prg to run when loaded, without typing "sys2304" or whatever.

I'm using C64Asm until I can get my hands on a real C64.
added on the 2009-06-17 12:34:49 by ferris ferris
You need a basic header/stub (that displays f.e. "10 sys2304" after loading and listing). Just google for a code snippet or ask at csdb and/or look at some demo/game source, f.e. here.
added on the 2009-06-17 13:07:48 by tomaes tomaes
Jake: Right after you left MSN I actually did find something :). Come and get it.
added on the 2009-06-17 13:16:15 by decipher decipher
also you can just feed your binary into a cross-tool cruncher like exomizer, which will reduce size&add sys line.
added on the 2009-06-17 13:58:43 by Oswald Oswald
what has happened to good old sledgehammer2 ? ;)
added on the 2009-06-17 16:57:27 by kb_ kb_
pucrunch is a good alternative to exomizer when doing crossdev; it accepts files without load address and is very fast.
added on the 2009-06-17 19:16:56 by Radiant Radiant
Cool, already had exomizer, had'nt tried it yet..thanks :)
added on the 2009-06-17 23:07:42 by ferris ferris
..And I had thought of the BASIC stub thing, but what tools would I use to create said stub .prg and make it execute when loaded? Should it be at a certain address (like "10" in Tomaes' example), and how could I cross-develop the .prg?
added on the 2009-06-17 23:22:09 by ferris ferris
Just add something like this to your ASM-program:

* = $0801
.byte $0c,$08,$0a,$00,$9e,$20,$32,$33,$30,$34,$00,$00,$00

That is the bytes for a basic '10 sys 2304' line

Otherwise most modern cross-assemblers have a built in macro that does this, for example Kick Assembler which I use (and recommend!), you simply do like this:

Code: .pc =$0801 :BasicUpstart($0810) .pc = $0810 "Code" (rest of code here)
added on the 2009-06-17 23:30:26 by Sdw Sdw
eh, the code tag doesn't like the '$'-characters it seems like, the second example should be like this:

.pc =$0801
:BasicUpstart($0810)

.pc = $0810 "Code"
(rest of code here]
added on the 2009-06-17 23:31:35 by Sdw Sdw
thanks Sdw :D Works perfectly.

One question, how did you get those bytes exactly? did you create a BASIC V2 prog, save it, and take those from a hex editor? I understand the BASIC address being where it is, just not how you got those bytes.
added on the 2009-06-17 23:35:18 by ferris ferris
I just typed in "10 sys 2304" in VICE, then entered the monitor (alt-m) and did a hex dump from $0801 and forward (enter ''m 0801" in the monitor)
added on the 2009-06-17 23:55:18 by Sdw Sdw
oh ok :) perfect, thanks.
added on the 2009-06-18 03:56:27 by ferris ferris
This is how I do it using ACME

BASIC_START = $0801
CODE_START = $080d

* = BASIC_START
!byte 12,8,0,0,158
!if CODE_START >= 10000 {!byte 48+((CODE_START/10000)%10)}
!if CODE_START >= 1000 {!byte 48+((CODE_START/1000)%10)}
!if CODE_START >= 100 {!byte 48+((CODE_START/100)%10)}
!if CODE_START >= 10 {!byte 48+((CODE_START/10)%10)}
!byte 48+(CODE_START % 10),0,0,0

* = CODE_START
; start of the main routine

You can change CODE_START to any address and basic autorun will be automatically generated.

Detailed info: First byte (12=$0c) represents the length of the basic code. If the number next to SYS command is a 4 digit number beween 1000-9999 it should be 11 ($0b) instead of 12. But since it works like this with both 4 and 5 digit number, we can forget about perfection.
added on the 2009-06-18 09:53:37 by Skate Skate
imho using a cross packer is better for two reasons:

- no need to fuck around to get the start addy
- the unpacked binary can use almost all 64k (unless vice's autostart featured doesnt support that, I dont know, but the built in loader can not load over $d000)
added on the 2009-06-18 14:06:19 by Oswald Oswald
one more: the final binary will have to be packed anyway ;)
added on the 2009-06-18 14:06:48 by Oswald Oswald
test test:
Code:$0810
added on the 2009-06-18 14:07:55 by Gargaj Gargaj
...ok that's weird
added on the 2009-06-18 14:08:02 by Gargaj Gargaj
Here is an excerpt from a tutorial i once wrote:

----
We do want a basic-header, and writing them in assembly is just plain ugly.

This is our basic-header,called basicheader.bas:

2004 sys32768

You need VICE's petcat to produce an Object:

petcat -w2 <basicheader.bas >basicheader.obj
----
The Tutorial then continues to describe how to use Makefile to automatically generate the basic stub

http://k2devel.sourceforge.net/doc_k2asm.html#example_3
there, fixed it for ya.
added on the 2009-06-18 14:22:44 by Gargaj Gargaj

login

Go to top