aboutsummaryrefslogtreecommitdiff
path: root/src/crt0.s
diff options
context:
space:
mode:
Diffstat (limited to 'src/crt0.s')
-rw-r--r--src/crt0.s41
1 files changed, 39 insertions, 2 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