yaze
0.2.2
Link to the Past ROM Editor
Loading...
Searching...
No Matches
title_screen.cc
Go to the documentation of this file.
1
#include "
title_screen.h
"
2
3
#include <cstdint>
4
5
#include "
app/gfx/bitmap.h
"
6
#include "
app/rom.h
"
7
8
namespace
yaze
{
9
namespace
zelda3
{
10
11
void
TitleScreen::Create
() {
12
tiles8Bitmap
.Create(128, 512, 8, std::vector<uint8_t>(0x20000));
13
tilesBG1Bitmap
.Create(256, 256, 8, std::vector<uint8_t>(0x80000));
14
tilesBG2Bitmap
.Create(256, 256, 8, std::vector<uint8_t>(0x80000));
15
oamBGBitmap
.Create(256, 256, 8, std::vector<uint8_t>(0x80000));
16
BuildTileset
();
17
LoadTitleScreen
();
18
}
19
20
void
TitleScreen::BuildTileset
() {
21
uint8_t staticgfx[16] = {0};
22
23
// Main Blocksets
24
25
// TODO: get the gfx from the GFX class rather than the rom.
26
// for (int i = 0; i < 8; i++) {
27
// staticgfx[i] = GfxGroups.mainGfx[titleScreenTilesGFX][i];
28
// }
29
30
staticgfx[8] = 115 + 0;
31
// staticgfx[9] = (GfxGroups.spriteGfx[titleScreenSpritesGFX][3] + 115);
32
staticgfx[10] = 115 + 6;
33
staticgfx[11] = 115 + 7;
34
// staticgfx[12] = (GfxGroups.spriteGfx[titleScreenSpritesGFX][0] + 115);
35
staticgfx[13] = 112;
36
staticgfx[14] = 112;
37
staticgfx[15] = 112;
38
39
// Loaded gfx for the current screen (empty at this point)
40
uint8_t* currentmapgfx8Data =
tiles8Bitmap
.mutable_data().data();
41
42
// All gfx of the game pack of 2048 bytes (4bpp)
43
uint8_t* allgfxData =
nullptr
;
44
for
(
int
i = 0; i < 16; i++) {
45
for
(
int
j = 0; j < 2048; j++) {
46
uint8_t mapByte = allgfxData[j + (staticgfx[i] * 2048)];
47
switch
(i) {
48
case
0:
49
case
3:
50
case
4:
51
case
5:
52
mapByte += 0x88;
53
break
;
54
}
55
56
currentmapgfx8Data[(i * 2048) + j] = mapByte;
// Upload used gfx data
57
}
58
}
59
}
60
61
void
TitleScreen::LoadTitleScreen
() {
62
int
pos =
63
(
rom_
[0x138C + 3] << 16) + (
rom_
[0x1383 + 3] << 8) +
rom_
[0x137A + 3];
64
65
for
(
int
i = 0; i < 1024; i++) {
66
tilesBG1Buffer
[i] = 492;
67
tilesBG2Buffer
[i] = 492;
68
}
69
70
pos =
SnesToPc
(pos);
71
72
while
((
rom_
[pos] & 0x80) != 0x80) {
73
int
dest_addr = pos;
// $03 and $04
74
pos += 2;
75
short
length = pos;
76
bool
increment64 = (length & 0x8000) == 0x8000;
77
bool
fixsource = (length & 0x4000) == 0x4000;
78
pos += 2;
79
80
length = (short)((length & 0x07FF));
81
82
int
j = 0;
83
int
jj = 0;
84
int
posB = pos;
85
while
(j < (length / 2) + 1) {
86
uint16_t tiledata = (uint16_t)pos;
87
if
(dest_addr >= 0x1000) {
88
// destAddr -= 0x1000;
89
if
(dest_addr < 0x2000) {
90
tilesBG1Buffer
[dest_addr - 0x1000] = tiledata;
91
}
92
}
else
{
93
if
(dest_addr < 0x1000) {
94
tilesBG2Buffer
[dest_addr] = tiledata;
95
}
96
}
97
98
if
(increment64) {
99
dest_addr += 32;
100
}
else
{
101
dest_addr++;
102
}
103
104
if
(!fixsource) {
105
pos += 2;
106
}
107
108
jj += 2;
109
j++;
110
}
111
112
if
(fixsource) {
113
pos += 2;
114
}
else
{
115
pos = posB + jj;
116
}
117
}
118
119
pal_selected_
= 2;
120
}
121
122
}
// namespace zelda3
123
}
// namespace yaze
bitmap.h
yaze::zelda3::TitleScreen::tilesBG2Buffer
uint16_t tilesBG2Buffer[0x1000]
Definition
title_screen.h:49
yaze::zelda3::TitleScreen::oamBGBitmap
gfx::Bitmap oamBGBitmap
Definition
title_screen.h:69
yaze::zelda3::TitleScreen::tilesBG2Bitmap
gfx::Bitmap tilesBG2Bitmap
Definition
title_screen.h:68
yaze::zelda3::TitleScreen::LoadTitleScreen
void LoadTitleScreen()
Definition
title_screen.cc:61
yaze::zelda3::TitleScreen::BuildTileset
void BuildTileset()
Definition
title_screen.cc:20
yaze::zelda3::TitleScreen::tiles8Bitmap
gfx::Bitmap tiles8Bitmap
Definition
title_screen.h:70
yaze::zelda3::TitleScreen::Create
void Create()
Definition
title_screen.cc:11
yaze::zelda3::TitleScreen::tilesBG1Bitmap
gfx::Bitmap tilesBG1Bitmap
Definition
title_screen.h:67
yaze::zelda3::TitleScreen::pal_selected_
int pal_selected_
Definition
title_screen.h:40
yaze::zelda3::TitleScreen::tilesBG1Buffer
uint16_t tilesBG1Buffer[0x1000]
Definition
title_screen.h:48
yaze::zelda3::TitleScreen::rom_
Rom rom_
Definition
title_screen.h:61
yaze::zelda3
Zelda 3 specific classes and functions.
yaze
Main namespace for the application.
Definition
controller.cc:18
yaze::SnesToPc
uint32_t SnesToPc(uint32_t addr) noexcept
Definition
rom.h:328
rom.h
title_screen.h
src
app
zelda3
screen
title_screen.cc
Generated by
1.13.2