yaze 0.2.0
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/gfx/snes_tile.h"
7#include "app/rom.h"
8
9namespace yaze {
10namespace app {
11namespace zelda3 {
12namespace screen {
13
15 tiles8Bitmap.Create(128, 512, 8, std::vector<uint8_t>(0x20000));
16 tilesBG1Bitmap.Create(256, 256, 8, std::vector<uint8_t>(0x80000));
17 tilesBG2Bitmap.Create(256, 256, 8, std::vector<uint8_t>(0x80000));
18 oamBGBitmap.Create(256, 256, 8, std::vector<uint8_t>(0x80000));
21}
22
24 uchar staticgfx[16] = {0};
25
26 // Main Blocksets
27
28 // TODO: get the gfx from the GFX class rather than the rom.
29 // for (int i = 0; i < 8; i++) {
30 // staticgfx[i] = GfxGroups.mainGfx[titleScreenTilesGFX][i];
31 // }
32
33 staticgfx[8] = 115 + 0;
34 // staticgfx[9] = (GfxGroups.spriteGfx[titleScreenSpritesGFX][3] + 115);
35 staticgfx[10] = 115 + 6;
36 staticgfx[11] = 115 + 7;
37 // staticgfx[12] = (GfxGroups.spriteGfx[titleScreenSpritesGFX][0] + 115);
38 staticgfx[13] = 112;
39 staticgfx[14] = 112;
40 staticgfx[15] = 112;
41
42 // Loaded gfx for the current screen (empty at this point)
43 uchar* currentmapgfx8Data = tiles8Bitmap.mutable_data().data();
44
45 // All gfx of the game pack of 2048 bytes (4bpp)
46 uchar* allgfxData = nullptr;
47 for (int i = 0; i < 16; i++) {
48 for (int j = 0; j < 2048; j++) {
49 uchar mapByte = allgfxData[j + (staticgfx[i] * 2048)];
50 switch (i) {
51 case 0:
52 case 3:
53 case 4:
54 case 5:
55 mapByte += 0x88;
56 break;
57 }
58
59 currentmapgfx8Data[(i * 2048) + j] = mapByte; // Upload used gfx data
60 }
61 }
62}
63
65 int pos =
66 (rom_[0x138C + 3] << 16) + (rom_[0x1383 + 3] << 8) + rom_[0x137A + 3];
67
68 for (int i = 0; i < 1024; i++) {
69 tilesBG1Buffer[i] = 492;
70 tilesBG2Buffer[i] = 492;
71 }
72
73 pos = core::SnesToPc(pos);
74
75 while ((rom_[pos] & 0x80) != 0x80) {
76 int dest_addr = pos; // $03 and $04
77 pos += 2;
78 short length = pos;
79 bool increment64 = (length & 0x8000) == 0x8000;
80 bool fixsource = (length & 0x4000) == 0x4000;
81 pos += 2;
82
83 length = (short)((length & 0x07FF));
84
85 int j = 0;
86 int jj = 0;
87 int posB = pos;
88 while (j < (length / 2) + 1) {
89 ushort tiledata = (ushort)pos;
90 if (dest_addr >= 0x1000) {
91 // destAddr -= 0x1000;
92 if (dest_addr < 0x2000) {
93 tilesBG1Buffer[dest_addr - 0x1000] = tiledata;
94 }
95 } else {
96 if (dest_addr < 0x1000) {
97 tilesBG2Buffer[dest_addr] = tiledata;
98 }
99 }
100
101 if (increment64) {
102 dest_addr += 32;
103 } else {
104 dest_addr++;
105 }
106
107 if (!fixsource) {
108 pos += 2;
109 }
110
111 jj += 2;
112 j++;
113 }
114
115 if (fixsource) {
116 pos += 2;
117 } else {
118 pos = posB + jj;
119 }
120 }
121
122 pal_selected_ = 2;
123}
124
125} // namespace screen
126} // namespace zelda3
127} // namespace app
128} // namespace yaze
void Create(int width, int height, int depth, const std::vector< uint8_t > &data)
Creates a bitmap object with the provided graphical data.
Definition bitmap.cc:230
auto & mutable_data()
Definition bitmap.h:177
unsigned char uchar
Definition constants.h:114
unsigned short ushort
Definition constants.h:112
uint32_t SnesToPc(uint32_t addr) noexcept
Definition common.h:226
Definition common.cc:22