gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit 96f4b2c7f77cb9f464dbd6e893ace645f6a11c3f parent ceb9681fba8340505365d0a8ab6f0409732d3400 Author: Toxa <untoxa@mail.ru> Date: Mon, 25 Mar 2024 14:30:59 +0300 SMS/GG/MSX DIV_REG emulation for the Z80 systems, may be useful for seeding RNG Diffstat:
| M | gbdk-lib/include/msx/msx.h | 9 | +++++++++ |
| M | gbdk-lib/include/sms/sms.h | 10 | ++++++++++ |
| A | gbdk-lib/libc/targets/z80/get_r_reg.s | 10 | ++++++++++ |
| M | gbdk-lib/libc/targets/z80/gg/Makefile | 2 | +- |
| M | gbdk-lib/libc/targets/z80/msxdos/Makefile | 2 | +- |
| M | gbdk-lib/libc/targets/z80/sms/Makefile | 2 | +- |
6 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/gbdk-lib/include/msx/msx.h b/gbdk-lib/include/msx/msx.h @@ -315,6 +315,15 @@ void refresh_OAM(void); */ extern volatile uint16_t sys_time; +/** Return R register for the DIV_REG emulation + + Increments once per CPU instruction (fetches the Z80 CPU R register) + +*/ +uint8_t get_r_reg(void) PRESERVES_REGS(b, c, d, e, h, l, iyh, iyl); + +#define DIV_REG get_r_reg() + /** Tracks current active ROM bank in frame 1 */ extern volatile uint8_t _current_bank; diff --git a/gbdk-lib/include/sms/sms.h b/gbdk-lib/include/sms/sms.h @@ -322,6 +322,16 @@ void refresh_OAM(void); */ extern volatile uint16_t sys_time; + +/** Return R register for the DIV_REG emulation + + Increments once per CPU instruction (fetches the Z80 CPU R register) + +*/ +uint8_t get_r_reg(void) PRESERVES_REGS(b, c, d, e, h, l, iyh, iyl); + +#define DIV_REG get_r_reg() + /** Tracks current active ROM bank in frame 1 */ #define _current_bank MAP_FRAME1 diff --git a/gbdk-lib/libc/targets/z80/get_r_reg.s b/gbdk-lib/libc/targets/z80/get_r_reg.s @@ -0,0 +1,10 @@ + .include "global.s" + + .title "DIV_REG emulation" + .module DIV_REG_emu + + .area _HOME + +_get_r_reg:: + LD A, R + RET diff --git a/gbdk-lib/libc/targets/z80/gg/Makefile b/gbdk-lib/libc/targets/z80/gg/Makefile @@ -24,7 +24,7 @@ ASSRC = set_interrupts.s \ palette.s set_palette.s \ pad.s pad_ex.s \ sms_int.s nmi.s \ - mode.s clock.s \ + mode.s clock.s get_r_reg.s \ delay.s \ emu_debug_printf.s \ memset_small.s \ diff --git a/gbdk-lib/libc/targets/z80/msxdos/Makefile b/gbdk-lib/libc/targets/z80/msxdos/Makefile @@ -18,7 +18,7 @@ ASSRC = set_interrupts.s \ msx_metasprites.s msx_metasprites_hide.s msx_metasprites_hide_spr.s \ pad.s \ msx_int.s \ - mode.s clock.s \ + mode.s clock.s get_r_reg.s \ delay.s \ memset_small.s \ far_ptr.s \ diff --git a/gbdk-lib/libc/targets/z80/sms/Makefile b/gbdk-lib/libc/targets/z80/sms/Makefile @@ -24,7 +24,7 @@ ASSRC = set_interrupts.s \ palette.s set_palette.s \ pad.s pad_ex.s \ sms_int.s nmi.s \ - mode.s clock.s \ + mode.s clock.s get_r_reg.s \ delay.s \ emu_debug_printf.s \ memset_small.s \
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.