Compare commits
18 commits
main
...
external-s
| Author | SHA1 | Date | |
|---|---|---|---|
| 1ca3d0c85b | |||
| 38b76a2bf8 | |||
| dcb6db2d00 | |||
| 58d661b5cb | |||
| f69b5c6317 | |||
| 7cfcfc20ee | |||
| 7a4b0f829e | |||
| d0205b5e6a | |||
| 4b5c183d07 | |||
| c3de84938e | |||
| 32c55d8efe | |||
| c6953328bc | |||
| d768866fb2 | |||
| 1106248ca3 | |||
| 63ec1c2148 | |||
| 5d19703e8b | |||
| 306c56641e | |||
| 03724ee197 |
32 changed files with 206 additions and 525 deletions
3
.github/workflows/build.yml
vendored
3
.github/workflows/build.yml
vendored
|
|
@ -30,8 +30,7 @@ jobs:
|
|||
- name: esp-idf setup/install
|
||||
run: esp-idf/install.sh
|
||||
- name: build DOOM
|
||||
run: |
|
||||
make
|
||||
run: . esp-idf/export.sh; make
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: s3-boy-doom-combined
|
||||
|
|
|
|||
20
Makefile
20
Makefile
|
|
@ -1,8 +1,18 @@
|
|||
ifeq ($(origin IDF_PATH),undefined)
|
||||
$(error You must "source esp-idf/export.sh" before building)
|
||||
endif
|
||||
|
||||
SHELL=/bin/bash
|
||||
.PHONY: default
|
||||
default: assets/doom.squashfs
|
||||
. esp-idf/export.sh && cd fw/s3-boy-doom && idf.py set-target esp32s3 && idf.py build && cd build && esptool.py --chip esp32s3 merge_bin -t 0 --output s3-boy-doom-combined.bin `tail -n +2 flash_args` 0x110000 ../../../assets/doom.squashfs
|
||||
default: fw/s3-boy-doom/build/build.ninja assets/doom.squashfs
|
||||
echo "make: Entering directory \`$(abspath fw/s3-boy-doom/build/)'"
|
||||
cd fw/s3-boy-doom && idf.py build && cd build && esptool.py --chip esp32s3 merge_bin -t 0 --output s3-boy-doom-combined.bin `tail -n +2 flash_args` 0x110000 ../../../assets/doom.squashfs
|
||||
cd fw/s3-boy-doom/build && esptool.py --chip esp32s3 merge_bin -t 0 --output s3-boy-doom-code.bin `tail -n +2 flash_args`
|
||||
cp fw/s3-boy-doom/build/s3-boy-doom-combined.bin assets/
|
||||
cp fw/s3-boy-doom/build/s3-boy-doom-code.bin assets/
|
||||
|
||||
fw/s3-boy-doom/build/build.ninja:
|
||||
cd fw/s3-boy-doom && idf.py set-target esp32s3
|
||||
|
||||
.PHONY: squash
|
||||
squash: assets/doom.squashfs
|
||||
|
|
@ -11,7 +21,7 @@ assets/doom.squashfs: assets/doom-root/doom/doom1.wad Makefile
|
|||
-all-root -no-exports -no-sparse -no-xattrs -all-time 1 -noI \
|
||||
-b 32k -comp lz4 -Xhc
|
||||
|
||||
.PHONY: flash-squash
|
||||
.PHONY: flash-squash flash-code flash-all
|
||||
ifneq ($(origin PORT),undefined)
|
||||
P_PORT=-p $(PORT)
|
||||
else
|
||||
|
|
@ -19,3 +29,7 @@ P_PORT=
|
|||
endif
|
||||
flash-squash: assets/doom.squashfs
|
||||
esptool.py $(P_PORT) write_flash 0x110000 $<
|
||||
flash-code: default
|
||||
esptool.py $(P_PORT) write_flash 0 assets/s3-boy-doom-code.bin
|
||||
flash-all: default
|
||||
esptool.py $(P_PORT) write_flash 0 assets/s3-boy-doom-combined.bin
|
||||
|
|
|
|||
|
|
@ -41,7 +41,11 @@ uint32_t buttonGetRepeatEvent(uint8_t ch);
|
|||
uint32_t buttonGetRepeatCount(uint8_t ch);
|
||||
|
||||
const char *buttonGetName(uint8_t ch);
|
||||
|
||||
#else
|
||||
#define buttonGetPressedEvent(x) false
|
||||
#define buttonGetPressed(x) false
|
||||
#define buttonClear() ((void)0)
|
||||
#define buttonInit() false
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
|
|
@ -36,13 +36,13 @@ int8_t mixerGetValidChannel(uint32_t length);
|
|||
int16_t mixerSamples(int16_t a, int16_t b);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif /* SRC_COMMON_HW_INCLUDE_MIXER_H_ */
|
||||
|
|
|
|||
|
|
@ -25,13 +25,13 @@ typedef struct
|
|||
|
||||
static const gpio_tbl_t gpio_tbl[GPIO_MAX_CH] =
|
||||
{
|
||||
{GPIO_NUM_7 , _DEF_OUTPUT, _DEF_HIGH}, // 0. LCD CS
|
||||
{GPIO_NUM_39, _DEF_OUTPUT, _DEF_LOW }, // 1. LCD DC
|
||||
{GPIO_NUM_45, _DEF_OUTPUT, _DEF_LOW }, // 2. LCD BLK
|
||||
{GPIO_NUM_40, _DEF_OUTPUT, _DEF_HIGH}, // 3. LCD RST
|
||||
{GPIO_NUM_38, _DEF_OUTPUT, _DEF_HIGH }, // 4. SPK MUTE
|
||||
{GPIO_NUM_17, _DEF_INPUT , _DEF_HIGH}, // 5. SDCARD CD
|
||||
{GPIO_NUM_21, _DEF_OUTPUT, _DEF_HIGH}, // 6. LCD PWR
|
||||
// .mosi_io_num = GPIO_NUM_35, // Feather ESP32S3 silk: "MOSI"
|
||||
// .sclk_io_num = GPIO_NUM_36, // Feather ESP32S3 silk: "SCK"
|
||||
{GPIO_NUM_8 , _DEF_OUTPUT, _DEF_HIGH}, // 0. LCD CS // Feather ESP32S3 silk: "A5" // must also change in st7789.c
|
||||
{GPIO_NUM_14, _DEF_OUTPUT, _DEF_LOW }, // 1. LCD DC // Feather ESP32S3 silk: "A4"
|
||||
{GPIO_NUM_15, _DEF_OUTPUT, _DEF_LOW }, // 2. LCD BLK // Feather ESP32S3 silk: "A3"
|
||||
{GPIO_NUM_16, _DEF_OUTPUT, _DEF_HIGH}, // 3. LCD RST // Feather ESP32S3 silk: "A2"
|
||||
{GPIO_NUM_17, _DEF_OUTPUT, _DEF_HIGH}, // 4. LCD PWR // Feather ESP32S3 silk: "A1"
|
||||
};
|
||||
|
||||
static uint8_t gpio_data[GPIO_MAX_CH];
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ typedef struct
|
|||
} cb_data_t;
|
||||
|
||||
|
||||
static void st7789FillRect_unchecked(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color);
|
||||
static void writecommand(uint8_t c);
|
||||
static void writedata(uint8_t d);
|
||||
static void writedata16(uint16_t d);
|
||||
|
|
@ -60,8 +61,8 @@ static void (*frameCallBack)(void) = NULL;
|
|||
volatile static bool is_write_frame = false;
|
||||
static cb_data_t cb_data;
|
||||
|
||||
const uint32_t colstart = 40;
|
||||
const uint32_t rowstart = 53;
|
||||
const uint32_t colstart = (320 - HW_LCD_WIDTH)/2;
|
||||
const uint32_t rowstart = (240 - HW_LCD_HEIGHT)/2;
|
||||
|
||||
|
||||
|
||||
|
|
@ -153,7 +154,7 @@ bool st7789SpiInit(void)
|
|||
{
|
||||
.clock_speed_hz = 40*1000*1000, // Clock out at 40 MHz
|
||||
.mode = 0, // SPI mode 0
|
||||
.spics_io_num = GPIO_NUM_7, // CS pin
|
||||
.spics_io_num = GPIO_NUM_8, // CS pin
|
||||
.queue_size = 16, // We want to be able to queue 8 transactions at a time
|
||||
.flags = SPI_DEVICE_HALFDUPLEX | SPI_DEVICE_NO_RETURN_RESULT,
|
||||
.pre_cb = st7789PreCallback, // Specify pre-transfer callback to handle D/C line
|
||||
|
|
@ -192,7 +193,7 @@ bool st7789Reset(void)
|
|||
|
||||
st7789SetRotation(0);
|
||||
|
||||
st7789FillRect(0, 0, HW_LCD_WIDTH, HW_LCD_HEIGHT, black);
|
||||
st7789FillRect_unchecked(-16, -16, HW_LCD_WIDTH+32, HW_LCD_HEIGHT+32, black);
|
||||
|
||||
if (_PIN_DEF_BLK >= 0) gpioPinWrite(_PIN_DEF_BLK, _DEF_HIGH);
|
||||
|
||||
|
|
@ -288,20 +289,6 @@ void st7789InitRegs(void)
|
|||
writecommand(ST7789_COLMOD); // 15: set color mode, 1 arg, no delay:
|
||||
writedata(0x05); // 16-bit color
|
||||
|
||||
|
||||
writecommand(ST7789_CASET); // 1: Column addr set, 4 args, no delay:
|
||||
writedata(0x00);
|
||||
writedata(0x00); // XSTART = 0
|
||||
writedata(0x00);
|
||||
writedata(HW_LCD_WIDTH-1); // XEND =
|
||||
|
||||
writecommand(ST7789_RASET); // 2: Row addr set, 4 args, no delay:
|
||||
writedata(0x00);
|
||||
writedata(0x00); // XSTART = 0
|
||||
writedata(0x00);
|
||||
writedata(HW_LCD_HEIGHT-1); // XEND =
|
||||
|
||||
|
||||
writecommand(ST7789_NORON); // 3: Normal display on, no args, w/delay
|
||||
delay(10);
|
||||
writecommand(ST7789_DISPON); // 4: Main screen turn on, no args w/delay
|
||||
|
|
@ -325,24 +312,10 @@ void st7789SetWindow(int32_t x0, int32_t y0, int32_t x1, int32_t y1)
|
|||
writecommand(ST7789_RAMWR); // write to RAM
|
||||
}
|
||||
|
||||
void st7789FillRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color)
|
||||
{
|
||||
uint16_t line_buf[w];
|
||||
|
||||
// Clipping
|
||||
if ((x >= _width) || (y >= _height)) return;
|
||||
|
||||
if (x < 0) { w += x; x = 0; }
|
||||
if (y < 0) { h += y; y = 0; }
|
||||
|
||||
if ((x + w) > _width) w = _width - x;
|
||||
if ((y + h) > _height) h = _height - y;
|
||||
|
||||
if ((w < 1) || (h < 1)) return;
|
||||
|
||||
|
||||
void st7789FillRect_unchecked(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color) {
|
||||
st7789SetWindow(x, y, x + w - 1, y + h - 1);
|
||||
|
||||
uint16_t line_buf[w];
|
||||
|
||||
spi_transaction_t trans;
|
||||
|
||||
|
|
@ -367,6 +340,23 @@ void st7789FillRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color)
|
|||
}
|
||||
}
|
||||
|
||||
void st7789FillRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color)
|
||||
{
|
||||
|
||||
// Clipping
|
||||
if ((x >= _width) || (y >= _height)) return;
|
||||
|
||||
if (x < 0) { w += x; x = 0; }
|
||||
if (y < 0) { h += y; y = 0; }
|
||||
|
||||
if ((x + w) > _width) w = _width - x;
|
||||
if ((y + h) > _height) h = _height - y;
|
||||
|
||||
if ((w < 1) || (h < 1)) return;
|
||||
|
||||
st7789FillRect_unchecked(x, y, w, h, color);
|
||||
}
|
||||
|
||||
bool st7789SendBuffer(uint8_t *p_data, uint32_t length, uint32_t timeout_ms)
|
||||
{
|
||||
const uint32_t block_cnt = 4;
|
||||
|
|
|
|||
|
|
@ -41,45 +41,45 @@ bool hwInit(void)
|
|||
logPrintf("\n");
|
||||
|
||||
nvsInit();
|
||||
#if _USE_HW_ADC
|
||||
adcInit();
|
||||
#endif
|
||||
#if _USE_HW_BUTTON
|
||||
buttonInit();
|
||||
printf("%s:%d\n", __FILE__, __LINE__);
|
||||
#endif
|
||||
|
||||
#if _USE_HW_BATTERY
|
||||
batteryInit();
|
||||
printf("%s:%d\n", __FILE__, __LINE__);
|
||||
#endif
|
||||
#if _USE_HW_I2S
|
||||
i2sInit();
|
||||
printf("%s:%d\n", __FILE__, __LINE__);
|
||||
#endif
|
||||
#if _USE_HW_AUDIO
|
||||
audioInit();
|
||||
printf("%s:%d\n", __FILE__, __LINE__);
|
||||
#endif
|
||||
#if _USE_HW_BUZZER
|
||||
buzzerInit();
|
||||
printf("%s:%d\n", __FILE__, __LINE__);
|
||||
#endif
|
||||
|
||||
lcdInit();
|
||||
printf("%s:%d\n", __FILE__, __LINE__);
|
||||
// sdInit();
|
||||
printf("%s:%d\n", __FILE__, __LINE__);
|
||||
fatfsInit();
|
||||
printf("%s:%d\n", __FILE__, __LINE__);
|
||||
#if _USE_HW_YMODEM
|
||||
ymodemInit();
|
||||
printf("%s:%d\n", __FILE__, __LINE__);
|
||||
|
||||
#endif
|
||||
|
||||
esp_partition_iterator_t it;
|
||||
|
||||
it = esp_partition_find(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_ANY, "launcher");
|
||||
printf("%s:%d\n", __FILE__, __LINE__);
|
||||
if (it != NULL)
|
||||
{
|
||||
printf("%s:%d\n", __FILE__, __LINE__);
|
||||
const esp_partition_t *part = esp_partition_get(it);
|
||||
|
||||
if (part != esp_ota_get_running_partition())
|
||||
{
|
||||
printf("%s:%d\n", __FILE__, __LINE__);
|
||||
esp_ota_set_boot_partition(part);
|
||||
}
|
||||
}
|
||||
printf("%s:%d\n", __FILE__, __LINE__);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,10 +39,10 @@
|
|||
#undef _USE_HW_SD
|
||||
#define _USE_HW_FATFS
|
||||
#define _USE_HW_NVS
|
||||
#define _USE_HW_BATTERY
|
||||
#define _USE_HW_I2S
|
||||
#define _USE_HW_BUZZER
|
||||
#define _USE_HW_YMODEM
|
||||
#undef _USE_HW_BATTERY
|
||||
#undef _USE_HW_I2S
|
||||
#undef _USE_HW_BUZZER
|
||||
#undef _USE_HW_YMODEM
|
||||
|
||||
|
||||
#define _USE_HW_LED
|
||||
|
|
@ -70,23 +70,23 @@
|
|||
#define HW_LCD_LVGL 1
|
||||
#define HW_LCD_LOGO 1
|
||||
#define _USE_HW_ST7789
|
||||
#define HW_LCD_WIDTH 240
|
||||
#define HW_LCD_HEIGHT 135
|
||||
#define HW_LCD_WIDTH 280
|
||||
#define HW_LCD_HEIGHT 234
|
||||
|
||||
#define _USE_HW_PWM
|
||||
#define HW_PWM_MAX_CH 1
|
||||
|
||||
#define _USE_HW_ADC
|
||||
#undef _USE_HW_ADC
|
||||
#define HW_ADC_MAX_CH 1
|
||||
|
||||
#define _USE_HW_BUTTON
|
||||
#define HW_BUTTON_MAX_CH 11
|
||||
#undef _USE_HW_BUTTON
|
||||
#define HW_BUTTON_MAX_CH 1
|
||||
|
||||
#define _USE_HW_MIXER
|
||||
#undef _USE_HW_MIXER
|
||||
#define HW_MIXER_MAX_CH 8
|
||||
#define HW_MIXER_MAX_BUF_LEN (16*4*8)
|
||||
|
||||
#define _USE_HW_AUDIO
|
||||
#undef _USE_HW_AUDIO
|
||||
#define HW_AUDIO_CMD_MAX_CH 4
|
||||
|
||||
|
||||
|
|
@ -95,7 +95,7 @@
|
|||
#define _PIN_GPIO_LCD_DC 1
|
||||
#define _PIN_GPIO_LCD_CS 0
|
||||
#define _PIN_GPIO_LCD_RST 3
|
||||
#define _PIN_GPIO_LCD_PWR 6
|
||||
#define _PIN_GPIO_LCD_PWR 4
|
||||
|
||||
// Indices within button.c:button_port_tbl[]
|
||||
#define _BTN_LEFT 0
|
||||
|
|
|
|||
|
|
@ -32,9 +32,7 @@
|
|||
|
||||
static sqfs_err sqfs_decompressor_lz4(void *in, size_t insz,
|
||||
void *out, size_t *outsz) {
|
||||
printf("decompress_safe(%p, %zd, %p, %zd)\n", in, insz, out, *outsz);
|
||||
int zout = LZ4_decompress_safe(in, out, (int)insz, (int)*outsz);
|
||||
printf("->%d", zout);
|
||||
if (zout < 0)
|
||||
return SQFS_ERR;
|
||||
*outsz = zout;
|
||||
|
|
@ -42,7 +40,6 @@ static sqfs_err sqfs_decompressor_lz4(void *in, size_t insz,
|
|||
}
|
||||
|
||||
sqfs_decompressor sqfs_decompressor_get(sqfs_compression_type type) {
|
||||
printf("decompressor_get type=%d\n", type);
|
||||
assert(SQFS_COMP_LZ4 == type);
|
||||
return &sqfs_decompressor_lz4;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,10 +57,10 @@ static const iwad_t iwads[] =
|
|||
#define MAX_IWAD_DIRS 128
|
||||
|
||||
static boolean iwad_dirs_built = false;
|
||||
static EXT_RAM_BSS_ATTR char *iwad_dirs[MAX_IWAD_DIRS];
|
||||
static EXT_RAM_BSS_ATTR const char *iwad_dirs[MAX_IWAD_DIRS];
|
||||
static int num_iwad_dirs = 0;
|
||||
|
||||
static void AddIWADDir(char *dir)
|
||||
static void AddIWADDir(const char *dir)
|
||||
{
|
||||
if (num_iwad_dirs < MAX_IWAD_DIRS)
|
||||
{
|
||||
|
|
@ -504,7 +504,7 @@ static char *CheckDirectoryHasIWAD(const char *dir, const char *iwadname)
|
|||
// Search a directory to try to find an IWAD
|
||||
// Returns the location of the IWAD if found, otherwise NULL.
|
||||
|
||||
static char *SearchDirectoryForIWAD(char *dir, int mask, GameMission_t *mission)
|
||||
static char *SearchDirectoryForIWAD(const char *dir, int mask, GameMission_t *mission)
|
||||
{
|
||||
char *filename;
|
||||
size_t i;
|
||||
|
|
@ -532,7 +532,7 @@ static char *SearchDirectoryForIWAD(char *dir, int mask, GameMission_t *mission)
|
|||
// When given an IWAD with the '-iwad' parameter,
|
||||
// attempt to identify it by its name.
|
||||
|
||||
static GameMission_t IdentifyIWADByName(char *name, int mask)
|
||||
static GameMission_t IdentifyIWADByName(const char *name, int mask)
|
||||
{
|
||||
size_t i;
|
||||
GameMission_t mission;
|
||||
|
|
@ -568,14 +568,15 @@ static GameMission_t IdentifyIWADByName(char *name, int mask)
|
|||
return mission;
|
||||
}
|
||||
|
||||
#if 0
|
||||
// Add IWAD directories parsed from splitting a path string containing
|
||||
// paths separated by PATH_SEPARATOR. 'suffix' is a string to concatenate
|
||||
// to the end of the paths before adding them.
|
||||
static void AddIWADPath(char *path, char *suffix)
|
||||
static void AddIWADPath(const char *path_in, const char *suffix)
|
||||
{
|
||||
char *left, *p;
|
||||
|
||||
path = M_StringDuplicate(path);
|
||||
char *path = M_StringDuplicate(path_in);
|
||||
|
||||
// Split into individual dirs within the list.
|
||||
left = path;
|
||||
|
|
@ -602,8 +603,9 @@ static void AddIWADPath(char *path, char *suffix)
|
|||
|
||||
memFree(path);
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifndef _WIN32
|
||||
#ifdef ORIGCODE
|
||||
// Add standard directories where IWADs are located on Unix systems.
|
||||
// To respect the freedesktop.org specification we support overriding
|
||||
// using standard environment variables. See the XDG Base Directory
|
||||
|
|
@ -611,7 +613,7 @@ static void AddIWADPath(char *path, char *suffix)
|
|||
// <http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html>
|
||||
static void AddXdgDirs(void)
|
||||
{
|
||||
char *env, *tmp_env;
|
||||
const char *env, *tmp_env;
|
||||
|
||||
// Quote:
|
||||
// > $XDG_DATA_HOME defines the base directory relative to which
|
||||
|
|
@ -623,7 +625,7 @@ static void AddXdgDirs(void)
|
|||
|
||||
if (env == NULL)
|
||||
{
|
||||
char *homedir = getenv("HOME");
|
||||
const char *homedir = getenv("HOME");
|
||||
if (homedir == NULL)
|
||||
{
|
||||
homedir = "/";
|
||||
|
|
@ -637,7 +639,7 @@ static void AddXdgDirs(void)
|
|||
// ~/.local/share/games/doom) as a user-writeable extension to
|
||||
// the usual /usr/share/games/doom location.
|
||||
AddIWADDir(M_StringJoin(env, "/games/doom", NULL));
|
||||
memFree(tmp_env);
|
||||
memFree((void*)tmp_env);
|
||||
|
||||
// Quote:
|
||||
// > $XDG_DATA_DIRS defines the preference-ordered set of base
|
||||
|
|
@ -665,6 +667,7 @@ static void AddXdgDirs(void)
|
|||
AddIWADPath(env, "/games/doom3bfg/base/wads");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//
|
||||
// Build a list of IWAD files
|
||||
|
|
@ -730,7 +733,7 @@ static void BuildIWADDirList(void)
|
|||
// Searches WAD search paths for an WAD with a specific filename.
|
||||
//
|
||||
|
||||
char *D_FindWADByName(const char *name)
|
||||
const char *D_FindWADByName(const char *name)
|
||||
{
|
||||
char *path;
|
||||
char *probe;
|
||||
|
|
@ -784,9 +787,9 @@ char *D_FindWADByName(const char *name)
|
|||
// if not found.
|
||||
//
|
||||
|
||||
char *D_TryFindWADByName(char *filename)
|
||||
const char *D_TryFindWADByName(const char *filename)
|
||||
{
|
||||
char *result;
|
||||
const char *result;
|
||||
|
||||
result = D_FindWADByName(filename);
|
||||
|
||||
|
|
@ -807,10 +810,10 @@ char *D_TryFindWADByName(char *filename)
|
|||
// should be executed (notably loading PWADs).
|
||||
//
|
||||
|
||||
char *D_FindIWAD(int mask, GameMission_t *mission)
|
||||
const char *D_FindIWAD(int mask, GameMission_t *mission)
|
||||
{
|
||||
char *result = NULL;
|
||||
char *iwadfile = NULL;
|
||||
const char *result = NULL;
|
||||
const char *iwadfile = NULL;
|
||||
int iwadparm;
|
||||
int i;
|
||||
|
||||
|
|
@ -862,7 +865,7 @@ const iwad_t **D_FindAllIWADs(int mask)
|
|||
{
|
||||
const iwad_t **result;
|
||||
int result_len;
|
||||
char *filename;
|
||||
const char *filename;
|
||||
int i;
|
||||
|
||||
result = memMalloc(sizeof(iwad_t *) * (arrlen(iwads) + 1));
|
||||
|
|
@ -897,7 +900,7 @@ const iwad_t **D_FindAllIWADs(int mask)
|
|||
// Get the IWAD name used for savegames.
|
||||
//
|
||||
|
||||
char *D_SaveGameIWADName(GameMission_t gamemission)
|
||||
const char *D_SaveGameIWADName(GameMission_t gamemission)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
|
|
@ -921,7 +924,7 @@ char *D_SaveGameIWADName(GameMission_t gamemission)
|
|||
return "unknown.wad";
|
||||
}
|
||||
|
||||
char *D_SuggestIWADName(GameMission_t mission, GameMode_t mode)
|
||||
const char *D_SuggestIWADName(GameMission_t mission, GameMode_t mode)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
@ -936,7 +939,7 @@ char *D_SuggestIWADName(GameMission_t mission, GameMode_t mode)
|
|||
return "unknown.wad";
|
||||
}
|
||||
|
||||
char *D_SuggestGameName(GameMission_t mission, GameMode_t mode)
|
||||
const char *D_SuggestGameName(GameMission_t mission, GameMode_t mode)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
|
|||
|
|
@ -33,19 +33,19 @@
|
|||
|
||||
typedef struct
|
||||
{
|
||||
char *name;
|
||||
const char *name;
|
||||
GameMission_t mission;
|
||||
GameMode_t mode;
|
||||
char *description;
|
||||
const char *description;
|
||||
} iwad_t;
|
||||
|
||||
char *D_FindWADByName(const char *filename);
|
||||
char *D_TryFindWADByName(char *filename);
|
||||
char *D_FindIWAD(int mask, GameMission_t *mission);
|
||||
const char *D_FindWADByName(const char *filename);
|
||||
const char *D_TryFindWADByName(const char *filename);
|
||||
const char *D_FindIWAD(int mask, GameMission_t *mission);
|
||||
const iwad_t **D_FindAllIWADs(int mask);
|
||||
char *D_SaveGameIWADName(GameMission_t gamemission);
|
||||
char *D_SuggestIWADName(GameMission_t mission, GameMode_t mode);
|
||||
char *D_SuggestGameName(GameMission_t mission, GameMode_t mode);
|
||||
const char *D_SaveGameIWADName(GameMission_t gamemission);
|
||||
const char *D_SuggestIWADName(GameMission_t mission, GameMode_t mode);
|
||||
const char *D_SuggestGameName(GameMission_t mission, GameMode_t mode);
|
||||
void D_CheckCorrectIWAD(GameMission_t mission);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -636,7 +636,7 @@ void D_StartTitle (void)
|
|||
// These are from the original source: some of them are perhaps
|
||||
// not used in any dehacked patches
|
||||
|
||||
static char *banners[] =
|
||||
static const char *banners[] =
|
||||
{
|
||||
// doom2.wad
|
||||
" "
|
||||
|
|
@ -707,12 +707,12 @@ static char *GetGameName(char *gamename)
|
|||
M_snprintf(gamename, gamename_size, deh_sub,
|
||||
version / 100, version % 100);
|
||||
|
||||
while (gamename[0] != '\0' && isspace(gamename[0]))
|
||||
while (gamename[0] != '\0' && isspace((unsigned char)gamename[0]))
|
||||
{
|
||||
memmove(gamename, gamename + 1, gamename_size - 1);
|
||||
}
|
||||
|
||||
while (gamename[0] != '\0' && isspace(gamename[strlen(gamename)-1]))
|
||||
while (gamename[0] != '\0' && isspace((unsigned char)gamename[strlen(gamename)-1]))
|
||||
{
|
||||
gamename[strlen(gamename) - 1] = '\0';
|
||||
}
|
||||
|
|
@ -729,7 +729,7 @@ static void SetMissionForPackName(char *pack_name)
|
|||
int i;
|
||||
static const struct
|
||||
{
|
||||
char *name;
|
||||
const char *name;
|
||||
int mission;
|
||||
} packs[] = {
|
||||
{ "doom2", doom2 },
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@
|
|||
#include "dstrings.h"
|
||||
|
||||
typedef struct {
|
||||
char *macro;
|
||||
char *string;
|
||||
const char *macro;
|
||||
const char *string;
|
||||
} bex_string_t;
|
||||
|
||||
// mnemonic keys table
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
typedef struct
|
||||
{
|
||||
char *name;
|
||||
const char *name;
|
||||
cheatseq_t *seq;
|
||||
} deh_cheat_t;
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ typedef void (*deh_sha1_hash_t)(sha1_context_t *context);
|
|||
|
||||
struct deh_section_s
|
||||
{
|
||||
char *name;
|
||||
const char *name;
|
||||
|
||||
// Called on startup to initialize code
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
#include "deh_defs.h"
|
||||
#include "deh_main.h"
|
||||
|
||||
char *deh_signatures[] =
|
||||
const char *deh_signatures[] =
|
||||
{
|
||||
"Patch File for DeHackEd v2.3",
|
||||
"Patch File for DeHackEd v3.0",
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ static boolean IsWhitespace(char *s)
|
|||
{
|
||||
for (; *s; ++s)
|
||||
{
|
||||
if (!isspace(*s))
|
||||
if (!isspace((unsigned char)*s))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -148,14 +148,14 @@ static char *CleanString(char *s)
|
|||
|
||||
// Leading whitespace
|
||||
|
||||
while (*s && isspace(*s))
|
||||
while (*s && isspace((unsigned char)*s))
|
||||
++s;
|
||||
|
||||
// Trailing whitespace
|
||||
|
||||
strending = s + strlen(s) - 1;
|
||||
|
||||
while (strlen(s) > 0 && isspace(*strending))
|
||||
while (strlen(s) > 0 && isspace((unsigned char)*strending))
|
||||
{
|
||||
*strending = '\0';
|
||||
--strending;
|
||||
|
|
@ -310,7 +310,7 @@ static void DEH_ParseContext(deh_context_t *context)
|
|||
return;
|
||||
}
|
||||
|
||||
while (line[0] != '\0' && isspace(line[0]))
|
||||
while (line[0] != '\0' && isspace((unsigned char)line[0]))
|
||||
++line;
|
||||
|
||||
if (line[0] == '#')
|
||||
|
|
@ -463,7 +463,7 @@ int DEH_LoadLumpByName(char *name, boolean allow_long, boolean allow_error)
|
|||
// Check the command line for -deh argument, and others.
|
||||
void DEH_ParseCommandLine(void)
|
||||
{
|
||||
char *filename;
|
||||
const char *filename;
|
||||
int p;
|
||||
|
||||
//!
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@
|
|||
{deh_name, NULL, -1, false},
|
||||
|
||||
#define DEH_END_MAPPING \
|
||||
{NULL, NULL, -1} \
|
||||
{NULL, NULL, -1, false} \
|
||||
} \
|
||||
};
|
||||
|
||||
|
|
@ -60,7 +60,7 @@ struct deh_mapping_entry_s
|
|||
{
|
||||
// field name
|
||||
|
||||
char *name;
|
||||
const char *name;
|
||||
|
||||
// location relative to the base in the deh_mapping_t struct
|
||||
// If this is NULL, it is an unsupported mapping
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ static deh_substitution_t *SubstitutionForString(const char *s)
|
|||
// Look up a string to see if it has been replaced with something else
|
||||
// This will be used throughout the program to substitute text
|
||||
|
||||
char *DEH_String(char *s)
|
||||
const char *DEH_String(const char *s)
|
||||
{
|
||||
deh_substitution_t *subst;
|
||||
|
||||
|
|
@ -366,9 +366,9 @@ static boolean ValidFormatReplacement(const char *original, const char *replacem
|
|||
|
||||
// Get replacement format string, checking arguments.
|
||||
|
||||
static const char *FormatStringReplacement(char *s)
|
||||
static const char *FormatStringReplacement(const char *s)
|
||||
{
|
||||
char *repl;
|
||||
const char *repl;
|
||||
|
||||
repl = DEH_String(s);
|
||||
|
||||
|
|
@ -385,7 +385,7 @@ static const char *FormatStringReplacement(char *s)
|
|||
|
||||
// printf(), performing a replacement on the format string.
|
||||
|
||||
void DEH_printf(char *fmt, ...)
|
||||
void DEH_printf(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
const char *repl;
|
||||
|
|
@ -417,7 +417,7 @@ void DEH_fprintf(FILE *fstream, char *fmt, ...)
|
|||
|
||||
// snprintf(), performing a replacement on the format string.
|
||||
|
||||
void DEH_snprintf(char *buffer, size_t len, char *fmt, ...)
|
||||
void DEH_snprintf(char *buffer, size_t len, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
const char *repl;
|
||||
|
|
|
|||
|
|
@ -24,10 +24,10 @@
|
|||
|
||||
// Used to do dehacked text substitutions throughout the program
|
||||
|
||||
char *DEH_String(char *s) PRINTF_ARG_ATTR(1);
|
||||
void DEH_printf(char *fmt, ...) PRINTF_ATTR(1, 2);
|
||||
const char *DEH_String(const char *s) PRINTF_ARG_ATTR(1);
|
||||
void DEH_printf(const char *fmt, ...) PRINTF_ATTR(1, 2);
|
||||
void DEH_fprintf(FILE *fstream, char *fmt, ...) PRINTF_ATTR(2, 3);
|
||||
void DEH_snprintf(char *buffer, size_t len, char *fmt, ...) PRINTF_ATTR(3, 4);
|
||||
void DEH_snprintf(char *buffer, size_t len, const char *fmt, ...) PRINTF_ATTR(3, 4);
|
||||
void DEH_AddStringReplacement(const char *from_text, const char *to_text);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -61,8 +61,8 @@ typedef struct
|
|||
{
|
||||
GameMission_t mission;
|
||||
int episode, level;
|
||||
char *background;
|
||||
char *text;
|
||||
const char *background;
|
||||
const char *text;
|
||||
} textscreen_t;
|
||||
|
||||
static textscreen_t textscreens[] =
|
||||
|
|
@ -94,8 +94,8 @@ static textscreen_t textscreens[] =
|
|||
{ pack_plut, 1, 31, "RROCK19", P6TEXT},
|
||||
};
|
||||
|
||||
char* finaletext;
|
||||
char* finaleflat;
|
||||
const char* finaletext;
|
||||
const char* finaleflat;
|
||||
|
||||
void F_StartCast (void);
|
||||
void F_CastTicker (void);
|
||||
|
|
@ -299,7 +299,7 @@ void F_TextWrite (void)
|
|||
//
|
||||
typedef struct
|
||||
{
|
||||
char *name;
|
||||
const char *name;
|
||||
mobjtype_t type;
|
||||
} castinfo_t;
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@
|
|||
|
||||
|
||||
|
||||
char *chat_macros[10] =
|
||||
const char *chat_macros[10] =
|
||||
{
|
||||
HUSTR_CHATMACRO0,
|
||||
HUSTR_CHATMACRO1,
|
||||
|
|
@ -76,7 +76,7 @@ char *chat_macros[10] =
|
|||
HUSTR_CHATMACRO9
|
||||
};
|
||||
|
||||
char* player_names[] =
|
||||
const char* player_names[] =
|
||||
{
|
||||
HUSTR_PLRGREEN,
|
||||
HUSTR_PLRINDIGO,
|
||||
|
|
@ -110,7 +110,7 @@ static boolean headsupactive = false;
|
|||
// The actual names can be found in DStrings.h.
|
||||
//
|
||||
|
||||
char* mapnames[] = // DOOM shareware/registered/retail (Ultimate) names.
|
||||
const char* mapnames[] = // DOOM shareware/registered/retail (Ultimate) names.
|
||||
{
|
||||
|
||||
HUSTR_E1M1,
|
||||
|
|
@ -164,7 +164,7 @@ char* mapnames[] = // DOOM shareware/registered/retail (Ultimate) names.
|
|||
"NEWLEVEL"
|
||||
};
|
||||
|
||||
char* mapnames_chex[] = // Chex Quest names.
|
||||
const char* mapnames_chex[] = // Chex Quest names.
|
||||
{
|
||||
|
||||
HUSTR_E1M1,
|
||||
|
|
@ -224,7 +224,7 @@ char* mapnames_chex[] = // Chex Quest names.
|
|||
// the layout in the Vanilla executable, where it is possible to
|
||||
// overflow the end of one array into the next.
|
||||
|
||||
char *mapnames_commercial[] =
|
||||
const char *mapnames_commercial[] =
|
||||
{
|
||||
// DOOM 2 map names.
|
||||
|
||||
|
|
@ -370,7 +370,7 @@ void HU_Start(void)
|
|||
{
|
||||
|
||||
int i;
|
||||
char* s;
|
||||
const char* s;
|
||||
|
||||
if (headsupactive)
|
||||
HU_Stop();
|
||||
|
|
@ -595,7 +595,7 @@ boolean HU_Responder(event_t *ev)
|
|||
{
|
||||
|
||||
static char lastmessage[HU_MAXLINELENGTH+1];
|
||||
char* macromessage;
|
||||
const char* macromessage;
|
||||
boolean eatkey = false;
|
||||
static boolean altdown = false;
|
||||
unsigned char c;
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ void HU_Drawer(void);
|
|||
char HU_dequeueChatChar(void);
|
||||
void HU_Erase(void);
|
||||
|
||||
extern char *chat_macros[10];
|
||||
extern const char *chat_macros[10];
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
// System interface for sound.
|
||||
//
|
||||
|
||||
#if 0
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
@ -136,164 +137,16 @@ static int current_sound_lump_num = -1;
|
|||
|
||||
static int I_SDL_StartSound(sfxinfo_t *sfxinfo, int channel, int vol, int sep, int pitch)
|
||||
{
|
||||
//printf("sound : I_SDL_StartSound %d %d %d %d\n", channel, vol, sep, pitch);
|
||||
|
||||
|
||||
|
||||
unsigned int lumplen;
|
||||
int samplerate;
|
||||
unsigned int length;
|
||||
static int lumpnum = -1;
|
||||
static byte *data = NULL;
|
||||
static byte *p_out_buf = NULL;
|
||||
|
||||
// need to load the sound
|
||||
#if 0
|
||||
@baram
|
||||
if (drvAudioGetReady() == false)
|
||||
{
|
||||
audioStop();
|
||||
}
|
||||
|
||||
if (data != NULL)
|
||||
{
|
||||
W_ReleaseLumpNum(lumpnum);
|
||||
}
|
||||
if (p_out_buf != NULL)
|
||||
{
|
||||
memFree(p_out_buf);
|
||||
}
|
||||
#else
|
||||
if (data != NULL)
|
||||
{
|
||||
W_ReleaseLumpNum(lumpnum);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
lumpnum = sfxinfo->lumpnum;
|
||||
data = W_CacheLumpNum(lumpnum, PU_STATIC);
|
||||
lumplen = W_LumpLength(lumpnum);
|
||||
|
||||
// Check the header, and ensure this is a valid sound
|
||||
|
||||
current_sound_lump = data;
|
||||
current_sound_lump_num = channel;
|
||||
|
||||
|
||||
if (lumplen < 8
|
||||
|| data[0] != 0x03 || data[1] != 0x00)
|
||||
{
|
||||
// Invalid sound
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// 16 bit sample rate field, 32 bit length field
|
||||
|
||||
samplerate = (data[3] << 8) | data[2];
|
||||
length = (data[7] << 24) | (data[6] << 16) | (data[5] << 8) | data[4];
|
||||
|
||||
|
||||
// If the header specifies that the length of the sound is greater than
|
||||
// the length of the lump itself, this is an invalid sound lump
|
||||
|
||||
// We also discard sound lumps that are less than 49 samples long,
|
||||
// as this is how DMX behaves - although the actual cut-off length
|
||||
// seems to vary slightly depending on the sample rate. This needs
|
||||
// further investigation to better understand the correct
|
||||
// behavior.
|
||||
|
||||
if (length > lumplen - 8 || length <= 48)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// The DMX sound library seems to skip the first 16 and last 16
|
||||
// bytes of the lump - reason unknown.
|
||||
|
||||
data += 16;
|
||||
length -= 32;
|
||||
|
||||
static int max_length = 0;
|
||||
|
||||
if (length > max_length) max_length = length;
|
||||
|
||||
//printf("%dHz, %dB, ch %d, %d, %d\n", samplerate, length , channel, max_length, data[0]);
|
||||
|
||||
|
||||
for (int i=0; i<NUM_CHANNELS; i++)
|
||||
{
|
||||
if (p_sound_buf[i].is_busy == true && p_sound_buf[i].channel == channel)
|
||||
{
|
||||
p_sound_buf[i].request_stop = true;
|
||||
}
|
||||
}
|
||||
|
||||
ch_index = (ch_index + 1) % NUM_CHANNELS;
|
||||
|
||||
memcpy(p_sound_buf[ch_index].data, data, length);
|
||||
p_sound_buf[ch_index].channel = channel;
|
||||
p_sound_buf[ch_index].index = 0;
|
||||
p_sound_buf[ch_index].length = length;
|
||||
p_sound_buf[ch_index].request_play = true;
|
||||
p_sound_buf[ch_index].is_busy = true;
|
||||
|
||||
//printf("%d %d\n", ch_index, channel);
|
||||
|
||||
current_sound_handle = channel;
|
||||
|
||||
return channel;
|
||||
return false
|
||||
}
|
||||
|
||||
static void I_SDL_StopSound(int handle)
|
||||
{
|
||||
//printf("sound : I_SDL_StopSound\n");
|
||||
|
||||
if (!sound_initialized || handle < 0 || handle >= NUM_CHANNELS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (int ch=0; ch<NUM_CHANNELS; ch++)
|
||||
{
|
||||
if (p_sound_buf[ch].channel == handle && p_sound_buf[ch].is_busy)
|
||||
{
|
||||
p_sound_buf[ch].request_stop = true;
|
||||
}
|
||||
}
|
||||
|
||||
//audioStop(); @baram
|
||||
}
|
||||
|
||||
|
||||
static boolean I_SDL_SoundIsPlaying(int handle)
|
||||
{
|
||||
//printf("sound : I_SDL_SoundIsPlaying\n");
|
||||
|
||||
if (!sound_initialized || handle < 0 || handle >= NUM_CHANNELS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#if 0
|
||||
@baram
|
||||
if (drvAudioGetReady() == false)
|
||||
{
|
||||
printf("Playing\n");
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
for (int ch=0; ch<NUM_CHANNELS; ch++)
|
||||
{
|
||||
if (p_sound_buf[ch].channel == handle && p_sound_buf[ch].is_busy)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -303,61 +156,10 @@ static boolean I_SDL_SoundIsPlaying(int handle)
|
|||
|
||||
static void I_SDL_UpdateSound(void)
|
||||
{
|
||||
uint32_t data_sum;
|
||||
uint32_t data_index;
|
||||
int buf_length = 0;
|
||||
|
||||
|
||||
//printf("sound : I_SDL_UpdateSound\n");
|
||||
|
||||
return;
|
||||
|
||||
//buf_length = speakerAvailable(); // TODO: chcbaram
|
||||
|
||||
|
||||
for (int i=0; i<256 && i<buf_length; i++)
|
||||
{
|
||||
data_sum = 0;
|
||||
data_index = 0;
|
||||
for (int ch=0; ch<NUM_CHANNELS; ch++)
|
||||
{
|
||||
if (p_sound_buf[ch].request_stop == true)
|
||||
{
|
||||
p_sound_buf[ch].request_stop = false;
|
||||
p_sound_buf[ch].is_busy = false;
|
||||
}
|
||||
|
||||
if (p_sound_buf[ch].is_busy)
|
||||
{
|
||||
data_sum += p_sound_buf[ch].data[p_sound_buf[ch].index++];
|
||||
data_index++;
|
||||
|
||||
if (p_sound_buf[ch].index >= p_sound_buf[ch].length)
|
||||
{
|
||||
p_sound_buf[ch].is_busy = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (data_index > 0)
|
||||
{
|
||||
data_sum = data_sum / data_index;
|
||||
}
|
||||
//speakerPutch(data_sum);
|
||||
}
|
||||
}
|
||||
|
||||
static void I_SDL_ShutdownSound(void)
|
||||
{
|
||||
printf("sound : I_SDL_ShutdownSound\n");
|
||||
|
||||
if (!sound_initialized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
sound_initialized = false;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -365,98 +167,9 @@ static void threadAudio(void const *argument);
|
|||
|
||||
static boolean I_SDL_InitSound(boolean _use_sfx_prefix)
|
||||
{
|
||||
use_sfx_prefix = _use_sfx_prefix;
|
||||
sound_initialized = true;
|
||||
|
||||
|
||||
p_sound_buf = (sound_buf_t *)malloc(sizeof(sound_buf_t) * NUM_CHANNELS);
|
||||
|
||||
for (int i=0; i<NUM_CHANNELS; i++)
|
||||
{
|
||||
p_sound_buf[i].is_busy = false;
|
||||
p_sound_buf[i].request_stop = false;
|
||||
p_sound_buf[i].request_play = false;
|
||||
p_sound_buf[i].channel = 0;
|
||||
p_sound_buf[i].index = 0;
|
||||
p_sound_buf[i].length = 0;
|
||||
}
|
||||
|
||||
// TODO chcbaram
|
||||
#if 0
|
||||
//speakerEnable();
|
||||
//speakerStart(11025);
|
||||
i2sSetSampleRate(11025);
|
||||
|
||||
if (xTaskCreate(threadAudio, "threadAudio", 4*1024, NULL, 5, NULL) != pdPASS)
|
||||
{
|
||||
logPrintf("[NG] threadAudio()\n");
|
||||
}
|
||||
|
||||
#endif
|
||||
printf("sound : I_SDL_InitSound\n");
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: chcbaram
|
||||
#if 1
|
||||
static void threadAudio(void const *argument)
|
||||
{
|
||||
uint32_t data_sum;
|
||||
uint32_t data_index;
|
||||
int buf_length;
|
||||
audio_t audio;
|
||||
int16_t buf[256];
|
||||
uint32_t buf_len;
|
||||
|
||||
|
||||
audioOpen(&audio);
|
||||
|
||||
while(1)
|
||||
{
|
||||
buf_length = audioAvailableForWrite(&audio);
|
||||
buf_len = 0;
|
||||
if (buf_length >= 32)
|
||||
{
|
||||
for (int i=0; i<32; i++)
|
||||
{
|
||||
data_sum = 0;
|
||||
data_index = 0;
|
||||
for (int ch=0; ch<NUM_CHANNELS; ch++)
|
||||
{
|
||||
if (p_sound_buf[ch].request_stop == true)
|
||||
{
|
||||
p_sound_buf[ch].request_stop = false;
|
||||
p_sound_buf[ch].is_busy = false;
|
||||
}
|
||||
|
||||
if (p_sound_buf[ch].is_busy)
|
||||
{
|
||||
//data_sum += p_sound_buf[ch].data[p_sound_buf[ch].index++];
|
||||
data_sum = mixerSamples(data_sum, p_sound_buf[ch].data[p_sound_buf[ch].index++]<<4);
|
||||
data_index++;
|
||||
|
||||
if (p_sound_buf[ch].index >= p_sound_buf[ch].length)
|
||||
{
|
||||
p_sound_buf[ch].is_busy = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (data_index > 0)
|
||||
{
|
||||
//data_sum = data_sum / data_index;
|
||||
}
|
||||
buf[buf_len] = data_sum;
|
||||
buf_len++;
|
||||
}
|
||||
audioWrite(&audio, buf, buf_len);
|
||||
}
|
||||
delay(1);
|
||||
}
|
||||
audioClose(&audio);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if 1
|
||||
static snddevice_t sound_sdl_devices[] =
|
||||
{
|
||||
|
|
@ -489,3 +202,4 @@ sound_module_t sound_sdl_module =
|
|||
I_SDL_PrecacheSounds,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ static SDL_Joystick *joystick = NULL;
|
|||
static int usejoystick = 1;
|
||||
|
||||
// SDL GUID and index of the joystick to use.
|
||||
static char *joystick_guid = "";
|
||||
static const char *joystick_guid = "";
|
||||
static int joystick_index = -1;
|
||||
|
||||
// Which joystick axis to use for horizontal movement, and whether to
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ int snd_maxslicetime_ms = 28;
|
|||
|
||||
// External command to invoke to play back music.
|
||||
|
||||
char *snd_musiccmd = "";
|
||||
const char *snd_musiccmd = "";
|
||||
|
||||
// Whether to vary the pitch of sound effects
|
||||
// Each game will set the default differently
|
||||
|
|
@ -95,10 +95,6 @@ static int snd_mport = 0;
|
|||
|
||||
static sound_module_t *sound_modules[] =
|
||||
{
|
||||
&sound_sdl_module,
|
||||
#ifdef FEATURE_SOUND
|
||||
&sound_pcsound_module,
|
||||
#endif
|
||||
NULL,
|
||||
};
|
||||
|
||||
|
|
@ -106,10 +102,6 @@ static sound_module_t *sound_modules[] =
|
|||
|
||||
static music_module_t *music_modules[] =
|
||||
{
|
||||
#ifdef FEATURE_SOUND
|
||||
&music_sdl_module,
|
||||
&music_opl_module,
|
||||
#endif
|
||||
NULL,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -232,7 +232,7 @@ extern int snd_musicdevice;
|
|||
extern int snd_samplerate;
|
||||
extern int snd_cachesize;
|
||||
extern int snd_maxslicetime_ms;
|
||||
extern char *snd_musiccmd;
|
||||
extern const char *snd_musiccmd;
|
||||
extern int snd_pitchshift;
|
||||
|
||||
void I_BindSoundVariables(void);
|
||||
|
|
|
|||
|
|
@ -92,43 +92,19 @@ void I_Tactile(int on, int off, int total)
|
|||
// by trying progressively smaller zone sizes until one is found that
|
||||
// works.
|
||||
|
||||
size_t heap_caps_get_largest_free_block(uint32_t caps);
|
||||
static byte *AutoAllocMemory(int *size, int default_ram, int min_ram)
|
||||
{
|
||||
byte *zonemem;
|
||||
|
||||
// Allocate the zone memory. This loop tries progressively smaller
|
||||
// zone sizes until a size is found that can be allocated.
|
||||
// If we used the -mb command line parameter, only the parameter
|
||||
// provided is accepted.
|
||||
size_t avail_ram = heap_caps_get_largest_free_block(0);
|
||||
|
||||
zonemem = NULL;
|
||||
|
||||
while (zonemem == NULL)
|
||||
{
|
||||
// We need a reasonable minimum amount of RAM to start.
|
||||
|
||||
if (default_ram < min_ram)
|
||||
{
|
||||
I_Error("Unable to allocate %i MiB of RAM for zone", default_ram);
|
||||
}
|
||||
|
||||
// Try to allocate the zone memory.
|
||||
|
||||
*size = default_ram * 1024 * 1024;
|
||||
#ifdef ORIGCODE
|
||||
*size = avail_ram * 3/4;
|
||||
zonemem = malloc(*size);
|
||||
#else
|
||||
zonemem = malloc(*size);
|
||||
#endif
|
||||
|
||||
// Failed to allocate? Reduce zone size until we reach a size
|
||||
// that is acceptable.
|
||||
if (!zonemem) *size = 0;
|
||||
|
||||
if (zonemem == NULL)
|
||||
{
|
||||
default_ram -= 1;
|
||||
}
|
||||
}
|
||||
printf("Allocated %d bytes for zone @%p\n", *size, zonemem);
|
||||
|
||||
return zonemem;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ static uint32_t pixel_format;
|
|||
static SDL_Color palette[256];
|
||||
static boolean palette_to_set;
|
||||
#else
|
||||
static char *window_title = "";
|
||||
static const char *window_title = "";
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -134,11 +134,11 @@ int png_screenshots = 0;
|
|||
|
||||
// SDL video driver name
|
||||
|
||||
char *video_driver = "";
|
||||
const char *video_driver = "";
|
||||
|
||||
// Window position:
|
||||
|
||||
char *window_position = "center";
|
||||
const char *window_position = "center";
|
||||
|
||||
// SDL display number on which to run.
|
||||
|
||||
|
|
@ -160,7 +160,7 @@ static int max_scaling_buffer_pixels = 16000000;
|
|||
|
||||
// Run in full screen mode? (int type for config code)
|
||||
|
||||
int fullscreen = false;
|
||||
int fullscreen = true;
|
||||
|
||||
// Aspect ratio correction mode
|
||||
|
||||
|
|
@ -817,29 +817,33 @@ static void drawScreenNormal(void)
|
|||
return;
|
||||
}
|
||||
|
||||
_Static_assert(HW_LCD_WIDTH == 240);
|
||||
const int x_offset = 0;
|
||||
|
||||
#if HW_LCD_HEIGHT < 180
|
||||
#define USE_HEIGHT HW_LCD_HEIGHT
|
||||
const int y_offset = 0;
|
||||
// vga mode 13h did not have square pixels, since it was displayed
|
||||
// on a 4:3 screen. Use 320x240 as the basis for calculating our scaling factors
|
||||
#if HW_LCD_WIDTH * 240 < HW_LCD_HEIGHT * 320
|
||||
// LCD is relatively wider than native screen, display will be letterboxed
|
||||
const int use_height = LCD_WIDTH * 240 / 320;
|
||||
const int use_width = LCD_WIDTH;
|
||||
#else
|
||||
#define USE_HEIGHT 180
|
||||
const int y_offset = (240 - USE_HEIGHT)/2;
|
||||
const int use_width = LCD_HEIGHT * 320 / 240;
|
||||
const int use_height = LCD_HEIGHT;
|
||||
// LCD is relatively taller than native screen, display will be pillarboxed
|
||||
#endif
|
||||
const int x_offset = (LCD_WIDTH - use_width) / 2;
|
||||
const int y_offset = (LCD_HEIGHT - use_height) / 2;
|
||||
|
||||
resizePixels(I_VideoBuffer, fullscreen_buffer, 320, 200, HW_LCD_WIDTH, USE_HEIGHT);
|
||||
resizePixels(I_VideoBuffer, fullscreen_buffer, 320, 200, use_width, use_height);
|
||||
|
||||
uint16_t *p_buf = lcdGetFrameBuffer();
|
||||
|
||||
for (y = 0; y < USE_HEIGHT; y++)
|
||||
for (y = 0; y < use_height; y++)
|
||||
{
|
||||
for (x = 0; x < HW_LCD_WIDTH; x++)
|
||||
for (x = 0; x < use_width; x++)
|
||||
{
|
||||
index = fullscreen_buffer[y * HW_LCD_WIDTH + x];
|
||||
index = fullscreen_buffer[y * use_width + x];
|
||||
rgb565 = rgb565_palette[index];
|
||||
|
||||
p_buf[(y+y_offset) * HW_LCD_WIDTH + x] = rgb565;
|
||||
p_buf[(y+y_offset) * LCD_WIDTH + x + x_offset] = rgb565;
|
||||
}
|
||||
}
|
||||
lcdRequestDraw();
|
||||
|
|
@ -884,7 +888,6 @@ static void drawScreenNormal(void)
|
|||
|
||||
static void drawScreenFull(void)
|
||||
{
|
||||
int x, y;
|
||||
byte index;
|
||||
uint16_t rgb565;
|
||||
|
||||
|
|
@ -893,28 +896,17 @@ static void drawScreenFull(void)
|
|||
return;
|
||||
}
|
||||
|
||||
int x_offset;
|
||||
int y_offset;
|
||||
|
||||
x_offset = 0;
|
||||
y_offset = 0;
|
||||
|
||||
|
||||
resizePixels(I_VideoBuffer, fullscreen_buffer, 320, 200, HW_LCD_WIDTH, HW_LCD_HEIGHT);
|
||||
|
||||
|
||||
uint16_t *p_buf = lcdGetFrameBuffer();
|
||||
|
||||
|
||||
for (y = 0; y < HW_LCD_HEIGHT; y++)
|
||||
{
|
||||
for (x = 0; x < HW_LCD_WIDTH; x++)
|
||||
{
|
||||
index = fullscreen_buffer[y * HW_LCD_WIDTH + x];
|
||||
for (int i = 0; i < HW_LCD_HEIGHT * HW_LCD_WIDTH; i++) {
|
||||
index = fullscreen_buffer[i];
|
||||
rgb565 = rgb565_palette[index];
|
||||
|
||||
p_buf[(y+y_offset) * HW_LCD_WIDTH + x] = rgb565;
|
||||
}
|
||||
p_buf[i] = rgb565;
|
||||
}
|
||||
lcdRequestDraw();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ void I_StartTic (void);
|
|||
|
||||
void I_EnableLoadingDisk(int xoffs, int yoffs);
|
||||
|
||||
extern char *video_driver;
|
||||
extern const char *video_driver;
|
||||
extern boolean screenvisible;
|
||||
|
||||
extern int vanilla_keyboard_mapping;
|
||||
|
|
@ -94,7 +94,7 @@ extern int integer_scaling;
|
|||
extern int vga_porch_flash;
|
||||
extern int force_software_renderer;
|
||||
|
||||
extern char *window_position;
|
||||
extern const char *window_position;
|
||||
void I_GetWindowPosition(int *x, int *y, int w, int h);
|
||||
|
||||
// Joystic/gamepad hysteresis
|
||||
|
|
|
|||
|
|
@ -26,15 +26,15 @@ void M_LoadDefaults(void);
|
|||
void M_SaveDefaults(void);
|
||||
void M_SaveDefaultsAlternate(char *main, char *extra);
|
||||
void M_SetConfigDir(const char *dir);
|
||||
void M_BindIntVariable(char *name, int *variable);
|
||||
void M_BindFloatVariable(char *name, float *variable);
|
||||
void M_BindStringVariable(char *name, char **variable);
|
||||
boolean M_SetVariable(char *name, char *value);
|
||||
int M_GetIntVariable(char *name);
|
||||
void M_BindIntVariable(const char *name, int *variable);
|
||||
void M_BindFloatVariable(const char *name, float *variable);
|
||||
void M_BindStringVariable(const char *name, char **variable);
|
||||
boolean M_SetVariable(const char *name, char *value);
|
||||
int M_GetIntVariable(const char *name);
|
||||
const char *M_GetStringVariable(char *name);
|
||||
float M_GetFloatVariable(char *name);
|
||||
void M_SetConfigFilenames(char *main_config, char *extra_config);
|
||||
char *M_GetSaveGameDir(char *iwadname);
|
||||
float M_GetFloatVariable(const char *name);
|
||||
void M_SetConfigFilenames(const char *main_config, char *extra_config);
|
||||
const char *M_GetSaveGameDir(char *iwadname);
|
||||
|
||||
extern const char *configdir;
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ boolean W_ParseCommandLine(void)
|
|||
{
|
||||
for (p = p + 1; p<myargc && myargv[p][0] != '-'; ++p)
|
||||
{
|
||||
char *filename;
|
||||
const char *filename;
|
||||
|
||||
modifiedgame = true;
|
||||
|
||||
|
|
@ -77,7 +77,7 @@ boolean W_ParseCommandLine(void)
|
|||
{
|
||||
for (p = p + 1; p<myargc && myargv[p][0] != '-'; ++p)
|
||||
{
|
||||
char *filename;
|
||||
const char *filename;
|
||||
|
||||
modifiedgame = true;
|
||||
|
||||
|
|
@ -104,7 +104,7 @@ boolean W_ParseCommandLine(void)
|
|||
{
|
||||
for (p = p + 1; p<myargc && myargv[p][0] != '-'; ++p)
|
||||
{
|
||||
char *filename;
|
||||
const char *filename;
|
||||
|
||||
modifiedgame = true;
|
||||
|
||||
|
|
@ -129,7 +129,7 @@ boolean W_ParseCommandLine(void)
|
|||
{
|
||||
for (p = p + 1; p<myargc && myargv[p][0] != '-'; ++p)
|
||||
{
|
||||
char *filename;
|
||||
const char *filename;
|
||||
|
||||
modifiedgame = true;
|
||||
filename = D_TryFindWADByName(myargv[p]);
|
||||
|
|
@ -152,7 +152,7 @@ boolean W_ParseCommandLine(void)
|
|||
{
|
||||
for (p = p + 1; p<myargc && myargv[p][0] != '-'; ++p)
|
||||
{
|
||||
char *filename;
|
||||
const char *filename;
|
||||
|
||||
modifiedgame = true;
|
||||
|
||||
|
|
@ -178,7 +178,7 @@ boolean W_ParseCommandLine(void)
|
|||
modifiedgame = true; // homebrew levels
|
||||
while (++p != myargc && myargv[p][0] != '-')
|
||||
{
|
||||
char *filename;
|
||||
const char *filename;
|
||||
|
||||
filename = D_TryFindWADByName(myargv[p]);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue