Skip to content

Commit

Permalink
sf2d disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
esoteric-programmer committed Oct 19, 2016
1 parent 0c41285 commit a185cc1
Show file tree
Hide file tree
Showing 16 changed files with 1,723 additions and 1,222 deletions.
2 changes: 1 addition & 1 deletion doc/data/minimap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ Consider the following lines:
For each line, consider 16 pixels in a row.
Count the number of non-zero pixels.
If at least 9 of these 16 pixels are non-zero,
draw a colored pixel intpo the minimap.
draw a colored pixel into the minimap.
Otherwise leave it black.

109 changes: 83 additions & 26 deletions include/draw.h
Original file line number Diff line number Diff line change
@@ -1,51 +1,108 @@
#ifndef DRAW_H
#define DRAW_H
#include <3ds.h>
#include <sf2d.h>
#include "settings.h"
#include "main_data.h"
#include "level.h"
#include "lemming_data.h"

// data structure for RGB image.
// (almost) all game graphics are drawn to this data structure before a sf2dtexture will be created from it.
struct RGB_Image {
s16 width;
s16 height;
u32 data[0];
};
typedef enum
{
TOP_SCREEN = 0,
BOTTOM_SCREEN = 1,
TOP_SCREEN_BACK = 2,
BOTTOM_SCREEN_BACK = 3
} ScreenBuffer;

// scale with linear interpolation (sf2d seems o scale without interpolation)
void scale(struct RGB_Image* dest, float factor, struct RGB_Image* source);
void init_drawing();

void begin_frame();
void end_frame();

// apply fading to palette (not its alpha value, since gfx seems to ignore alpha value)
void fade_palette(u32 palette[16], float fading);

// scale with linear interpolation
int draw_scaled(
ScreenBuffer screen,
s16 x,
s16 y,
const u8* img,
u16 w,
u16 h,
u32 palette[16],
float scaling);

int clear(ScreenBuffer screen);
int clear_rectangle(ScreenBuffer screen, u16 x, u16 y, u16 w, u16 h);
void copy_from_backbuffer(ScreenBuffer screen);

// draw palette image into RGB image at specific position
int draw(struct RGB_Image* image, u32 palette[16], const u8* img, s16 x, s16 y, u16 w, u16 h);
int draw(ScreenBuffer screen, s16 x, s16 y, const u8* img, u16 w, u16 h, u32 palette[16]);

// draw menu background into im_bottom (tiled)
void tile_menu_background(ScreenBuffer screen, struct MainMenuData* menu_data);

// draw level view at top of RGB image while (without info text, toolbar, and lemmings)
int draw_level(struct RGB_Image* image, struct Level* level);
int draw_level(
ScreenBuffer screen,
s16 x,
s16 y,
u16 w,
u16 h,
struct Level* level,
struct Lemming lemmings[MAX_NUM_OF_LEMMINGS],
struct MainInGameData* main_data,
u32* palette);


// draw a string using highperf-font into an RGB image
void draw_highperf_text(struct RGB_Image* image, struct MainInGameData* data,
s16 y_offset, const char* text);
void draw_highperf_text(
ScreenBuffer screen,
s16 x,
s16 y,
struct MainInGameData* data,
const char* text,
u32* highperf_palette);

// draw a string using menu-font into an RGB image
void draw_menu_text(struct RGB_Image* image, struct MainMenuData* data,
s16 x_offset, s16 y_offset, const char* text);
void draw_menu_text(
ScreenBuffer screen,
struct MainMenuData* data,
s16 x_offset,
s16 y_offset,
const char* text,
u32* palette);

// draw a string using scaled (interpolated) menu-font into an RGB image
void draw_menu_text_small(struct RGB_Image* image, struct MainMenuData* data,
s16 x_offset, s16 y_offset, const char* text);
void draw_menu_text_small(
ScreenBuffer screen,
struct MainMenuData* data,
s16 x_offset,
s16 y_offset,
const char* text,
u32* palette);

// draw toolbar at bottom of RGB image
int draw_toolbar(struct RGB_Image* image, struct MainInGameData* data,
struct Level* level, struct LevelState* state,
struct Lemming[MAX_NUM_OF_LEMMINGS], const char* text);
int draw_toolbar(
struct MainInGameData* data,
struct Level* level,
struct LevelState* state,
struct Lemming[MAX_NUM_OF_LEMMINGS],
const char* text,
u32* highperf_palette);

// return number of lemmings drawn
u8 draw_lemmings(struct Lemming[MAX_NUM_OF_LEMMINGS], struct Image* lemmings_anim[337], struct Image* masks[23], u32 palette[16], struct RGB_Image* image, u16 x_offset);

// draw menu background into im_bottom (tiled)
void tile_menu_background(struct RGB_Image* im_bottom, struct MainMenuData* menu_data);
u8 draw_lemmings(
ScreenBuffer screen,
s16 x,
s16 y,
struct Lemming[MAX_NUM_OF_LEMMINGS],
struct Image* lemmings_anim[337],
struct Image* masks[23],
u32 palette[16],
s16 x_offset,
s16 y_offset);

