XFBManager.cpp

This commit is contained in:
Charlotte Delenk 2021-10-20 10:55:50 +02:00
parent 585854ec84
commit ab70bbabcc
Signed by: darkkirb
GPG key ID: 015E3768A70AFBC5
15 changed files with 109 additions and 10 deletions

View file

@ -26,6 +26,8 @@ build/obj/donut/app/System.o
build/obj/15.o
build/obj/donut/gfx/GXFifoMemoryManager.o
build/obj/16.o
build/obj/donut/mem/Memory.o
build/obj/donut/gfx/XFBManager.o
build/obj/17.o
build/obj/donut/mem/Memory.o
build/obj/18.o
build/obj/19.o

View file

@ -14,7 +14,8 @@
,,,,,,801776bc,80177810,,,,,,,80452cf7,80452d18,,,,,8055d13c,8055d141,,,,,donut/app/EntryPoint.o
,,,,,,801778d8,8017793c,,,,,,,,,,,,,,,,,,,donut/app/EntryPoint2.o
,,,,,,8017bbdc,8017bd88,,,,,,,,,,,,,,,,,,,donut/app/System.o
,,,,,,8019607c,80196168,,,,,,,,,,,,,8055d1b1,8055d1b9,,,,,donut/gfx/GXFifoMemoryManager.o
,,,,,,8019607c,801961fc,,,,,,,,,,,,,8055d1b1,8055d1b9,,,,,donut/gfx/GXFifoMemoryManager.o
,,,,,,80197d50,80197ef4,,,,,,,,,,,,,,,,,,,donut/gfx/XFBManager.o
,,,,,,801bf250,801bf2bc,,,,,,,,,80545bf8,80545ed0,,,8055d2a0,8055d2a1,,,,,donut/mem/Memory.o
80006684,80006728,,,,,,,8040652c,80406530,80406548,8040654c,,,,,,,,,,,,,,,Linker generated symbol file
80006728,80006728,800068cc,800068cc,800069e4,800069e4,80406244,80406244,80406530,80406530,8040654c,8040654c,80421030,80421030,804966fc,804966fc,8055640c,8055640c,8055c6d0,8055c6d0,8055df74,8055df74,805643b0,805643b0,805643fc,805643fc,End of File
1 .init start .init end extab start extab end extabindex start extabindex end .text start .text end .ctors start .ctors end .dtors start .dtors end .rodata start .rodata end .data start .data end .bss start .bss end .sdata start .sdata end .sbss start .sbss end .sdata2 start .sdata2 end .sbss2 start .sbss2 end File
14 801776bc 80177810 80452cf7 80452d18 8055d13c 8055d141 donut/app/EntryPoint.o
15 801778d8 8017793c donut/app/EntryPoint2.o
16 8017bbdc 8017bd88 donut/app/System.o
17 8019607c 80196168 801961fc 8055d1b1 8055d1b9 donut/gfx/GXFifoMemoryManager.o
18 80197d50 80197ef4 donut/gfx/XFBManager.o
19 801bf250 801bf2bc 80545bf8 80545ed0 8055d2a0 8055d2a1 donut/mem/Memory.o
20 80006684 80006728 8040652c 80406530 80406548 8040654c Linker generated symbol file
21 80006728 80006728 800068cc 800068cc 800069e4 800069e4 80406244 80406244 80406530 80406530 8040654c 8040654c 80421030 80421030 804966fc 804966fc 8055640c 8055640c 8055c6d0 8055c6d0 8055df74 8055df74 805643b0 805643b0 805643fc 805643fc End of File

View file

