From 1681e619563bb92880a9bdd7a8bb5bc2f150f5e6 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Mon, 12 Oct 2020 21:11:46 -0400 Subject: [PATCH] emul/sms: don't hardcode name table offset Use reg 2 as specified. --- emul/hw/sms/vdp.c | 3 ++- recipes/sms/blk/605 | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/emul/hw/sms/vdp.c b/emul/hw/sms/vdp.c index a92c3ba..ef71bae 100644 --- a/emul/hw/sms/vdp.c +++ b/emul/hw/sms/vdp.c @@ -61,7 +61,8 @@ uint8_t vdp_pixel(VDP *vdp, uint16_t x, uint16_t y) return 0; } // name table offset - uint16_t offset = 0x3800 + ((y/8) << 6) + ((x/8) << 1); + uint16_t offset = (vdp->regs[2] & 0xe) << 10; + offset += ((y/8) << 6) + ((x/8) << 1); uint16_t tableval = vdp->vram[offset] + (vdp->vram[offset+1] << 8); uint16_t tilenum = tableval & 0x1ff; // is palette select bit on? if yes, use sprite palette instead diff --git a/recipes/sms/blk/605 b/recipes/sms/blk/605 index 70e9aee..b85436c 100644 --- a/recipes/sms/blk/605 +++ b/recipes/sms/blk/605 @@ -1,7 +1,7 @@ CREATE _idat 0b00000100 C, 0x80 C, ( Bit 2: Select mode 4 ) 0b00000000 C, 0x81 C, -0b11111111 C, 0x82 C, ( Name table: 0x3800 ) +0b00001110 C, 0x82 C, ( Name table: 0x3800 ) 0b11111111 C, 0x85 C, ( Sprite table: 0x3f00 ) 0b11111111 C, 0x86 C, ( sprite use tiles from 0x2000 ) 0b11111111 C, 0x87 C, ( Border uses palette 0xf )