From 63f03cd8245b7c13a564039124d9ee1a1fc9bf23 Mon Sep 17 00:00:00 2001 From: profi200 Date: Thu, 14 May 2020 16:27:11 +0200 Subject: [PATCH] Force LgyFb to insert 16 pixels of padding horizontally. Makes tiled output finally work. --- include/arm11/hardware/lgyfb.h | 4 ++-- source/arm11/hardware/lgyfb.c | 8 +++----- source/arm11/hardware/lgyfb.dma330 | 17 ++++------------- source/arm11/main.c | 2 +- 4 files changed, 10 insertions(+), 21 deletions(-) diff --git a/include/arm11/hardware/lgyfb.h b/include/arm11/hardware/lgyfb.h index cd23118..f9c7944 100644 --- a/include/arm11/hardware/lgyfb.h +++ b/include/arm11/hardware/lgyfb.h @@ -19,8 +19,8 @@ #define LGYFB_DMA_E (1u<<15) #define LGYFB_UNK (1u<<16) -// REG_LGYFB_SIZE -#define LGYFB_SIZE(v, h) (((v) - 1)<<16 | ((h) - 1)) +// REG_LGYFB_SIZE width and hight +#define LGYFB_SIZE(w, h) (((h) - 1)<<16 | ((w) - 1)) // REG_LGYFB_STAT and REG_LGYFB_IRQ #define LGYFB_IRQ_DMA_REQ (1u) diff --git a/source/arm11/hardware/lgyfb.c b/source/arm11/hardware/lgyfb.c index 7e58a7c..9cc832d 100644 --- a/source/arm11/hardware/lgyfb.c +++ b/source/arm11/hardware/lgyfb.c @@ -51,20 +51,18 @@ void LGYFB_init(void) { if(DMA330_run(0, program)) return; - REG_LGYFB_TOP_SIZE = LGYFB_SIZE(160u, 240u); + // Insert 16 pixels padding horizontally to fit the texture. + REG_LGYFB_TOP_SIZE = LGYFB_SIZE(256u, 160u); REG_LGYFB_TOP_STAT = LGYFB_IRQ_MASK; REG_LGYFB_TOP_IRQ = 0; REG_LGYFB_TOP_ALPHA = 0xFF; - REG_LGYFB_TOP_CNT = LGYFB_DMA_E /*| LGYFB_OUT_SWIZZLE*/ | LGYFB_OUT_FMT_5551 | LGYFB_ENABLE; + REG_LGYFB_TOP_CNT = LGYFB_DMA_E | LGYFB_OUT_SWIZZLE | LGYFB_OUT_FMT_5551 | LGYFB_ENABLE; IRQ_registerHandler(IRQ_CDMA_EVENT0, 13, 0, true, lgyFbDmaIrqHandler); } void rotateFrame(void) { - GX_displayTransfer((u32*)0x18400000, 160u<<16 | 256u, (u32*)0x18200000, 160u<<16 | 256u, 3u<<12 | 3u<<8 | 1u<<1); - GFX_waitForEvent(GFX_EVENT_PPF, false); - alignas(16) static const u8 firstList[1136] = { 0x01, 0x00, 0x00, 0x00, 0x10, 0x01, 0x0F, 0x00, 0x00, 0x00, 0x06, 0x03, diff --git a/source/arm11/hardware/lgyfb.dma330 b/source/arm11/hardware/lgyfb.dma330 index 37fb75f..61029bd 100644 --- a/source/arm11/hardware/lgyfb.dma330 +++ b/source/arm11/hardware/lgyfb.dma330 @@ -1,9 +1,9 @@ -# 8 bytes burst with 4 transfers. Total 32 bytes per burst. +# 8 bytes burst with 16 transfers. Total 128 bytes per burst. # Source fixed address and destination incrementing. # Source and destination unprivileged, non-secure data access. -MOV CCR, SB4 SS64 SAF SP2 DB4 DS64 DAI DP2 +MOV CCR, SB16 SS64 SAF SP2 DB16 DS64 DAI DP2 MOV SAR, 0x10311000 -MOV DAR, 0x18400000 +MOV DAR, 0x18200000 FLUSHP 14 @@ -16,21 +16,12 @@ LPFE # LgyFb sometimes (at the end of each scanline?) sends # single requests. Since we can transfer all 8 scanlines # with bursts only we will ignore them. - LP 7 - LP 15 - LDB - STB - LPENDB - ADDH DAR, 0x20 - LPENDB - - LP 14 + LP 31 LDB STB LPENDB LDPB 14 STB - ADDH DAR, 0x20 LPEND WMB SEV 0 diff --git a/source/arm11/main.c b/source/arm11/main.c index 646c952..b950b9b 100644 --- a/source/arm11/main.c +++ b/source/arm11/main.c @@ -36,7 +36,7 @@ void clearScreens(void) void updateScreens(void) { - GX_textureCopy((u32*)RENDERBUF_TOP, 0, (u32*)GFX_getFramebuffer(SCREEN_TOP), + GX_textureCopy(RENDERBUF_TOP, 0, GFX_getFramebuffer(SCREEN_TOP), 0, SCREEN_SIZE_TOP + SCREEN_SIZE_BOT); GFX_waitForEvent(GFX_EVENT_PPF, true); // Texture copy GFX_swapFramebufs();