; This must be the *second* file on the linker command line
; (.cvt header must be the *first* one)
-; Maciej 'YTM/Alliance' Witkowiak
-; 26.10.99, 10.3.2000
+; Maciej 'YTM/Elysium' Witkowiak
+; 26.10.99, 10.3.2000, 15.8.2001
; no __hinit
.export _exit
+ .import initlib, donelib
.import pushax
.import _main
- .import zerobss, doatexit
+ .import zerobss
; ------------------------------------------------------------------------
; Define and export the ZP variables for the C64 runtime
.reloc
; ------------------------------------------------------------------------
-; Actual code
+; Create an empty LOWCODE segment to avoid linker warnings
+
+.segment "LOWCODE"
+
+; ------------------------------------------------------------------------
+; Place the startup code in a special segment.
+
+.segment "STARTUP"
; Clear the BSS data
; Setup stack
- lda #<$7900
+ lda #<$6000
sta sp
- lda #>$7900
+ lda #>$6000
sta sp+1 ; Set argument stack ptr
-; Initialize the heap
+; Call module constructors
-;;! jsr __hinit
+ jsr initlib
; Pass an empty command line
jsr pushax ; argc
jsr pushax ; argv
+ cli
ldy #4 ; Argument size
jsr _main ; call the users code
jmp $c1c3 ; jump to GEOS MainLoop
-; exit must be called from the code!
+; Call module destructors. This is also the _exit entry which must be called
+; explicitly by the code.
+
+_exit: jsr donelib ; Run module destructors
-_exit:
- jsr doatexit ; call exit functions
+ jmp $c22c ; EnterDeskTop
- jmp $c22c ; EnterDeskTop