int draw_topscreen(struct MainMenuData* menu, struct RGB_Image* im_top, sf2d_texture** texture_top_screen, struct RGB_Image* logo_scaled, sf2d_texture** texture_logo);
int update_topscreen(struct MainMenuData* menu);
#endif
1 change: 1 addition & 0 deletions include/gamespecific.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ struct GameSpecific {
const u8 num_of_difficulties;
const u8 num_of_level_per_difficulty;
const char* const path;
const char* const custom_audio_path;
const char* const level_dat_prefix;
const char* const* const difficulties;
const unsigned char* const level_position;
Expand Down
16 changes: 9 additions & 7 deletions include/ingame.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef INGAME_H
#define INGAME_H
#include <3ds.h>
#include <sf2d.h>
#include "level.h"
#include "main_data.h"
#include "draw.h"
Expand All @@ -20,12 +19,15 @@ struct LevelResult {
};

// returns: percentage saved
struct LevelResult run_level(u8 game, u8 lvl,
struct MainInGameData* main_data,
sf2d_texture* texture_top_screen, sf2d_texture* texture_logo);

int show_result(u8 game, struct LevelResult result,
struct LevelResult run_level(
u8 game,
u8 lvl,
struct MainMenuData* menu_data,
sf2d_texture** texture_logo, sf2d_texture** texture_top_screen);
struct MainInGameData* main_data);

int show_result(
u8 game,
struct LevelResult result,
struct MainMenuData* menu_data);

#endif
3 changes: 3 additions & 0 deletions include/lemming.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ u8 select_lemming(struct Lemming[MAX_NUM_OF_LEMMINGS], s16 x, s16 y, u8 right_mo
u8 assign_skill(u8 skill, struct Lemming* lem1, struct Lemming* lem2, struct Level*);

const char* get_lemming_description(struct Lemming*); // returns ptr to pre-initialized string (no heap is reserved, do not free the pointer)

// get number of lemmings alive
int count_lemmings(struct Lemming lemmings[MAX_NUM_OF_LEMMINGS]);
#endif
4 changes: 4 additions & 0 deletions include/main.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#ifndef MAIN_H
#define MAIN_H
int was_suspended();
#endif
22 changes: 14 additions & 8 deletions include/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,20 @@
#define RESULT_ACTION_CANCEL 7
#define MENU_EXIT_GAME 127

int main_menu(u8 games[], u8* game, int* lvl,
struct MainMenuData* menu_data, struct MainInGameData* main_data,
struct RGB_Image* im_top, struct RGB_Image* logo_scaled,
sf2d_texture** texture_logo, sf2d_texture** texture_top_screen);
int main_menu(
u8 games[],
u8* game,
int* lvl,
struct MainMenuData* menu_data,
struct MainInGameData* main_data);

int level_select_menu(u8 games[], u8* game, int* lvl, u8* progress, const char* level_names,
struct MainMenuData* menu_data, struct MainInGameData* main_data,
struct RGB_Image* im_top, struct RGB_Image* logo_scaled,
sf2d_texture** texture_logo, sf2d_texture** texture_top_screen);
int level_select_menu(
u8 games[],
u8* game,
int* lvl,
u8* progress,
const char* level_names,
struct MainMenuData* menu_data,
struct MainInGameData* main_data);

#endif
17 changes: 13 additions & 4 deletions include/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,27 @@
#define SETTINGS_H
#include <3ds.h>

#define NO_SF2D

#define LEMMINGS_DIR "/lemmings" // if it does not exist, "." will be used instead
extern const char* PATH_ROOT;

#define MAX_NUM_OF_LEMMINGS 80
#define FPS 17
#define FPS 17 // dosframes per second (for time counter in level)
#define SCREEN_WIDTH 320
#define FRAMES_PER_DOS_FRAME 3 // slow down 3ds animation...
#define FADE_IN_FRAMES (18 * FRAMES_PER_DOS_FRAME) // duration of fade-in (level start)
#define FADE_OUT_FRAMES (32 * FRAMES_PER_DOS_FRAME) // duration of fade-out (level end)
#define MS_PER_FRAME 71 // duration of frame in milliseconds
#define MS_PER_FRAME_SUPERLEM 28 // frame duration in "introducing superlemming"
#define INPUT_SAMPLING_MILLIS 25 // affects cursor speed and so on...
#define MS_PER_FRAME_SPEED_UP 20
#define FADE_IN_DOSFRAMES 18
#define FADE_OUT_DOSFRAMES 32

#define ENABLE_NUKE_GLITCH 1
#define ENABLE_ENTRANCE_PAUSING_GLITCH 1
#define ENABLE_SHRUGGER_GLITCH 0
#define ENABLE_MINING_ONEWAY_BUG 1

#ifdef NO_SF2D
#define ABGR
#endif
#endif
Loading

0 comments on commit a185cc1

Please sign in to comment.