aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2024-05-27 23:24:19 +0100
committerJuan J. Martinez <jjm@usebox.net>2024-05-27 23:24:19 +0100
commit703ab56587aac0d79ccc0f72f2b8d9ee235e20a5 (patch)
tree32b186dc14c56fe19c004a403eeaaf7e2dd0b10f /src
parent420ac2c8f2307ddcbe551972544bbe11f05ee7ff (diff)
downloadubox-msx-lib-703ab56587aac0d79ccc0f72f2b8d9ee235e20a5.tar.gz
ubox-msx-lib-703ab56587aac0d79ccc0f72f2b8d9ee235e20a5.zip
Use SDCC's new calling convention
(this is an ABI breaking change, and will require changes to user-written asm functions or their declarations)
Diffstat (limited to 'src')
-rw-r--r--src/ap/ap.z8012
-rw-r--r--src/mplayer/akm/akm_ubox.asm5
-rw-r--r--src/mplayer/mplayer_init.z809
-rw-r--r--src/mplayer/mplayer_play_effect.z8017
-rw-r--r--src/mplayer/mplayer_play_effect_p.z8041
-rw-r--r--src/mplayer/mplayer_stop_effect_channel.z802
-rw-r--r--src/ubox/ubox_fill_screen.z802
-rw-r--r--src/ubox/ubox_get_tile.z8014
-rw-r--r--src/ubox/ubox_get_vsync_freq.z803
-rw-r--r--src/ubox/ubox_isr.z801
-rw-r--r--src/ubox/ubox_put_tile.z8014
-rw-r--r--src/ubox/ubox_read_ctl.z805
-rw-r--r--src/ubox/ubox_read_keys.z802
-rw-r--r--src/ubox/ubox_read_vm.z8022
-rw-r--r--src/ubox/ubox_select_ctl.z804
-rw-r--r--src/ubox/ubox_set_colors.z8016
-rw-r--r--src/ubox/ubox_set_mode.z802
-rw-r--r--src/ubox/ubox_set_sprite_attr.z8022
-rw-r--r--src/ubox/ubox_set_sprite_pat16.z8021
-rw-r--r--src/ubox/ubox_set_sprite_pat16_flip.z8013
-rw-r--r--src/ubox/ubox_set_sprite_pat8.z8021
-rw-r--r--src/ubox/ubox_set_sprite_pat8_flip.z8014
-rw-r--r--src/ubox/ubox_set_tiles.z801
-rw-r--r--src/ubox/ubox_set_tiles_colors.z801
-rw-r--r--src/ubox/ubox_wait_for.z803
-rw-r--r--src/ubox/ubox_write_vm.z8022
-rw-r--r--src/ubox/ubox_wvdp.z8012
27 files changed, 123 insertions, 178 deletions
diff --git a/src/ap/ap.z80 b/src/ap/ap.z80
index b968853..882c75e 100644
--- a/src/ap/ap.z80
+++ b/src/ap/ap.z80
@@ -18,16 +18,7 @@
.ez80
_ap_uncompress::
- ld hl, #2
- add hl, sp
- ld e, (hl)
- inc hl
- ld d, (hl)
- inc hl
- ld a, (hl)
- inc hl
- ld h, (hl)
- ld l, a
+ ex de, hl
ap_uncompress::
ld ixl, #128
@@ -154,4 +145,3 @@ ap_getgammaloop:
call ap_getbit
jr c, ap_getgammaloop
ret
-
diff --git a/src/mplayer/akm/akm_ubox.asm b/src/mplayer/akm/akm_ubox.asm
index cbbf8af..39aef74 100644
--- a/src/mplayer/akm/akm_ubox.asm
+++ b/src/mplayer/akm/akm_ubox.asm
@@ -7,11 +7,10 @@ PLY_AKM_ROM_Buffer = #c000
include "PlayerAkm.asm"
-; IN: L = channel
+; IN: a = channel
; OUT: L = 0 if is not on
PLY_AKM_IsSoundEffectOnDisarkGenerateExternalLabel:
PLY_AKM_IsSoundEffectOn:
- ld a,l
add a,a
add a,a
add a,a
@@ -22,6 +21,4 @@ PLY_AKM_IsSoundEffectOn:
ld a,(hl)
inc hl
or (hl)
- ld l,a
ret
-
diff --git a/src/mplayer/mplayer_init.z80 b/src/mplayer/mplayer_init.z80
index 90b3824..ee922ca 100644
--- a/src/mplayer/mplayer_init.z80
+++ b/src/mplayer/mplayer_init.z80
@@ -5,13 +5,12 @@
_mplayer_init::
ld ix, #2
add ix, sp
-
- ld l, 0 (ix)
- ld h, 1 (ix)
- ld a, 2 (ix)
+ ld a, 0 (ix)
di
call _PLY_AKM_INIT
ei
- ret
+ pop hl
+ inc sp
+ jp (hl)
diff --git a/src/mplayer/mplayer_play_effect.z80 b/src/mplayer/mplayer_play_effect.z80
index adf41b9..e2a233f 100644
--- a/src/mplayer/mplayer_play_effect.z80
+++ b/src/mplayer/mplayer_play_effect.z80
@@ -5,14 +5,13 @@
.globl _PLY_AKM_PLAYSOUNDEFFECT
_mplayer_play_effect::
- ld hl, #2
- add hl, sp
+ ld c, l
+ ld ix, #2
+ add ix, sp
+ ld b, 0 (ix)
- ld a, (hl)
- inc hl
- ld c, (hl)
- inc hl
- ld b, (hl)
-
- jp _PLY_AKM_PLAYSOUNDEFFECT
+ call _PLY_AKM_PLAYSOUNDEFFECT
+ pop hl
+ inc sp
+ jp (hl)
diff --git a/src/mplayer/mplayer_play_effect_p.z80 b/src/mplayer/mplayer_play_effect_p.z80
index 8efd705..9e428cd 100644
--- a/src/mplayer/mplayer_play_effect_p.z80
+++ b/src/mplayer/mplayer_play_effect_p.z80
@@ -7,39 +7,40 @@
.globl _PLY_AKM_PLAYSOUNDEFFECT
_mplayer_play_effect_p::
+ ld e, a
+ ld c, l
+
ld hl, #2
add hl, sp
+ ld b, (hl)
- ld e, (hl)
- inc hl
- ld c, (hl)
- inc hl
- ld b, (hl)
-
- ; e effect no
- ; bc: channel and volume
- push bc
- push de
- ld l, c
- call _mplayer_is_sound_effect_on
+ ; e effect no
+ ; bc: channel and volume
+ push bc
+ push de
+ ld a, c
+ call _mplayer_is_sound_effect_on
- ld a, l
or a
- pop de
- pop bc
+ pop de
+ pop bc
jr z, play_efx
ld a, (mplayer_current_efx)
- ; comment out following line if you don't want to
- ; replace current sound if is the same effect type
- dec a
+ ; comment out following line if you don't want to
+ ; replace current sound if is the same effect type
+ dec a
cp e
- ret nc
+ jp nc, play_exit
play_efx:
; all good, play the effect
ld a, e
ld (mplayer_current_efx), a
- jp _PLY_AKM_PLAYSOUNDEFFECT
+ call _PLY_AKM_PLAYSOUNDEFFECT
+play_exit:
+ pop hl
+ inc sp
+ jp (hl)
diff --git a/src/mplayer/mplayer_stop_effect_channel.z80 b/src/mplayer/mplayer_stop_effect_channel.z80
index 82eb5d7..2b03954 100644
--- a/src/mplayer/mplayer_stop_effect_channel.z80
+++ b/src/mplayer/mplayer_stop_effect_channel.z80
@@ -5,6 +5,4 @@
.globl _PLY_AKM_STOPSOUNDEFFECTFROMCHANNEL
_mplayer_stop_effect_channel::
- ld a, l
jp _PLY_AKM_STOPSOUNDEFFECTFROMCHANNEL
-
diff --git a/src/ubox/ubox_fill_screen.z80 b/src/ubox/ubox_fill_screen.z80
index e803f76..f07218c 100644
--- a/src/ubox/ubox_fill_screen.z80
+++ b/src/ubox/ubox_fill_screen.z80
@@ -4,8 +4,6 @@ FILVRM = 0x0056
BG_TILE_MAP = 0x1800
_ubox_fill_screen::
- ld a, l
ld hl, #BG_TILE_MAP
ld bc, #768
jp FILVRM
-
diff --git a/src/ubox/ubox_get_tile.z80 b/src/ubox/ubox_get_tile.z80
index 3a6004d..9ea9b7b 100644
--- a/src/ubox/ubox_get_tile.z80
+++ b/src/ubox/ubox_get_tile.z80
@@ -4,13 +4,8 @@ RDVRM = 0x004a
BG_TILE_MAP = 0x1800
_ubox_get_tile::
- ld hl, #2
- add hl, sp
-
- ld b, #0
- ld c, (hl)
- inc hl
- ld l, (hl)
+ ld b, l
+ ld c, a
ld h, #0
add hl, hl
@@ -23,7 +18,4 @@ _ubox_get_tile::
ld bc, #BG_TILE_MAP
add hl, bc
- call RDVRM
- ld l, a
- ret
-
+ jp RDVRM
diff --git a/src/ubox/ubox_get_vsync_freq.z80 b/src/ubox/ubox_get_vsync_freq.z80
index 681fe67..4a7f841 100644
--- a/src/ubox/ubox_get_vsync_freq.z80
+++ b/src/ubox/ubox_get_vsync_freq.z80
@@ -3,7 +3,6 @@
_ubox_get_vsync_freq::
ld a, (#0x002b)
and #128
- ld l, a
ret z
- ld l, #1
+ ld a, #1
ret
diff --git a/src/ubox/ubox_isr.z80 b/src/ubox/ubox_isr.z80
index f25e35d..b8a19fe 100644
--- a/src/ubox/ubox_isr.z80
+++ b/src/ubox/ubox_isr.z80
@@ -12,7 +12,6 @@ REPCNT = 0xf3f7
_ubox_init_isr::
di
- ld a, l
ld (ubox_isr_wait_ticks), a
xor a
ld (ubox_isr_wait_tick), a
diff --git a/src/ubox/ubox_put_tile.z80 b/src/ubox/ubox_put_tile.z80
index 24e58b2..718027d 100644
--- a/src/ubox/ubox_put_tile.z80
+++ b/src/ubox/ubox_put_tile.z80
@@ -4,14 +4,11 @@ WRTVRM = 0x004d
BG_TILE_MAP = 0x1800
_ubox_put_tile::
+ ld c, a
+ ld b, l
+
ld hl, #2
add hl, sp
-
- ld c, (hl)
- inc hl
- ld b, (hl)
- inc hl
-
ld a, (hl)
ld h, #0
@@ -27,5 +24,8 @@ _ubox_put_tile::
ld bc, #BG_TILE_MAP
add hl, bc
- jp WRTVRM
+ call WRTVRM
+ pop hl
+ inc sp
+ jp (hl)
diff --git a/src/ubox/ubox_read_ctl.z80 b/src/ubox/ubox_read_ctl.z80
index ae4fff9..d6f6a07 100644
--- a/src/ubox/ubox_read_ctl.z80
+++ b/src/ubox/ubox_read_ctl.z80
@@ -5,7 +5,6 @@ WRTPSG = 0x0093
SNSMAT = 0x0141
_ubox_read_ctl::
- ld a, l
or a
jr z, is_keyb
dec a
@@ -13,7 +12,7 @@ _ubox_read_ctl::
dec a
jr z, is_joy2
- ld l, #0
+ xor a
ret
is_joy2:
@@ -49,7 +48,6 @@ call_psg:
xor a
joy_extra_m:
or e
- ld l, a
ret
is_keyb:
@@ -96,5 +94,4 @@ is_keyb_dir:
or e
; added 2nd fire (M)
- ld l, a
ret
diff --git a/src/ubox/ubox_read_keys.z80 b/src/ubox/ubox_read_keys.z80
index d32f2de..a8889fd 100644
--- a/src/ubox/ubox_read_keys.z80
+++ b/src/ubox/ubox_read_keys.z80
@@ -3,8 +3,6 @@
SNSMAT = 0x0141
_ubox_read_keys::
- ld a, l
call SNSMAT
cpl
- ld l, a
ret
diff --git a/src/ubox/ubox_read_vm.z80 b/src/ubox/ubox_read_vm.z80
index 7ef0f41..78df980 100644
--- a/src/ubox/ubox_read_vm.z80
+++ b/src/ubox/ubox_read_vm.z80
@@ -3,21 +3,23 @@
LDIRMV = 0x0059
_ubox_read_vm::
+ ex de, hl
+ ; dst -> de
+ ; len -> hl
+ ld c, l
+ ld b, h
+ ; len -> bc
+
ld hl, #2
add hl, sp
-
- ld e, (hl)
- inc hl
- ld d, (hl)
- inc hl
- ld c, (hl)
- inc hl
- ld b, (hl)
- inc hl
ld a, (hl)
inc hl
ld h, (hl)
ld l, a
+ ; src -> hl
- jp LDIRMV
+ call LDIRMV
+ pop hl
+ pop bc
+ jp (hl)
diff --git a/src/ubox/ubox_select_ctl.z80 b/src/ubox/ubox_select_ctl.z80
index 9685bec..e313061 100644
--- a/src/ubox/ubox_select_ctl.z80
+++ b/src/ubox/ubox_select_ctl.z80
@@ -32,11 +32,11 @@ loop:
or a
jr nz, trigger_b
- ld l, #0xff
+ ld a, #0xff
ret
trigger_b:
dec b
trigger:
dec b
- ld l, b
+ ld a, b
ret
diff --git a/src/ubox/ubox_set_colors.z80 b/src/ubox/ubox_set_colors.z80
index 74a5b7f..4b89c99 100644
--- a/src/ubox/ubox_set_colors.z80
+++ b/src/ubox/ubox_set_colors.z80
@@ -6,17 +6,17 @@ BAKCLR = 0xf3ea
BDRCLR = 0xf3eb
_ubox_set_colors::
- ld hl, #2
- add hl, sp
-
- ld a, (hl)
- inc hl
ld (FORCLR), a
- ld a, (hl)
- inc hl
+ ld a, l
ld (BAKCLR), a
+
+ ld hl, #2
+ add hl, sp
ld a, (hl)
ld (BDRCLR), a
+
call CHGCLR
- ret
+ pop hl
+ inc sp
+ jp (hl)
diff --git a/src/ubox/ubox_set_mode.z80 b/src/ubox/ubox_set_mode.z80
index 4635d34..373a145 100644
--- a/src/ubox/ubox_set_mode.z80
+++ b/src/ubox/ubox_set_mode.z80
@@ -3,6 +3,4 @@
CHGMOD = 0x005f
_ubox_set_mode::
- ld a, l
jp CHGMOD
-
diff --git a/src/ubox/ubox_set_sprite_attr.z80 b/src/ubox/ubox_set_sprite_attr.z80
index 4e5c80e..ecf5952 100644
--- a/src/ubox/ubox_set_sprite_attr.z80
+++ b/src/ubox/ubox_set_sprite_attr.z80
@@ -4,14 +4,11 @@
SP_ATTRS = 0x1b00
_ubox_set_sprite_attr::
+ ld e, l
+ ld d, h
+
ld hl, #2
add hl, sp
-
- ld e, (hl)
- inc hl
- ld d, (hl)
- inc hl
-
ld l, (hl)
sla l
sla l
@@ -20,12 +17,11 @@ _ubox_set_sprite_attr::
add hl, bc
push de
- ld bc, #4
- push bc
- push hl
+ ld de, #4
+ ; hl: dst, de: len, stack: src
call _ubox_write_vm
- pop af
- pop af
- pop af
- ret
+
+ pop hl
+ inc sp
+ jp (hl)
diff --git a/src/ubox/ubox_set_sprite_pat16.z80 b/src/ubox/ubox_set_sprite_pat16.z80
index 59d7ccb..ee0f3c4 100644
--- a/src/ubox/ubox_set_sprite_pat16.z80
+++ b/src/ubox/ubox_set_sprite_pat16.z80
@@ -4,14 +4,11 @@
SP_PATTERNS = 0x3800
_ubox_set_sprite_pat16::
+ ld e, l
+ ld d, h
+
ld hl, #2
add hl, sp
-
- ld e, (hl)
- inc hl
- ld d, (hl)
- inc hl
-
ld l, (hl)
ld h, #0
add hl, hl
@@ -23,12 +20,10 @@ _ubox_set_sprite_pat16::
add hl, bc
push de
- ld bc, #32
- push bc
- push hl
+ ld de, #32
+ ; hl: dst, de: len, stack: src
call _ubox_write_vm
- pop af
- pop af
- pop af
- ret
+ pop hl
+ inc sp
+ jp (hl)
diff --git a/src/ubox/ubox_set_sprite_pat16_flip.z80 b/src/ubox/ubox_set_sprite_pat16_flip.z80
index 52f4ab7..7ac4077 100644
--- a/src/ubox/ubox_set_sprite_pat16_flip.z80
+++ b/src/ubox/ubox_set_sprite_pat16_flip.z80
@@ -4,14 +4,11 @@ WRTVRM = 0x004d
SP_PATTERNS = 0x3800
_ubox_set_sprite_pat16_flip::
+ ld e, l
+ ld d, h
+
ld hl, #2
add hl, sp
-
- ld e, (hl)
- inc hl
- ld d, (hl)
- inc hl
-
ld l, (hl)
ld h, #0
add hl, hl
@@ -32,7 +29,9 @@ _ubox_set_sprite_pat16_flip::
pop de
call flip
- ret
+ pop hl
+ inc sp
+ jp (hl)
flip:
ld b, #16
diff --git a/src/ubox/ubox_set_sprite_pat8.z80 b/src/ubox/ubox_set_sprite_pat8.z80
index 06b484c..c48588e 100644
--- a/src/ubox/ubox_set_sprite_pat8.z80
+++ b/src/ubox/ubox_set_sprite_pat8.z80
@@ -4,14 +4,11 @@
SP_PATTERNS = 0x3800
_ubox_set_sprite_pat8::
+ ld e, l
+ ld d, h
+
ld hl, #2
add hl, sp
-
- ld e, (hl)
- inc hl
- ld d, (hl)
- inc hl
-
ld l, (hl)
ld h, #0
add hl, hl
@@ -21,12 +18,10 @@ _ubox_set_sprite_pat8::
add hl, bc
push de
- ld bc, #8
- push bc
- push hl
+ ld de, #8
+ ; hl: dst, de: len, stack: src
call _ubox_write_vm
- pop af
- pop af
- pop af
- ret
+ pop hl
+ inc sp
+ jp (hl)
diff --git a/src/ubox/ubox_set_sprite_pat8_flip.z80 b/src/ubox/ubox_set_sprite_pat8_flip.z80
index b453253..64451e4 100644
--- a/src/ubox/ubox_set_sprite_pat8_flip.z80
+++ b/src/ubox/ubox_set_sprite_pat8_flip.z80
@@ -4,14 +4,11 @@ WRTVRM = 0x004d
SP_PATTERNS = 0x3800
_ubox_set_sprite_pat8_flip::
+ ld e, l
+ ld d, h
+
ld hl, #2
add hl, sp
-
- ld e, (hl)
- inc hl
- ld d, (hl)
- inc hl
-
ld l, (hl)
ld h, #0
add hl, hl
@@ -26,7 +23,10 @@ flip0:
inc hl
inc de
djnz flip0
- ret
+
+ pop hl
+ inc sp
+ jp (hl)
flip_and_copy:
ld a, (de)
diff --git a/src/ubox/ubox_set_tiles.z80 b/src/ubox/ubox_set_tiles.z80
index 7e4f42e..726eaae 100644
--- a/src/ubox/ubox_set_tiles.z80
+++ b/src/ubox/ubox_set_tiles.z80
@@ -19,4 +19,3 @@ _ubox_set_tiles::
ld de, #BG_TILES + #256 * 8 * 2
ld bc, #256 * 8
jp LDIRVM
-
diff --git a/src/ubox/ubox_set_tiles_colors.z80 b/src/ubox/ubox_set_tiles_colors.z80
index 4c4591b..6ca5d36 100644
--- a/src/ubox/ubox_set_tiles_colors.z80
+++ b/src/ubox/ubox_set_tiles_colors.z80
@@ -19,4 +19,3 @@ _ubox_set_tiles_colors::
ld de, #BG_COLS + 256 * 8 * 2
ld bc, #256 * 8
jp LDIRVM
-
diff --git a/src/ubox/ubox_wait_for.z80 b/src/ubox/ubox_wait_for.z80
index 5cc4649..f1984c8 100644
--- a/src/ubox/ubox_wait_for.z80
+++ b/src/ubox/ubox_wait_for.z80
@@ -4,11 +4,10 @@
.globl ubox_isr_wait_tick
_ubox_wait_for::
- ld b, l
+ ld b, a
wait_for_loop:
push bc
call _ubox_wait
pop bc
djnz wait_for_loop
ret
-
diff --git a/src/ubox/ubox_write_vm.z80 b/src/ubox/ubox_write_vm.z80
index 3d6606b..0daa7cc 100644
--- a/src/ubox/ubox_write_vm.z80
+++ b/src/ubox/ubox_write_vm.z80
@@ -3,21 +3,23 @@
LDIRVM = 0x005c
_ubox_write_vm::
+ ex de, hl
+ ; dst -> de
+ ; len -> hl
+ ld c, l
+ ld b, h
+ ; len -> bc
+
ld hl, #2
add hl, sp
-
- ld e, (hl)
- inc hl
- ld d, (hl)
- inc hl
- ld c, (hl)
- inc hl
- ld b, (hl)
- inc hl
ld a, (hl)
inc hl
ld h, (hl)
ld l, a
+ ; src -> hl
- jp LDIRVM
+ call LDIRVM
+ pop hl
+ pop af
+ jp (hl)
diff --git a/src/ubox/ubox_wvdp.z80 b/src/ubox/ubox_wvdp.z80
index 90dfc86..b185f57 100644
--- a/src/ubox/ubox_wvdp.z80
+++ b/src/ubox/ubox_wvdp.z80
@@ -3,12 +3,6 @@
WRITEVDP = 0x0047
_ubox_wvdp::
- ld hl, #2
- add hl, sp
-
- ld c, (hl)
- inc hl
- ld b, (hl)
- call WRITEVDP
- ret
-
+ ld c, a
+ ld b, l
+ jp WRITEVDP