gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit c62e9f89c0ba5d622c23577143f689d2e9937c68 parent 78bdae13c89a41850ad8fb2e9d137bfbc4ef58f3 Author: Toxa <untoxa@mail.ru> Date: Wed, 22 Feb 2023 19:45:59 +0300 minor optimization of to_far_ptr() Diffstat:
| M | gbdk-lib/include/gbdk/far_ptr.h | 2 | +- |
| M | gbdk-lib/libc/targets/sm83/far_ptr.s | 68 | +++++++++++++++++++++++++++++++++----------------------------------- |
| M | gbdk-lib/libc/targets/z80/far_ptr.s | 15 | +++++---------- |
3 files changed, 39 insertions(+), 46 deletions(-)
diff --git a/gbdk-lib/include/gbdk/far_ptr.h b/gbdk-lib/include/gbdk/far_ptr.h @@ -94,6 +94,6 @@ void __call__banked(void); @returns A far pointer (type @ref FAR_PTR) */ -uint32_t to_far_ptr(void* ofs, uint16_t seg) OLDCALL; +uint32_t to_far_ptr(void* ofs, uint16_t seg); #endif diff --git a/gbdk-lib/libc/targets/sm83/far_ptr.s b/gbdk-lib/libc/targets/sm83/far_ptr.s @@ -13,7 +13,7 @@ ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; -; You should have received a copy of the GNU General Public License +; You should have received a copy of the GNU General Public License ; along with this library; see the file COPYING. If not, write to the ; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, ; MA 02110-1301, USA. @@ -26,46 +26,44 @@ ; might be covered by the GNU General Public License. ;-------------------------------------------------------------------------- - .module far_ptr + .module far_ptr + + .include "global.s" + + .area _HOME - .include "global.s" - - .area _HOME - ___call__banked:: - ldh A, (#__current_bank) - push AF - ld HL, #1$ - push HL - ld HL, #___call_banked_addr - ld A, (HL+) - ld H, (HL) - ld L, A - ld A, (#___call_banked_bank) - ldh (#__current_bank), A - ld (.MBC_ROM_PAGE),A - jp (HL) + ldh A, (#__current_bank) + push AF + ld HL, #1$ + push HL + ld HL, #___call_banked_addr + ld A, (HL+) + ld H, (HL) + ld L, A + ld A, (#___call_banked_bank) + ldh (#__current_bank), A + ld (.MBC_ROM_PAGE),A + jp (HL) 1$: - pop AF - ldh (#__current_bank), A - ld (.MBC1_ROM_PAGE), A - ret + pop AF + ldh (#__current_bank), A + ld (.MBC1_ROM_PAGE), A + ret _to_far_ptr:: - lda HL, 2(SP) - ld A, (HL+) - ld E, A - ld A, (HL+) - ld D, A - ld A, (HL+) - ld H, (HL) - ld L, A - ret + ld a, c + ld c, e + ld e, a + ld a, b + ld b, d + ld d, a + ret + + .area _DATA - .area _DATA - ___call_banked_ptr:: ___call_banked_addr:: - .ds 0x02 ; far pointer offset + .ds 0x02 ; far pointer offset ___call_banked_bank:: - .ds 0x02 ; far pointer segment + .ds 0x02 ; far pointer segment diff --git a/gbdk-lib/libc/targets/z80/far_ptr.s b/gbdk-lib/libc/targets/z80/far_ptr.s @@ -13,7 +13,7 @@ ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; -; You should have received a copy of the GNU General Public License +; You should have received a copy of the GNU General Public License ; along with this library; see the file COPYING. If not, write to the ; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, ; MA 02110-1301, USA. @@ -29,9 +29,9 @@ .module far_ptr .include "global.s" - + .area _HOME - + ___call__banked:: ld a, (#.MAP_FRAME1) @@ -47,16 +47,11 @@ ___call__banked:: ret _to_far_ptr:: - pop bc - pop hl - pop de - push de - push hl - push bc + ex de, hl ret .area _DATA - + ___call_banked_ptr:: ___call_banked_addr:: .ds 0x02 ; far pointer offset
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.