~ndiddy/libremo

2fb91b1a48606972c7c40359f5fad617646bd2d8 — Nathan Misner 2 years ago da26a60
fixed gcc compiler warnings
M Makefile => Makefile +2 -2
@@ 4,10 4,10 @@ CXX = g++
TARGET = libremo

SDL2_CFLAGS = $(shell sdl2-config --cflags)
SDL2_LDFLAGS = $(shell sdl2-config --libs) -mconsole
SDL2_LDFLAGS = $(shell sdl2-config --libs)

CFLAGS = -g -std=c11 -Wall -Wvla -Wformat=2 -O0 $(SDL2_CFLAGS)
CXXFLAGS = -g -std=c++20 -Wall -O0 $(SDL2_CFLAGS)
CXXFLAGS = -g -std=c++20 -Wall -Wvla -O0 $(SDL2_CFLAGS)
LDFLAGS = $(SDL2_LDFLAGS) -lSDL2_image -lm

OBJECTS =	main.o \

M README => README +4 -4
@@ 37,14 37,14 @@ and figure out where the "Cyberblock" and "EX" graphics are stored in the execut

Menu: Very simplistic compared to the X68000 version, I need to make it data-driven.

Tutorial screens: Not implemented.
Tutorial screens: Mostly implemented.

Cutscenes: Not implemented.
Cutscenes: Show background but not animation or text.

Game: Hud needs work (specifically with representing powerup state). Chip doesn't move her
mouth when the player collects a powerup. Game over and continue states aren't implemented.
Scoring isn't entirely accurate. The "guns" on the walls that change based on what powerup
you have aren't implemented.
Scoring isn't accurate. The "guns" on the walls that change based on what powerup you have
aren't implemented. The ship doesn't extend its guns when the player gets the laser powerup.

Used software:


