aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2026-04-08 09:11:15 -0400
committerB. Watson <urchlay@slackware.uk>2026-04-08 09:11:15 -0400
commitae2bd7b13946eafee72a953d55b70e3bc1cdb5be (patch)
tree8392830be37ab05aca10f050f494512f4f242ef7 /src
parent8227a82f78bb27bbcbe5a241ec5b51de799b12bc (diff)
downloadfujinet-chat-ae2bd7b13946eafee72a953d55b70e3bc1cdb5be.tar.gz
Use custom ctr0.s that doesn't have all the contructor/destructor and clean-edit setup overhead.
Diffstat (limited to 'src')
-rw-r--r--src/crt0.s62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/crt0.s b/src/crt0.s
new file mode 100644
index 0000000..6ffb2ce
--- /dev/null
+++ b/src/crt0.s
@@ -0,0 +1,62 @@
+;
+; Startup code for cc65 (ATARI version)
+;
+; Contributing authors:
+; Mark Keates
+; Freddy Offenga
+; Christian Groessler
+; Stefan Haubenthal
+;
+
+; Hacked up, trimmed down version for fnchat.
+
+ .export __STARTUP__ : absolute = 1 ; Mark as startup
+ .export _exit, start
+
+ .import _main, zerobss
+ .import __RESERVED_MEMORY__
+ .import __MAIN_START__, __MAIN_SIZE__
+ .import __LOWCODE_RUN__, __LOWCODE_SIZE__
+ .include "zeropage.inc"
+ .include "atari.inc"
+
+; ------------------------------------------------------------------------
+
+.segment "STARTUP"
+ _exit = WARMSV ; nothing should be calling exit() anyway.
+
+ rts ; fix for SpartaDOS / OS/A+
+ ; They first call the entry point from AUTOSTRT; and
+ ; then, the load address (this rts here).
+ ; We point AUTOSTRT directly after the rts.
+
+; Real entry point:
+
+start:
+
+; Clear the BSS data.
+ jsr zerobss
+
+; Set up the stack
+ lda MEMTOP
+ sta sp
+ lda MEMTOP+1
+ sta sp+1
+
+; Set the keyboard to upper-/lower-case mode.
+ ldy #0
+ sty SHFLOK
+ dey ; Set Y to $FF
+ sty CH ; remove keypress which might be in the input buffer
+
+; Go directly to main(). No support for CLI arguments, no saving
+; any machine state for a clean exit, because we don't exit.
+ jmp _main
+
+; ------------------------------------------------------------------------
+
+.segment "LOWCODE" ; have at least one (empty) segment of LOWCODE, so that the next line works even if the program doesn't make use of this segment
+.assert (__LOWCODE_RUN__ + __LOWCODE_SIZE__ <= $4000 || __LOWCODE_RUN__ > $7FFF || __LOWCODE_SIZE__ = 0), warning, "'lowcode area' reaches into $4000..$7FFF bank memory window"
+; check for LOWBSS_SIZE = 0 not needed since the only file which uses LOWBSS (irq.s) also uses LOWCODE
+; check for LOWCODE_RUN > $7FFF is mostly for cartridges, where this segment is loaded high (into cart ROM)
+; there is a small chance that if the user loads the program really high, LOWCODE is above $7FFF, but LOWBSS is below -- no warning emitted in this case