MCPcopy Create free account
hub / github.com/TheOfficialFloW/VitaShell / SFOReader

Function SFOReader

sfo.c:105–284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103}
104
105int SFOReader(const char *file) {
106 uint8_t *buffer = memalign(4096, BIG_BUFFER_SIZE);
107 if (!buffer)
108 return VITASHELL_ERROR_NO_MEMORY;
109
110 int size = 0;
111
112 if (isInArchive()) {
113 size = ReadArchiveFile(file, buffer, BIG_BUFFER_SIZE);
114 } else {
115 size = ReadFile(file, buffer, BIG_BUFFER_SIZE);
116 }
117
118 if (size <= 0) {
119 free(buffer);
120 return size;
121 }
122
123 SfoHeader *sfo_header = (SfoHeader *)buffer;
124 if (sfo_header->magic != SFO_MAGIC)
125 return VITASHELL_ERROR_INVALID_MAGIC;
126
127 int base_pos = 0, rel_pos = 0;
128
129 int scroll_count = 0;
130 float scroll_x = FILE_X;
131
132 while (1) {
133 readPad();
134
135 if (pressed_pad[PAD_CANCEL]) {
136 break;
137 }
138
139 if (hold_pad[PAD_UP] || hold2_pad[PAD_LEFT_ANALOG_UP]) {
140 int old_pos = base_pos + rel_pos;
141
142 if (rel_pos > 0) {
143 rel_pos--;
144 } else if (base_pos > 0) {
145 base_pos--;
146 }
147
148 if (old_pos != base_pos + rel_pos) {
149 scroll_count = 0;
150 }
151 } else if (hold_pad[PAD_DOWN] || hold2_pad[PAD_LEFT_ANALOG_DOWN]) {
152 int old_pos = base_pos + rel_pos;
153
154 if ((rel_pos + 1) < sfo_header->count) {
155 if ((rel_pos + 1) < MAX_POSITION) {
156 rel_pos++;
157 } else if ((base_pos + rel_pos + 1) < sfo_header->count) {
158 base_pos++;
159 }
160 }
161
162 if (old_pos != base_pos + rel_pos) {

Callers 1

handleFileFunction · 0.85

Calls 8

isInArchiveFunction · 0.85
ReadArchiveFileFunction · 0.85
ReadFileFunction · 0.85
readPadFunction · 0.85
startDrawingFunction · 0.85
drawShellInfoFunction · 0.85
drawScrollBarFunction · 0.85
endDrawingFunction · 0.85

Tested by

no test coverage detected