M block_explode.cpp => block_explode.cpp +1 -1
@@ 62,7 62,7 @@ void BlockExplode::move() {
        frame++;
    }

    if (frame >= explodeTextures.size()) {
    if (frame >= (int)explodeTextures.size()) {
        explodeList.queueRemove(this);
        // don't display the sprite
        texture = NULL;

M block_shine.cpp => block_shine.cpp +1 -1
@@ 70,7 70,7 @@ void BlockShine::move(float xPos, float yPos) {
    if (animTimer >= SHINE_TIMING) {
        animTimer = 0;
        frame++;
        if (frame >= shineTextures.size()) {
        if (frame >= (int)shineTextures.size()) {
            display = 0;
            return;
        }

M block_shrink.cpp => block_shrink.cpp +1 -1
@@ 72,7 72,7 @@ void BlockShrink::move(Level *parent) {
            if (animTimer >= SHRINK_TIMING) {
                animTimer = 0;
                frame++;
                if (frame >= shrinkTextures.size()) {
                if (frame >= (int)shrinkTextures.size()) {
                    state = STATE_HIDE;
                    return;
                }

M block_stretch.cpp => block_stretch.cpp +1 -1
@@ 94,7 94,7 @@ void BlockStretch::draw() {
        spr.draw();
    }
    else {
        if ((frame + STRETCH_FRAMES) >= stretchTextures.size()) {
        if ((frame + STRETCH_FRAMES) >= (int)stretchTextures.size()) {
            return;
        }
        // left split sprite

M font.cpp => font.cpp +2 -3
@@ 174,7 174,6 @@ Font::~Font() {
void Font::clearSurface() {
    uint32_t *pixels = (uint32_t *)dispSurface->pixels;
    int size = dispSurface->w * dispSurface->h;
    uint32_t color = SDL_MapRGBA(gWindowFormat, 0, 0, 0, 0);

    for (int i = 0; i < size; i++) {
        pixels[i] = 0;


@@ 240,13 239,13 @@ void Font::display(float x, float y, int scale) {
        return;
    }

    if (printCursor < message.length()) {
    if (printCursor < (int)message.length()) {
        printTimer += Speed_Multiplier();
    }

    // "while" instead of "if" so the FONT_TIMING_IMMEDIATE feature works
    while (printTimer >= printTiming) {
        if (printCursor >= message.length()) {
        if (printCursor >= (int)message.length()) {
            break;
        }
        printTimer = 0;

M game.cpp => game.cpp +6 -5
@@ 142,7 142,7 @@ static float shipFrames;
#define SHIP_COLLAPSE_FIRST (0)
#define SHIP_COLLAPSE_LAST (480)

static float shipSpeed;
float shipSpeed;

SpriteInfo barrelSprite;
#define BARREL_SIZE (8)


@@ 290,10 290,11 @@ static void Game_BitAnim() {
}

static void Game_FlameRun(int start, int end) {
    static uint32_t frameCnt = 0;
    static float frameCount = 0;

    frameCnt++;
    if (frameCnt & 1) {
    frameCount += Speed_Multiplier();
    if (frameCount >= 2) {
        frameCount -= 2;
        flameFrame += FLAME_SIZE;
        if (flameFrame >= end) {
            flameFrame = start + FLAME_SIZE;


@@ 436,7 437,7 @@ int Game_Run() {
            
            // if all the blocks from the current level are gone, move to the new level.
            // if there's no more letters, show the coming soon text.
            if ((padDataE & PAD_DBG2) || gameLevel->doneLoad() && !gameLevel->blocksLeft()) {
            if ((padDataE & PAD_DBG2) || (gameLevel->doneLoad() && !gameLevel->blocksLeft())) {
                // remove all balls
                Ball_RemoveAll();
                // remove all capsules

M hud.cpp => hud.cpp +2 -2
@@ 380,7 380,7 @@ static void Hud_DispWall() {
    wallSprite.y = 0;

    // draw ceiling
    for (int i = 0; i < (sizeof(ceilArr) / sizeof(ceilArr[0])); i++) {
    for (int i = 0; i < (int)(sizeof(ceilArr) / sizeof(ceilArr[0])); i++) {
        // skip WALL_NONE
        if (ceilArr[i] >= 0) {
            int sourcePos = ceilArr[i] & 0xffff;


@@ 407,7 407,7 @@ static void Hud_DispWall() {
    
    // draw left/right walls
    wallSprite.y += HUD_WALL_SIZE;
    for (int i = 0; i < (sizeof(wallArr) / sizeof(wallArr[0])); i++) {
    for (int i = 0; i < (int)(sizeof(wallArr) / sizeof(wallArr[0])); i++) {
        wallSprite.source.x = wallArr[i] & 0xffff;
        if (wallArr[i] & WALL_VMIRROR) {
            wallSprite.mirror = SDL_FLIP_VERTICAL;

M laser.cpp => laser.cpp +2 -2
@@ 58,7 58,7 @@ Laser::Laser(float xPos, float yPos) :
}

int Laser::check(SDL_Rect *rect) {
    for (int i = 0; i < (sizeof(laserPixels) / sizeof(laserPixels[0])); i++) {
    for (int i = 0; i < (int)(sizeof(laserPixels) / sizeof(laserPixels[0])); i++) {
        if ((x + laserPixels[i] >= rect->x) && ((x + laserPixels[i]) < (rect->x + rect->w)) &&
                (y >= rect->y) && (y < (rect->y + rect->h)))
        {


@@ 116,7 116,7 @@ void Laser_Init() {
}

void Laser_Add(float x, float y) {
    if (lasers.count() >= laserMax) {
    if ((int)lasers.count() >= laserMax) {
        return;
    }
    lasers.add(Laser(x, y));

M logo.cpp => logo.cpp +1 -1
@@ 123,7 123,7 @@ int Logo_Run(void) {
            break;

        case STATE_LOGO_RUN:
            if (cursor < (sizeof(timings) / sizeof(timings[0]))) {
            if (cursor < (int)(sizeof(timings) / sizeof(timings[0]))) {
                timer += Speed_Multiplier();
                if (timer > timings[cursor]) {
                    Logo_LoadFrame(cursor++);

M menu.cpp => menu.cpp +1 -2
@@ 44,7 44,6 @@

static float timer;
static float frames; 
static int menuCursor = 0;
int cutscene = 1;

#define CHIP_XPOS (WINDOW_LOWIDTH - CHIP_WIDTH - 16)


@@ 80,7 79,7 @@ Star::Star() :
	source.h = STAR_HEIGHT;
	

    if (starColor >= starTextures.size()) {
    if (starColor >= (int)starTextures.size()) {
        starColor = 0;
    }
	

M palette.cpp => palette.cpp +1 -1
@@ 52,7 52,7 @@ void Palette::init(SDL_Surface *surface, std::vector<uint32_t> &colorPal) {
    }

    for (int i = 0; i < (original->w * original->h); i++) {
        for (int j = 0; j < colorPal.size(); j++) {
        for (int j = 0; j < (int)colorPal.size(); j++) {
            if (((uint32_t *)original->pixels)[i] == colorPal[j]) {
                colors.push_back({i, j});
            }

M sprite.cpp => sprite.cpp +0 -6
@@ 34,12 34,6 @@
#include "sprite.h"
#include "util.h"

typedef enum {
    DISPLAY_HIRES = 0,
    DISPLAY_LORES,
} DISPLAY_MODES;
static int displayMode = DISPLAY_LORES;

SpriteInfo::SpriteInfo(SDL_Texture *tex, SDL_Rect *src, SDL_Rect *dimensions) {
    display = 1;
    texture = tex;

M tutorial.cpp => tutorial.cpp +3 -3
@@ 289,7 289,7 @@ static void dispTopDoor(int x, int y, int num, int open) {

	int clipping = open % DOOR_ROW_HEIGHT;

	for (int i = open / DOOR_ROW_HEIGHT; i < ARRAY_LENGTH(topDoor); i++) {
	for (int i = open / DOOR_ROW_HEIGHT; i < (int)ARRAY_LENGTH(topDoor); i++) {
		dispDoorRow(x, yCursor, clipping, 0, topDoor[i]);
		yCursor += DOOR_ROW_HEIGHT - clipping;
		clipping = 0; // clipping only matters for the highest row


@@ 444,7 444,7 @@ int Tutorial_Run() {
		}
	}
	// next, preview every level in order
	else if (levels.size() < displayedLevels) {
	else if ((int)levels.size() < displayedLevels) {
		if ((levels.size() == 0) || levels.back()->doneLoad()) {
			levels.push_back(std::make_unique<Level>(WALL_XPOS + doorXPos[levels.size()],
				WALL_YPOS + doorYPos[levels.size()], currLevel + levels.size(), BLOCK_MODE_TUTORIAL));


@@ 461,7 461,7 @@ int Tutorial_Run() {
		dispDoor(WALL_XPOS + doorXPos[i], WALL_YPOS + doorYPos[i], i + 1, doorOpen[i]);
	}

	for (int i = 0; i < levels.size(); i++) {
	for (int i = 0; i < (int)levels.size(); i++) {
		levels[i]->disp();
	}