Make CPC version run from ROM
This frees up an extra 11K of RAM for apps.
It is still slightly broken: glitches during start of the ROM, and the
desktop icons are somehow missing. I don't know why yet...
diff --git a/contiki-cpc/arch/crt0.s b/contiki-cpc/arch/crt0.s
index da8bf56..325ef30 100644
--- a/contiki-cpc/arch/crt0.s
+++ b/contiki-cpc/arch/crt0.s
@@ -7,43 +7,44 @@
.module crt0
.globl _main
.globl _progend
- .area _HEADER (ABS)
+
;; Ordering of segments for the linker.
- .area _CODE
-init:
-; This is the program entry point. Execution starts here
-;; Initialise global variables, clear BSS areas, initialize AMSDOS and setup heap.
- call gsinit
-; Enter the C main.
- call _main
-
-_exit::
- rst #0
-
- .area _HOME
- .area _CODE
+ ; Things that go in RAM
.area _INITIALIZED
.area _DATA
- .area _BSEG
- .area _BSS (REL)
- .area _HEAP (REL)
+ .area _BSS
+ .area _HEAP
_progend::
- ; NOTE - THE IS NOT ROM-FRIENDLY!
- ; We put the initializers for initialized data in the memory that will later
- ; be used for the heap. The gsinit copies it back to the CODE area above.
- ; Then, we can overwrite the now unused initializers with the heap.
- ; In the case of software actually running from ROM, the initializer section
- ; would be in ROM, and GSINIT would copy it to RAM. Of course in that case,
- ; The initializer space can't be reclaimed for the heap...
- .area _INITIALIZER
- .area _GSINIT (REL)
- .area _GSFINAL (REL)
-
-; -----------------------------------------------------------------------------
- .area _GSINIT (REL)
-gsinit::
+ ;; Things that go in ROM
+ .area _HOME
+ .area _CODE (REL,CON)
+ .area _INITIALIZER (REL,CON)
+ .area _GSINIT (REL,CON)
+ .area _GSFINAL (REL,CON)
+
+ .area _CODE (REL,CON)
+
+ .db #1 ; Background ROM
+ .db #1 ; Version 1.4
+ .db #4
+ .db #0
+ .dw rsx_table
+
+ jp do_nothing
+ jp init
+
+rsx_table:
+
+ .db 'K' + #0x80
+ .ascii "CONTIK"
+ .db 'I' + #0x80
+ .db #0
+
+init:
+; This is the program entry point. Execution starts here
+;; Initialise global variables, clear BSS areas, initialize AMSDOS and setup heap.
ld bc, #l__INITIALIZER
ld a, b
or a, c
@@ -56,7 +57,7 @@
ld hl,#s__DATA
ld (hl),#0
ld de,#s__DATA + #1
- ld bc,#l__DATA
+ ld bc,#s__DATA + #0x200
ldir
; Initialize disk ROM
@@ -65,6 +66,18 @@
ld c,#7
call 0xbcce
- .area _GSFINAL
- ; After the ROMs are initialized, initialize the heap.
- jp __sdcc_heap_init
+ ; Init the heap. Do it after the disk ROM is ready, because that may change HIMEM
+ call __sdcc_heap_init
+; Enter the C main.
+ jp _main
+
+do_nothing:
+ LD A, #'K'
+ CALL #0xBB5A
+ scf
+ ret
+
+_exit::
+ rst #0
+
+; -----------------------------------------------------------------------------