summaryrefslogtreecommitdiff
path: root/game/src/crt0.z80
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2020-12-30 19:07:31 +0000
committerJuan J. Martinez <jjm@usebox.net>2020-12-30 19:23:41 +0000
commit2682bc5d1d864341aaeb42a449db73c3ecd16d70 (patch)
tree9116764364b4ee0ce7f6037305077807b57776de /game/src/crt0.z80
downloadubox-msx-lib-2682bc5d1d864341aaeb42a449db73c3ecd16d70.tar.gz
ubox-msx-lib-2682bc5d1d864341aaeb42a449db73c3ecd16d70.zip
Initial import1.0
Diffstat (limited to 'game/src/crt0.z80')
-rw-r--r--game/src/crt0.z8082
1 files changed, 82 insertions, 0 deletions
diff --git a/game/src/crt0.z80 b/game/src/crt0.z80
new file mode 100644
index 0000000..81763d0
--- /dev/null
+++ b/game/src/crt0.z80
@@ -0,0 +1,82 @@
+.module crt0
+.globl _main
+
+.area _HOME
+.area _CODE
+.area _INITIALIZER
+.area _GSINIT
+.area _GSFINAL
+
+.area _DATA
+.area _INITIALIZED
+.area _BSEG
+.area _BSS
+.area _HEAP
+
+.area _CODE
+
+ENASLT = 0x0024
+RSLREG = 0x0138
+CLIKSW = 0xf3db
+
+ ; ROM header
+ .str "AB"
+ .dw _main_init
+ .db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+
+_main_init::
+
+ ; init the stack
+ di
+ ld sp, #0xf380
+ ei
+
+ ; setup memory
+ ; ref: https://www.msx.org/forum/msx-talk/development/memory-pages-again
+
+ call RSLREG
+ rrca
+ rrca
+ and #3
+ ld c, a
+ add a, #0xc1
+ ld l, a
+ ld h, #0xfc
+ ld a, (hl)
+ and #0x80
+ or c
+ ld c, a
+ inc l
+ inc l
+ inc l
+ inc l
+ ld a, (hl)
+ and #0x0c
+ or c
+ ld h, #0x80
+ call ENASLT
+
+ ; disable key click sound
+ xor a
+ ld (CLIKSW), a
+
+ call gsinit
+ call _main
+
+halt0:
+ halt
+ jr halt0
+
+.area _GSINIT
+gsinit::
+ ld bc, #l__INITIALIZER
+ ld a, b
+ or a, c
+ jr Z, gsinit_next
+ ld de, #s__INITIALIZED
+ ld hl, #s__INITIALIZER
+ ldir
+gsinit_next:
+
+.area _GSFINAL
+ ret