@ -21,6 +21,8 @@ Address,SymbolName
80028530,__init_user
800285a0,exit
8002c840,VIInit
8002cd90,VIWaitForRetrace
8002de70,VISetNextFrameBuffer
80031fe0,GXInit
80038940,GXSetDither
8003a210,DVDInit
@ -30,26 +32,25 @@ Address,SymbolName
80075730,size__Q23gfx19GXFifoMemoryManagerCFv
800dc470,SetTMemLayout__Q34nw4r3g3d4tmemFQ44nw4r3g3d4tmem10TMemLayout
800f16b0,G3dInit__Q24nw4r3g3dFb
801007e0,startAddress__Q23mem8MemBlockCFv
80175b68,__dt__Q33hel6common11NonCopyableFv
80176268,Run__Q23app11ApplicationFRQ23app6Systembbb
80177810,__dt__Q26freeze13FreezeManagerFv
8017786c,__dt__Q23gfx10XFBManagerFv
8018a900,__ct__Q26freeze13FreezeManagerFPUcPUc
80196168,__dt__Q23gfx19GXFifoMemoryManagerFv
801961e0,data__Q23gfx19GXFifoMemoryManagerFv
801962dc,__ct__Q23gfx13RenderSettingFv
80196404,__dt__Q23gfx13RenderSettingFv
801979ac,__ct__Q23gfx9VISettingFv
80197a04,__dt__Q23gfx9VISettingFv
80197b90,set__Q23gfx9VISettingFUl
80197d50,__ct__Q23gfx10XFBManagerFRCQ23gfx9VISetting
80197e8c,target1__Q23gfx10XFBManagerFv
80197ec0,target2__Q23gfx10XFBManagerFv
801a38b0,__ct__Q23hid14LibInitializerFv
801a39f8,__dt__Q23hid14LibInitializerFv
801bd2a4,__ct__Q23mem9DataBlockFUllRQ23mem10IAllocator
801be5a0,free__Q23mem7HeapExpFPv
801bf2bc,__ct__Q23mem6MemoryFv
801bf520,__dt__Q23mem6MemoryFv
801bf5e8,mem1FixHeap__Q23mem6MemoryFv
801bf5f8,mem2FixHeap__Q23mem6MemoryFv
801bf714,__dl__FPv
80402ee8,__ct__Q23snd12SoundManagerFv
80403150,__dt__Q23snd12SoundManagerFv

1 Address SymbolName
21 80028530 __init_user
22 800285a0 exit
23 8002c840 VIInit
24 8002cd90 VIWaitForRetrace
25 8002de70 VISetNextFrameBuffer
26 80031fe0 GXInit
27 80038940 GXSetDither
28 8003a210 DVDInit
32 80075730 size__Q23gfx19GXFifoMemoryManagerCFv
33 800dc470 SetTMemLayout__Q34nw4r3g3d4tmemFQ44nw4r3g3d4tmem10TMemLayout
34 800f16b0 G3dInit__Q24nw4r3g3dFb
35 801007e0 startAddress__Q23mem8MemBlockCFv
36 80175b68 __dt__Q33hel6common11NonCopyableFv
37 80176268 Run__Q23app11ApplicationFRQ23app6Systembbb
38 80177810 __dt__Q26freeze13FreezeManagerFv
39 8017786c __dt__Q23gfx10XFBManagerFv
40 8018a900 __ct__Q26freeze13FreezeManagerFPUcPUc
80196168 __dt__Q23gfx19GXFifoMemoryManagerFv
801961e0 data__Q23gfx19GXFifoMemoryManagerFv
41 801962dc __ct__Q23gfx13RenderSettingFv
42 80196404 __dt__Q23gfx13RenderSettingFv
43 801979ac __ct__Q23gfx9VISettingFv
44 80197a04 __dt__Q23gfx9VISettingFv
45 80197b90 set__Q23gfx9VISettingFUl
80197d50 __ct__Q23gfx10XFBManagerFRCQ23gfx9VISetting
80197e8c target1__Q23gfx10XFBManagerFv
80197ec0 target2__Q23gfx10XFBManagerFv
46 801a38b0 __ct__Q23hid14LibInitializerFv
47 801a39f8 __dt__Q23hid14LibInitializerFv
48 801bd2a4 __ct__Q23mem9DataBlockFUllRQ23mem10IAllocator
49 801be5a0 free__Q23mem7HeapExpFPv
50 801bf2bc __ct__Q23mem6MemoryFv
51 801bf520 __dt__Q23mem6MemoryFv
52 801bf5e8 mem1FixHeap__Q23mem6MemoryFv
53 801bf5f8 mem2FixHeap__Q23mem6MemoryFv
54 801bf714 __dl__FPv
55 80402ee8 __ct__Q23snd12SoundManagerFv
56 80403150 __dt__Q23snd12SoundManagerFv

View file

@ -18,4 +18,17 @@ PrivateSingleton<gfx::GXFifoMemoryManager>::~PrivateSingleton() {
}
bool PrivateSingleton<gfx::GXFifoMemoryManager>::isExist_;
} // namespace common
} // namespace hel
} // namespace hel
namespace gfx {
GXFifoMemoryManager::~GXFifoMemoryManager() {
MEMORY_OBJ->mem1FixHeap().free(fifo_);
fifo_ = 0;
}
void *GXFifoMemoryManager::data() {
return (void *)(((u32)fifo_ + 0x3ff) & ~0x3ff);
}
void GXFifoMemoryManager::setWriteEnable() { writeEnable_ = true; }
} // namespace gfx

31
donut/gfx/XFBManager.cpp Normal file
View file

