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