add #define for struct packing attribute

This commit is contained in:
Gered 2021-03-24 14:11:32 -04:00
parent 6292c87676
commit 18e331819b
3 changed files with 17 additions and 7 deletions

6
defs.h Normal file
View file

@ -0,0 +1,6 @@
#ifndef DEFS_H_INCLUDED
#define DEFS_H_INCLUDED
#define _PACKED_ __attribute__((packed))
#endif

View file

@ -23,8 +23,10 @@
#include <sylverant/encryption.h>
#include <sylverant/prs.h>
#include "fuzziqer_prs.h"
#include "defs.h"
#include "quests.h"
#include "utils.h"
@ -35,7 +37,7 @@
// copied from https://github.com/suloku/gcmm/blob/master/source/gci.h
typedef struct __attribute__((__packed__)) {
typedef struct _PACKED_ {
uint8_t gamecode[4];
uint8_t company[2];
uint8_t reserved01; /*** Always 0xff ***/
@ -53,7 +55,7 @@ typedef struct __attribute__((__packed__)) {
uint32_t comment_addr;
} GCI;
typedef struct __attribute__((packed)) {
typedef struct _PACKED_ {
GCI gci_header;
uint8_t card_file_header[0x2040]; // big area containing the icon and such other things. ignored

View file

@ -4,13 +4,15 @@
#include <stdio.h>
#include <stdint.h>
#include "defs.h"
#define PACKET_ID_QUEST_INFO_ONLINE 0x44
#define PACKET_ID_QUEST_INFO_DOWNLOAD 0xa6
#define PACKET_ID_QUEST_CHUNK_ONLINE 0x13
#define PACKET_ID_QUEST_CHUNK_DOWNLOAD 0xa7
// quest .bin file header (after file contents have been prs-decompressed)
typedef struct __attribute__((packed)) {
typedef struct _PACKED_ {
uint32_t object_code_offset;
uint32_t function_offset_table_offset;
uint32_t bin_size;
@ -37,7 +39,7 @@ typedef struct __attribute__((packed)) {
char long_description[288];
} QUEST_BIN_HEADER;
typedef struct __attribute__((packed)) {
typedef struct _PACKED_ {
uint32_t type;
uint32_t table_size;
uint32_t area;
@ -45,7 +47,7 @@ typedef struct __attribute__((packed)) {
} QUEST_DAT_TABLE_HEADER;
// .qst file header, for either the embedded bin or dat quest data
typedef struct __attribute__((packed)) {
typedef struct _PACKED_ {
// 0xA6 = download to memcard, 0x44 = download for online play
// (quest file data chunks must then be encoded accordingly. 0xA6 = use 0xA7, and 0x44 = use 0x13)
uint8_t pkt_id;
@ -70,7 +72,7 @@ typedef struct __attribute__((packed)) {
uint32_t size;
} QST_HEADER;
typedef struct __attribute__((packed)) {
typedef struct _PACKED_ {
uint8_t pkt_id;
uint8_t pkt_flags;
uint16_t pkt_size;