aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2026-04-13 06:24:18 -0400
committerB. Watson <urchlay@slackware.uk>2026-04-13 06:24:39 -0400
commit29b51c0dfdd27de76b489cd77ea70d25d9d74fdc (patch)
tree6c2055f0173de7eef0518d3f470c7bc084b312dd /src
parent46453088eec3947300b376cb1960a0c67b2252f0 (diff)
downloadfujinet-chat-29b51c0dfdd27de76b489cd77ea70d25d9d74fdc.tar.gz
Zero the BSS in the throwaway STARTUP segment. 7764 bytes free.
Diffstat (limited to 'src')
-rw-r--r--src/crt0.s41
-rw-r--r--src/main.c2
2 files changed, 39 insertions, 4 deletions
diff --git a/src/crt0.s b/src/crt0.s
index 44a1c93..564ca3d 100644
--- a/src/crt0.s
+++ b/src/crt0.s
@@ -13,10 +13,13 @@
.export __STARTUP__ : absolute = 1 ; Mark as startup
.export _exit, start
- .import _main, zerobss
+ .import _main; not any more: , zerobss
.import __RESERVED_MEMORY__
.import __MAIN_START__, __MAIN_SIZE__
.import __LOWCODE_RUN__, __LOWCODE_SIZE__
+ .import __BSS_RUN__, __BSS_SIZE__
+ .import _scr_init, _init_channels
+ .importzp ptr1
.include "zeropage.inc"
.include "atari.inc"
@@ -35,7 +38,36 @@
start:
; Clear the BSS data.
- jsr zerobss
+; This routine was copied from libsrc/common/zerobss.s.
+;zerobss:
+ lda #<__BSS_RUN__
+ sta ptr1
+ lda #>__BSS_RUN__
+ sta ptr1+1
+ lda #0
+ tay
+
+; Clear full pages
+
+L1: ldx #>__BSS_SIZE__
+ beq L3
+L2: sta (ptr1),y
+ iny
+ bne L2
+ inc ptr1+1
+ dex
+ bne L2
+
+; Clear remaining page (y is zero on entry)
+
+L3: cpy #<__BSS_SIZE__
+ beq L4
+ sta (ptr1),y
+ iny
+ bne L3
+
+L4:
+; Done clearing BSS.
; Set up the stack
lda MEMTOP
@@ -50,6 +82,11 @@ start:
sty SHFLOK ; Turn off Caps Lock
sty SOUNDR ; Turn off SIO beep/click
+; These 2 used to be called from main(). Moving the calls here saves 6 bytes.
+; Do not call _edbox_clear from here (we're *running* in the edbox area).
+ jsr _scr_init
+ jsr _init_channels
+
; 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
diff --git a/src/main.c b/src/main.c
index cfc9641..3b24182 100644
--- a/src/main.c
+++ b/src/main.c
@@ -132,8 +132,6 @@ void main(void) {
bell_type = config.alert_type; /* TODO: have bell.s read staight from the struct */
edbox_clear();
- scr_init();
- init_channels();
while(1) {
if(fn_connect()) {