@ -0,0 +1,31 @@
#include <gfx/XFBManager.hpp>
#include <mem/Memory.hpp>
#include <vi.h>
namespace gfx {
XFBManager::XFBManager(const VISetting &vi)
: fb1_(vi.fbSize(), 0x20, MEMORY_OBJ->mem2FixHeap()),
fb2_(vi.fbSize(), 0x20, MEMORY_OBJ->mem2FixHeap()), oddFb_(false) {
VISetNextFrameBuffer(drawTargetXFB());
VIWaitForRetrace();
changeDrawTargetXFB();
}
unsigned char *XFBManager::drawTargetXFB() {
if (oddFb_) {
mem::MemBlock block = fb1_.block_;
return (unsigned char *)block.startAddress();
} else {
mem::MemBlock block = fb2_.block_;
return (unsigned char *)block.startAddress();
}
}
void XFBManager::changeDrawTargetXFB() { oddFb_ = !oddFb_; }
unsigned char *XFBManager::target1() {
mem::MemBlock block = fb1_.block_;
return (unsigned char *)block.startAddress();
}
unsigned char *XFBManager::target2() {
mem::MemBlock block = fb2_.block_;
return (unsigned char *)block.startAddress();
}
} // namespace gfx

View file

@ -17,5 +17,6 @@ struct GXFifoMemoryManager
u32 size() const;
void *data();
void setWriteEnable();
};
} // namespace gfx

View file

@ -1,10 +1,17 @@
#pragma once
#include <gx.h>
#include <types.h>
namespace gfx {
struct VISetting {
int unk[5];
GXRenderModeObject *rmode_;
int unk[4];
VISetting();
~VISetting();
void set(unsigned long);
u32 fbSize() const {
return (u16)((rmode_->fbWidth + 15) & ~15) * (u32)rmode_->xfbHeight * 2;
}
};
} // namespace gfx

View file

@ -1,13 +1,18 @@
#pragma once
#include <gfx/VISetting.hpp>
#include <mem/DataBlock.hpp>
namespace gfx {
struct XFBManager {
int unk[7];
mem::DataBlock fb1_;
mem::DataBlock fb2_;
bool oddFb_;
XFBManager(const VISetting &);
~XFBManager();
unsigned char *target1();
unsigned char *target2();
unsigned char *drawTargetXFB();
void changeDrawTargetXFB();
};
} // namespace gfx

View file

@ -9,6 +9,22 @@ extern "C" {
void GXInit(void *fifoBase, u32 size);
void GXSetDither(BOOL enabled);
typedef struct {
u32 viTVMode;
u16 fbWidth;
u16 efbHeight;
u16 xfbHeight;
u16 viXOrigin;
u16 viYOrigin;
u16 viWidth;
u16 viHeight;
u32 xfbMode;
u8 field_rendering;
u8 aa;
u8 sample_pattern[12][2];
u8 vfilter[7];
} GXRenderModeObject;
#ifdef __cplusplus
}
#endif

14
include/mem/DataBlock.hpp Normal file
View file

@ -0,0 +1,14 @@
#pragma once
#include <mem/IAllocator.hpp>
#include <mem/MemBlock.hpp>
namespace mem {
struct DataBlock {
IAllocator &alloc_;
MemBlock block_;
DataBlock(u32 size, s32 align, IAllocator &alloc);
~DataBlock();
};
} // namespace mem

View file

@ -12,5 +12,7 @@ struct HeapExp : public IHeap {
virtual const MemBlock heapMemBlock() const;
virtual u32 heapUsingBlockCount() const;
virtual void heapDump() const;
void free(void *ptr);
};
} // namespace mem

View file

@ -6,5 +6,7 @@ namespace mem {
struct MemBlock {
u32 size;
void *ptr;
void *startAddress() const;
};
} // namespace mem

View file

@ -21,6 +21,7 @@ struct Memory : hel::common::ExplicitSingleton<Memory> {
~Memory();
HeapExp &mem1FixHeap();
HeapExp &mem2FixHeap();
};
} // namespace mem

View file

@ -5,6 +5,8 @@ extern "C" {
#endif
void VIInit(void);
void VISetNextFrameBuffer(void *fb);
void VIWaitForRetrace();
#ifdef __cplusplus
}

View file

@ -26,6 +26,7 @@ const SOURCES: &[(&str, &str)] = &[
("donut/app/EntryPoint2.cpp", "donut"),
("donut/app/System.cpp", "donut"),
("donut/gfx/GXFifoMemoryManager.cpp", "donut"),
("donut/gfx/XFBManager.cpp", "donut"),
("donut/mem/Memory.cpp", "donut"),
];