Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sweep: Port this for M5Stack Cardputer #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doomgeneric/doomgeneric.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<DisableSpecificWarnings>4146;4996</DisableSpecificWarnings>
<AdditionalIncludeDirectories>$(M5StackSDK)\include</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand All @@ -106,6 +107,7 @@
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<DisableSpecificWarnings>4146;4996</DisableSpecificWarnings>
<AdditionalIncludeDirectories>$(M5StackSDK)\include</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand All @@ -123,6 +125,7 @@
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<DisableSpecificWarnings>4146;4996</DisableSpecificWarnings>
<AdditionalIncludeDirectories>$(M5StackSDK)\include</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand Down
7 changes: 7 additions & 0 deletions doomgeneric/i_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ int vanilla_keyboard_mapping = 1;

static int shiftdown = 0;

static int ReadButton(int buttonPin)
{
return digitalRead(buttonPin);
}

// Lookup table for mapping AT keycodes to their doom keycode
static const char at_to_doom[] =
{
Expand Down Expand Up @@ -278,6 +283,8 @@ static void UpdateShiftStatus(int pressed, unsigned char key)

void I_GetEvent(void)
{
I_GetM5StackButtons();

event_t event;
int pressed;
unsigned char key;
Expand Down
9 changes: 9 additions & 0 deletions doomgeneric/i_sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ static void InitSfxModule(boolean use_sfx_prefix)
if (sound_modules[i]->Init(use_sfx_prefix))
{
sound_module = sound_modules[i];

// Initialize M5Stack speaker
M5.Speaker.begin();
M5.Speaker.mute();

return;
}
}
Expand All @@ -161,6 +166,10 @@ static void InitMusicModule(void)

void I_InitSound(boolean use_sfx_prefix)
{
// Initialize M5Stack speaker
M5.Speaker.begin();
M5.Speaker.mute();

boolean nosound, nosfx, nomusic;

//!
Expand Down
29 changes: 17 additions & 12 deletions doomgeneric/i_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,24 +176,26 @@ void cmap_to_fb(uint8_t * out, uint8_t * in, int in_pixels)

void I_InitGraphics (void)
{
// Initialize M5Stack display
M5.begin();
M5.Lcd.fillScreen(TFT_BLACK);

int i;

memset(&s_Fb, 0, sizeof(struct FB_ScreenInfo));
s_Fb.xres = DOOMGENERIC_RESX;
s_Fb.yres = DOOMGENERIC_RESY;
s_Fb.xres = M5STACK_SCREEN_WIDTH;
s_Fb.yres = M5STACK_SCREEN_HEIGHT;
s_Fb.xres_virtual = s_Fb.xres;
s_Fb.yres_virtual = s_Fb.yres;
s_Fb.bits_per_pixel = 32;

s_Fb.blue.length = 8;
s_Fb.green.length = 8;
s_Fb.red.length = 8;
s_Fb.transp.length = 8;
s_Fb.bits_per_pixel = 16;

s_Fb.blue.length = 5;
s_Fb.green.length = 6;
s_Fb.red.length = 5;

s_Fb.blue.offset = 0;
s_Fb.green.offset = 8;
s_Fb.red.offset = 16;
s_Fb.transp.offset = 24;
s_Fb.green.offset = 5;
s_Fb.red.offset = 11;


printf("I_InitGraphics: framebuffer: x_res: %d, y_res: %d, x_virtual: %d, y_virtual: %d, bpp: %d\n",
Expand Down Expand Up @@ -277,7 +279,7 @@ void I_FinishUpdate (void)
for (i = 0; i < fb_scaling; i++) {
line_out += x_offset;
#ifdef CMAP256
for (fb_scaling == 1) {
if (fb_scaling == 1) {
memcpy(line_out, line_in, SCREENWIDTH); /* fb_width is bigger than Doom SCREENWIDTH... */
} else {
//XXX FIXME fb_scaling support!
Expand All @@ -292,6 +294,9 @@ void I_FinishUpdate (void)
}

DG_DrawFrame();

// Write the frame buffer to the M5Stack display
M5.Lcd.drawRGBBitmap(0, 0, DG_ScreenBuffer, SCREENWIDTH, SCREENHEIGHT);
}

//
Expand Down