Make scaling easier to configure at compile time.
This commit is contained in:
parent
cb00f0a424
commit
56289b36fb
|
@ -24,7 +24,7 @@ SOURCES := ../kernel/source ../source ../source/hardware ../source/arm11 \
|
|||
DATA :=
|
||||
INCLUDES := ../kernel/include ../include ../thirdparty
|
||||
DEFINES := -DARM11 -D_3DS -DVERS_STRING=\"$(VERS_STRING)\" \
|
||||
-DVERS_MAJOR=$(VERS_MAJOR) -DVERS_MINOR=$(VERS_MINOR)
|
||||
-DVERS_MAJOR=$(VERS_MAJOR) -DVERS_MINOR=$(VERS_MINOR) -DOAF_SCALE_SELECT=2
|
||||
ASSETS :=
|
||||
|
||||
ifneq ($(strip $(NO_DEBUG)),)
|
||||
|
|
|
@ -21,10 +21,7 @@
|
|||
#include "types.h"
|
||||
|
||||
|
||||
#define SCALE_SELECT 2
|
||||
|
||||
|
||||
#if SCALE_SELECT == 0
|
||||
#if OAF_SCALE_SELECT == 0
|
||||
// 240x160 no scaling, no filter.
|
||||
alignas(16) static const u8 gbaGpuInitList[1136] =
|
||||
{
|
||||
|
@ -75,7 +72,7 @@ alignas(16) static const u8 gbaGpuInitList[1136] =
|
|||
0x00, 0x00, 0x00, 0x00, 0x62, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x18, 0x01, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x61, 0x00, 0x01, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x6A, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x81, 0x00, 0x4F, 0x80, 0x00, 0x01, 0x00, 0x01, 0x02, 0x00, 0x00, 0x00,
|
||||
0x81, 0x00, 0x4F, 0x80, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x03, 0x01, 0x00, 0x00, 0x00,
|
||||
0x8E, 0x00, 0x0F, 0x00, 0x01, 0x10, 0x01, 0x00, 0x80, 0x00, 0x0B, 0x00,
|
||||
0x00, 0x00, 0x01, 0x00, 0x80, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
|
@ -167,7 +164,7 @@ alignas(16) static const u8 gbaGpuList2[448] =
|
|||
0x78, 0x56, 0x34, 0x12, 0x10, 0x00, 0x0F, 0x00, 0x78, 0x56, 0x34, 0x12,
|
||||
0x10, 0x00, 0x0F, 0x00
|
||||
};
|
||||
#elif SCALE_SELECT == 1
|
||||
#elif OAF_SCALE_SELECT == 1
|
||||
// 240x160 with bilinear scaling to 360x240, no filter.
|
||||
alignas(16) static const u8 gbaGpuInitList[1136] =
|
||||
{
|
||||
|
@ -310,7 +307,7 @@ alignas(16) static const u8 gbaGpuList2[448] =
|
|||
0x78, 0x56, 0x34, 0x12, 0x10, 0x00, 0x0F, 0x00, 0x78, 0x56, 0x34, 0x12,
|
||||
0x10, 0x00, 0x0F, 0x00
|
||||
};
|
||||
#elif SCALE_SELECT == 2
|
||||
#elif OAF_SCALE_SELECT == 2
|
||||
// 360x240, no filter.
|
||||
alignas(16) static const u8 gbaGpuInitList[1136] =
|
||||
{
|
||||
|
@ -361,7 +358,7 @@ alignas(16) static const u8 gbaGpuInitList[1136] =
|
|||
0x00, 0x00, 0x00, 0x00, 0x62, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x18, 0x01, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x61, 0x00, 0x01, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x6A, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x81, 0x00, 0x4F, 0x80, 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00,
|
||||
0x81, 0x00, 0x4F, 0x80, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x03, 0x01, 0x00, 0x00, 0x00, // Last 4 bytes: Texture format.
|
||||
0x8E, 0x00, 0x0F, 0x00, 0x01, 0x10, 0x01, 0x00, 0x80, 0x00, 0x0B, 0x00,
|
||||
0x00, 0x00, 0x01, 0x00, 0x80, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
|
@ -454,6 +451,3 @@ alignas(16) static const u8 gbaGpuList2[448] =
|
|||
0x10, 0x00, 0x0F, 0x00
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#undef SCALE_SELECT
|
||||
|
|
|
@ -5,7 +5,11 @@
|
|||
#include "arm11/hardware/interrupt.h"
|
||||
#include "hardware/corelink_dma-330.h"
|
||||
#include "arm11/hardware/lcd.h"
|
||||
#include "lgyfb_dma330.h"
|
||||
#if OAF_SCALE_SELECT < 2
|
||||
#include "lgyfb_240x160_dma330.h"
|
||||
#else
|
||||
#include "lgyfb_360x240_dma330.h"
|
||||
#endif
|
||||
#include "kevent.h"
|
||||
|
||||
|
||||
|
@ -121,14 +125,17 @@ void LGYFB_init(KEvent *frameReadyEvent)
|
|||
|
||||
g_frameReadyEvent = frameReadyEvent;
|
||||
|
||||
//REG_LGYFB_TOP_SIZE = LGYFB_SIZE(240u, 160u);
|
||||
#if OAF_SCALE_SELECT < 2
|
||||
REG_LGYFB_TOP_SIZE = LGYFB_SIZE(240u, 160u);
|
||||
#else
|
||||
REG_LGYFB_TOP_SIZE = LGYFB_SIZE(360u, 240u);
|
||||
#endif
|
||||
REG_LGYFB_TOP_STAT = LGYFB_IRQ_MASK;
|
||||
REG_LGYFB_TOP_IRQ = 0;
|
||||
REG_LGYFB_TOP_ALPHA = 0xFF;
|
||||
|
||||
/*
|
||||
* Limitations:
|
||||
* Scale matrix limitations:
|
||||
* First pattern bit must be 1 and last 0 (for V-scale) or it loses sync with the DS/GBA input.
|
||||
* Vertical scaling is fucked with identity matrix.
|
||||
*
|
||||
|
@ -142,6 +149,21 @@ void LGYFB_init(KEvent *frameReadyEvent)
|
|||
*
|
||||
* Note: At scanline start the in FIFO is all filled with the first pixel.
|
||||
*/
|
||||
#if OAF_SCALE_SELECT < 2
|
||||
// Identity.
|
||||
static const s16 scaleMatrix[6 * 6] =
|
||||
{
|
||||
// Identity (no scaling). Don't use for vertical scaling!
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0
|
||||
};
|
||||
setScaleMatrix(®_LGYFB_TOP_H_LEN, 0xF8, 6, 0b00111111, scaleMatrix);
|
||||
#else
|
||||
// Other
|
||||
static const s16 scaleMatrix[6 * 6] =
|
||||
{
|
||||
// Original from AGB_FIRM.
|
||||
|
@ -168,20 +190,10 @@ void LGYFB_init(KEvent *frameReadyEvent)
|
|||
0x4000, 0x4000, 0x2000, 0x4000, 0x4000, 0x2000,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0
|
||||
|
||||
// Identity (no scaling). Don't use for vertical scaling!
|
||||
/* 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0x4000, 0x4000, 0x4000, 0x4000, 0x4000, 0x4000,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0*/
|
||||
};
|
||||
// Identity.
|
||||
//setScaleMatrix(®_LGYFB_TOP_H_LEN, 0xF8, 6, 0b00111111, scaleMatrix);
|
||||
// Other
|
||||
setScaleMatrix(®_LGYFB_TOP_V_LEN, 0xF8, 6, 0b00011011, scaleMatrix);
|
||||
setScaleMatrix(®_LGYFB_TOP_H_LEN, 0x00, 6, 0b00011011, scaleMatrix);
|
||||
#endif
|
||||
|
||||
// With RGB8 output solid red and blue are converted to 0xF8 and green to 0xFA.
|
||||
// The green bias exists on the whole range of green colors.
|
||||
|
@ -190,8 +202,13 @@ void LGYFB_init(KEvent *frameReadyEvent)
|
|||
// RGB8: Observed best format. Invisible dithering and best color accuracy.
|
||||
// RGB565: A little visible dithering. Good color accuracy.
|
||||
// RGB5551: Lots of visible dithering. Good color accuracy (a little worse than 565).
|
||||
#if OAF_SCALE_SELECT < 2
|
||||
REG_LGYFB_TOP_CNT = LGYFB_DMA_E | LGYFB_OUT_SWIZZLE | LGYFB_OUT_FMT_8880 |
|
||||
LGYFB_HSCALE_E | LGYFB_ENABLE;
|
||||
#else
|
||||
REG_LGYFB_TOP_CNT = LGYFB_DMA_E | LGYFB_OUT_SWIZZLE | LGYFB_OUT_FMT_8880 |
|
||||
LGYFB_HSCALE_E | LGYFB_VSCALE_E | LGYFB_ENABLE;
|
||||
#endif
|
||||
|
||||
IRQ_registerIsr(IRQ_CDMA_EVENT0, 13, 0, lgyFbDmaIrqHandler);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
# 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, SB16 SS64 SAF SP2 DB16 DS64 DAI DP2
|
||||
MOV SAR, 0x10311000
|
||||
MOV DAR, 0x18200000
|
||||
|
||||
FLUSHP 14
|
||||
|
||||
|
||||
# Loop until the entire frame has been transferred.
|
||||
LP 20 # For height 160.
|
||||
# Wait for a burst request.
|
||||
WFP 14, burst
|
||||
|
||||
# Transfer 8 scanlines.
|
||||
# For width 240:
|
||||
#LP 29 # RGB5551 & RGB565, 128 bytes burst
|
||||
LP 44 # RGB8, 128 bytes burst
|
||||
#LP 59 # RGBA8, 128 bytes burst
|
||||
LD
|
||||
ST
|
||||
LPEND
|
||||
LDPB 14 # This must always be conditional on bursts. No idea why. Assembler bug?
|
||||
ST
|
||||
|
||||
# Skip gaps swizzle edition™.
|
||||
# For width 240 with 256x256 texture:
|
||||
#ADDH DAR, 0x100 # RGB5551 & RGB565
|
||||
ADDH DAR, 0x180 # RGB8
|
||||
#ADDH DAR, 0x200 # RGBA8
|
||||
LPEND
|
||||
WMB
|
||||
SEV 0
|
||||
END
|
|
@ -9,17 +9,11 @@ FLUSHP 14
|
|||
|
||||
|
||||
# Loop until the entire frame has been transferred.
|
||||
#LP 20 # For height 160.
|
||||
LP 30 # For height 240.
|
||||
# Wait for a burst request.
|
||||
WFP 14, burst
|
||||
|
||||
# Transfer 8 scanlines.
|
||||
# For width 240:
|
||||
#LP 29 # RGB5551 & RGB565, 128 bytes burst
|
||||
#LP 44 # RGB8, 128 bytes burst
|
||||
#LP 59 # RGBA8, 128 bytes burst
|
||||
|
||||
# For width 360:
|
||||
#LP 44 # RGB5551 & RGB565, 128 bytes burst
|
||||
LP 71 # RGB8, 120 bytes burst
|
||||
|
@ -31,11 +25,6 @@ LP 30 # For height 240.
|
|||
ST
|
||||
|
||||
# Skip gaps swizzle edition™.
|
||||
# For width 240 with 256x256 texture:
|
||||
#ADDH DAR, 0x100 # RGB5551 & RGB565
|
||||
#ADDH DAR, 0x180 # RGB8
|
||||
#ADDH DAR, 0x200 # RGBA8
|
||||
|
||||
#For width 360 with 512x512 texture:
|
||||
#ADDH DAR, 0x980 # RGB5551 & RGB565
|
||||
ADDH DAR, 0xE40 # RGB8
|
Loading…
Reference in New Issue