From 703ab56587aac0d79ccc0f72f2b8d9ee235e20a5 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Mon, 27 May 2024 23:24:19 +0100 Subject: Use SDCC's new calling convention (this is an ABI breaking change, and will require changes to user-written asm functions or their declarations) --- src/ubox/ubox_fill_screen.z80 | 2 -- src/ubox/ubox_get_tile.z80 | 14 +++----------- src/ubox/ubox_get_vsync_freq.z80 | 3 +-- src/ubox/ubox_isr.z80 | 1 - src/ubox/ubox_put_tile.z80 | 14 +++++++------- src/ubox/ubox_read_ctl.z80 | 5 +---- src/ubox/ubox_read_keys.z80 | 2 -- src/ubox/ubox_read_vm.z80 | 22 ++++++++++++---------- src/ubox/ubox_select_ctl.z80 | 4 ++-- src/ubox/ubox_set_colors.z80 | 16 ++++++++-------- src/ubox/ubox_set_mode.z80 | 2 -- src/ubox/ubox_set_sprite_attr.z80 | 22 +++++++++------------- src/ubox/ubox_set_sprite_pat16.z80 | 21 ++++++++------------- src/ubox/ubox_set_sprite_pat16_flip.z80 | 13 ++++++------- src/ubox/ubox_set_sprite_pat8.z80 | 21 ++++++++------------- src/ubox/ubox_set_sprite_pat8_flip.z80 | 14 +++++++------- src/ubox/ubox_set_tiles.z80 | 1 - src/ubox/ubox_set_tiles_colors.z80 | 1 - src/ubox/ubox_wait_for.z80 | 3 +-- src/ubox/ubox_write_vm.z80 | 22 ++++++++++++---------- src/ubox/ubox_wvdp.z80 | 12 +++--------- 21 files changed, 88 insertions(+), 127 deletions(-) (limited to 'src/ubox') 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 -- cgit v1.2.3