[Decompilation] Finally declare <stdint.h> types

*Finally*. We already used `(unsigned) int` in quite a few places where
we actually want a 16-bit value, which was bound to annoy future port
developers.
This commit is contained in:
nmlgc 2019-12-11 21:42:27 +01:00
parent cb45bf5a80
commit 9cb6cc527a
10 changed files with 59 additions and 33 deletions

View File

@ -5,6 +5,7 @@
#include <master.h>
#include <stddef.h>
#include "platform.h"
#include "pc98.h"
// master.lib extensions
@ -60,9 +61,9 @@ typedef struct {
typedef union {
struct {
char lo, hi;
int8_t lo, hi;
} byte;
int v;
int16_t v;
} twobyte_t;
/// Typedefs

25
platform.h Normal file
View File

@ -0,0 +1,25 @@
/* ReC98
* -----
* Platform- and compiler-specific types.
*/
/// <stdint.h>
/// ----------
// __TURBOC__ is #define'd on both "Borland" and "Turbo" editions, unlike
// __BORLANDC__, which is only #define'd on the former.
#if defined(__TURBOC__) && defined(__MSDOS__)
# ifdef __cplusplus
typedef char bool;
# define false 0
# define true 1
#endif
typedef char int8_t;
typedef short int16_t;
typedef long int32_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned long uint32_t;
#else
# error This code can currently only be compiled on Borland's 16-bit DOS compilers. Ideally, you'd only have to declare <stdint.h> types for your compiler here though?
#endif
/// ----------

View File

@ -15,10 +15,10 @@ typedef struct {
char type[2]; // •• if RLE-compressed
char aux; // Always 3, unused
char fn[FN_LEN];
long packsize;
long orgsize;
long offset; // of the file data within the entire archive
long reserved; // Always zero
int32_t packsize;
int32_t orgsize;
int32_t offset; // of the file data within the entire archive
int32_t reserved; // Always zero
} pf_header_t;
#pragma option -Z -a1
@ -84,9 +84,9 @@ int pascal near at_pos_of(const char *fn)
}
// Get it? En*crap*tion?
void pascal near crapt(char *buf, unsigned int size)
void pascal near crapt(char *buf, size_t size)
{
unsigned int i;
size_t i;
for(i = 0; i < size; i++) {
buf[i] ^= arc_key;
}
@ -178,10 +178,10 @@ void pascal arc_file_load(const char *fn)
file_close();
}
void pascal arc_file_get(char *buf, unsigned int size)
void pascal arc_file_get(char *buf, size_t size)
{
char *p = buf;
unsigned int i;
size_t i;
for(i = 0; i < size; i++) {
if(file_pos >= file_pf->orgsize) {
break;

View File

@ -111,13 +111,13 @@ void z_text_locate(char x, char y)
void z_text_putsa(int x, int y, int z_atrb, const char *str)
{
unsigned int codepoint;
uint16_t codepoint;
int p = ((y * text_width()) + x) * 2;
int hw_atrb = 1;
#define tx_chars(byte) ((char*)MK_FP(0xA000, 0) + p + byte)
#define tx_chars(byte) ((char*)MK_FP(0xA000, 0) + p + byte)
#define tx_atrbs(byte) (int*)((char*)MK_FP(0xA200, 0) + p + byte)
#define tx_chars(byte) ((char*)MK_FP(0xA000, p + byte))
#define tx_chars(byte) ((char*)MK_FP(0xA000, p + byte))
#define tx_atrbs(byte) ((int16_t*)MK_FP(0xA200, p + byte))
if(z_atrb & 1) {
hw_atrb += 0x20;
@ -152,7 +152,7 @@ void z_text_putsa(int x, int y, int z_atrb, const char *str)
*tx_chars(1) = codepoint;
*tx_atrbs(0) = hw_atrb;
} else if(x == text_width() - 1) {
*(int*)tx_chars(0) = ' ';
*(int16_t*)tx_chars(0) = ' ';
*tx_atrbs(0) = hw_atrb;
} else {
*tx_chars(0) = (codepoint >> 8) + 0xE0;
@ -166,7 +166,7 @@ void z_text_putsa(int x, int y, int z_atrb, const char *str)
x++;
}
} else {
*(int*)tx_chars(0) = *(unsigned char*)(str++);
*(int16_t*)tx_chars(0) = *(unsigned char*)(str++);
*tx_atrbs(0) = hw_atrb;
}
p += 2;

View File

@ -3,7 +3,7 @@
void graph_putsa_fx(int x, int y, int fx, const unsigned char *str)
{
unsigned int codepoint;
uint16_t codepoint;
unsigned int glyph_row;
unsigned char far *vram;
int fullwidth;

View File

@ -1,4 +1,4 @@
int snd_kaja_interrupt(int ax)
int16_t snd_kaja_interrupt(int16_t ax)
{
if(snd_active) {
_AX = ax;

View File

@ -183,7 +183,7 @@ int snd_pmd_resident(void);
int snd_mmd_resident(void);
int snd_determine_mode(void);
int snd_kaja_interrupt(int ax);
int16_t snd_kaja_interrupt(int16_t ax);
#define snd_kaja_func(func, param) snd_kaja_interrupt((func) << 8 | (param))
#define SND_LOAD_SONG (KAJA_GET_SONG_ADDRESS << 8)
@ -206,17 +206,17 @@ void snd_se_update(void);
#define CFG_FN "huuma.cfg"
#pragma option -a1
typedef struct {
char rank;
char bgm_mode;
char bombs;
char lives;
char perf;
int8_t rank;
int8_t bgm_mode;
int8_t bombs;
int8_t lives;
int8_t perf;
} huuma_options_t;
typedef struct {
huuma_options_t opts;
int resident_sgm;
char debug;
int8_t debug;
} huuma_cfg_t;
#pragma option -a.
// ------------------
@ -283,10 +283,10 @@ typedef struct {
*
* For rank #4, this field is unused.
*/
int cleared;
int16_t cleared;
long points[SCORE_PLACES];
long points_sum;
int32_t points[SCORE_PLACES];
int32_t points_sum;
unsigned char g_name[SCORE_PLACES][SCORE_NAME_LEN + 1];
unsigned char g_name_first_sum;
unsigned char stage[SCORE_PLACES];
@ -297,7 +297,7 @@ typedef struct {
typedef struct {
score_t score;
long score_sum; // Sum of all bytes in score, pre-encraption
int32_t score_sum; // Sum of all bytes in score, pre-encraption
} score_file_t;
extern char cleared_game_with[SHOTTYPE_COUNT];

View File

@ -1,2 +1,2 @@
unsigned short pascal near randring1_next16(void);
unsigned short pascal near randring1_next16_and(unsigned short mask);
uint16_t pascal near randring1_next16(void);
uint16_t pascal near randring1_next16_and(uint16_t mask);

View File

@ -2,7 +2,7 @@
#define MEM_ASSIGN_PARAS_OP (336000 >> 4)
#define MEM_ASSIGN_PARAS_MAIN (320000 >> 4)
#define MEM_ASSIGN_PARAS_MAINE (336000 >> 4)
extern unsigned int mem_assign_paras;
extern size_t mem_assign_paras;
#define EMSSIZE (180000) /* ZUN symbol [MAGNet2010] */

View File

@ -2,7 +2,7 @@
#define MEM_ASSIGN_PARAS_OP (336000 >> 4)
#define MEM_ASSIGN_PARAS_MAIN (291200 >> 4)
#define MEM_ASSIGN_PARAS_MAINE (336000 >> 4)
extern unsigned int mem_assign_paras;
extern size_t mem_assign_paras;
#define EMSSIZE (320000) /* ZUN symbol [MAGNet2010] */