Skip to content
Draft
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 Classes/framewrk/sprite.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include "frm_int.hpp"
#include <stdlib.h>

/* Widescreen support */
#include <PlatformConfig.h>
Cspr_frame::Cspr_frame(COMP_SPRITE *dc, UINT16 w, UINT16 h, INT16 hx, INT16 hy)
{
}
Expand Down
12 changes: 8 additions & 4 deletions Classes/framewrk/video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,10 @@ void Cvideo::swap(void)

if((g_RenderMode%NUMRENDERMODES)==0) // nearest neigbour
{
for (unsigned int y = 0; y < 480; y++) {
for (unsigned int x = 0; x < (640>>5); x++) {
/* Widescreen support: Use dynamic width from this->width instead of hardcoded 640 */
unsigned int pixelsPerRow = this->width;
for (unsigned int y = 0; y < this->height; y++) {
for (unsigned int x = 0; x < (pixelsPerRow>>5); x++) {
// *DestBuf++ = m_DibPalette32[*SrcPtr++];
UNROLL32
}
Expand Down Expand Up @@ -455,21 +457,23 @@ void Cvideo::DisplayChars(unsigned char *Cijfers, int x, int y)
ScreenPtr = Screen;
CharsetPtr = charset + (Cijfer*36);

/* Widescreen support: Use dynamic width instead of hardcoded 640 */
unsigned int screenWidth = this->width;
for(y=0;y<6;y++)
{
for(x=0;x<6;x++)
{
*ScreenPtr++ = *CharsetPtr;
*ScreenPtr++ = *CharsetPtr++;
}
ScreenPtr += (640-12);
ScreenPtr += (screenWidth-12);
CharsetPtr-=6;
for(x=0;x<6;x++)
{
*ScreenPtr++ = *CharsetPtr;
*ScreenPtr++ = *CharsetPtr++;
}
ScreenPtr += (640-12);
ScreenPtr += (screenWidth-12);
}
Screen+= 14;
Index--;
Expand Down
20 changes: 16 additions & 4 deletions Classes/moonchild/globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,19 @@ UINT32 blackdiamondlocations[13][7]; //7 per level... 13 levels
UINT32 blackdiamondcollocations[13][7]; //7 per level... 13 levels


/* editor variables */
/* Widescreen support - 16:9 aspect ratio */
#define MC_BASE_WIDTH 640
#define MC_BASE_HEIGHT 480
/* Widescreen adds 224 pixels horizontally (640 + 224 = 864, which is 16:9 with 480 height) */
#define MC_WIDESCREEN_PADDING 112

/* editor variables - now dynamically sized for widescreen */

UINT16 cliptlx = 0;
UINT16 cliptly = 0;
UINT16 clipbrx = 640;
UINT16 clipbry = 480;
/* clipbrx/clipbry are now dynamically set based on game mode */
UINT16 clipbrx = MC_BASE_WIDTH + (2 * MC_WIDESCREEN_PADDING);
UINT16 clipbry = MC_BASE_HEIGHT;

UINT16 sokomoved;
UINT16 editflg = 0; /* we don't start of in the editor */
Expand Down Expand Up @@ -380,7 +387,7 @@ PREFS defprefs = {
// 300,
// 400,

0,0,640,480,
0,0,640 + (2 * MC_WIDESCREEN_PADDING),480, // Extended for widescreen

PREFS_HIRES,
// 'J',
Expand Down Expand Up @@ -409,6 +416,11 @@ PREFS defprefs = {
// 'a',
// 'd',
// 's'

// Widescreen support fields
MC_BASE_WIDTH,
MC_BASE_HEIGHT,
MC_WIDESCREEN_PADDING
};

PREFS *prefs = &defprefs;
Expand Down
16 changes: 11 additions & 5 deletions Classes/moonchild/mc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ int FirstTimeShowCredzFlg;
#include <stdio.h>
#include <string.h>

/* Widescreen support */
#include <PlatformConfig.h>

/* Widescreen menu centering offset */
#define MC_WIDESCREEN_MENU_OFFSET_X ((GAME_FRAMEBUFFER_WIDTH - GAME_FRAMEBUFFER_BASE_WIDTH) / 2)

//#include <direct.h>
//#include <iostream.h>
#include <stdlib.h>
Expand Down Expand Up @@ -835,9 +841,9 @@ HEARTBEAT_FN MC_testje1(void)


video->palette(titlepal);
titlepic->draw_nokey(*vidblitbuf,0,0,0,0,640,480);
titlepic->draw_nokey(*vidblitbuf,MC_WIDESCREEN_MENU_OFFSET_X,0,0,0,640,480);
video->swap();
titlepic->draw_nokey(*vidblitbuf,0,0,0,0,640,480);
titlepic->draw_nokey(*vidblitbuf,MC_WIDESCREEN_MENU_OFFSET_X,0,0,0,640,480);


return (HEARTBEAT_FN) MC_testje2;
Expand Down Expand Up @@ -899,7 +905,7 @@ HEARTBEAT_FN framework_InitGame(Cvideo *newvideo, Caudio *newaudio, Ctimer *newt
video->scansync();

vidblitbuf = new Cblitbuf(video);
vidblitbuf->set_clipping(0, 0, 640, 480);
vidblitbuf->set_clipping(0, 0, GAME_FRAMEBUFFER_WIDTH, GAME_FRAMEBUFFER_HEIGHT);



Expand Down Expand Up @@ -7136,8 +7142,8 @@ HEARTBEAT_FN MC_menu(void)
keytab[CB_BACK] = 0;
if (menupoint == menu1)
{
titlepic->draw_nokey(*refreshpic, 0, 0, 0, 0, 640, 480);
menuleavefunc = (HEARTBEAT_FN) MC_leavemenu;
titlepic->draw_nokey(*refreshpic, MC_WIDESCREEN_MENU_OFFSET_X, 0, 0, 0, 640, 480);
menuleavefunc = (HEARTBEAT_FN) MC_leavemenu;
}
if (menupoint == menu12 || menupoint == menu13)
{
Expand Down
25 changes: 18 additions & 7 deletions Classes/moonchild/objects.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#include <objects.hpp>
#include <hoi.hpp>
#include <sound.hpp>
#include <prefs.hpp>

/* Widescreen support */
#include <PlatformConfig.h>


static void object_process(int (*process)(VG_DLL_ITEM *));
Expand Down Expand Up @@ -218,15 +222,22 @@ int cb_object_visualise(VG_DLL_ITEM *item)
x = obj->x - curplayer->worldx - curplayer->quakex;
y = obj->y - curplayer->worldy - curplayer->quakey;

#if 0
if (x > /*curplayer->worldx*/ + 630) return 0;
if (x < 0/*curplayer->worldx*/ ) return 0;
if (y > curplayer->curmap->mapsizey + 32) return 0;
#endif
/* Widescreen support: Extended culling bounds for 16:9 aspect ratio */
/* Use prefs screenwidth for dynamic sizing - adds padding on each side */
INT16 screen_width = prefs->screenwidth;

/* New widescreen culling: Only cull objects that are completely off-screen */
/* Allow objects down to -112 on the left edge to prevent "edge freeze" */
INT16 widescreen_left_bound = -GAME_FRAMEBUFFER_WIDESCREEN_PADDING;
if (x > screen_width) return 0; // Culled if completely past right edge
if (x < widescreen_left_bound - 32) return 0; // Culled if completely past left edge (-144)

/* Widescreen: Apply +112px camera offset to match tile rendering */
INT16 widescreen_cam_offset = GAME_FRAMEBUFFER_WIDESCREEN_PADDING; // +112

if (obj->blitsizex && obj->blitsizey)
{
if (obj->frame->draw(*curplayer->loadedmap->blitbuf,x , y,
if (obj->frame->draw(*curplayer->loadedmap->blitbuf, x + widescreen_cam_offset, y,
obj->blitstartx, obj->blitstarty,
obj->blitstartx+obj->blitsizex, obj->blitstarty+obj->blitsizey))
{
Expand All @@ -239,7 +250,7 @@ int cb_object_visualise(VG_DLL_ITEM *item)
}
else /* no size override */
{
if ( obj->frame->draw(*curplayer->loadedmap->blitbuf,x , y ))
if ( obj->frame->draw(*curplayer->loadedmap->blitbuf, x + widescreen_cam_offset, y ))
{
if (obj->visible<1024) obj->visible++;
}
Expand Down
11 changes: 11 additions & 0 deletions Classes/moonchild/prefs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ void prefs_calcvals(void);
#define PREFS_LORES 0
#define PREFS_HIRES 1

/* Widescreen support - 16:9 aspect ratio */
#define MC_BASE_WIDTH 640
#define MC_BASE_HEIGHT 480
/* Widescreen adds 224 pixels horizontally (640 + 224 = 864, which is 16:9 with 480 height) */
#define MC_WIDESCREEN_PADDING 112

struct PREFS
{
UINT16 screentopx;
Expand All @@ -23,6 +29,11 @@ struct PREFS
UINT16 downkey;
UINT16 jumpkey;
UINT16 shootkey;

/* Widescreen support - these are computed from base + padding */
UINT16 basewidth;
UINT16 baseheight;
UINT16 widescreenpadding;
};


Expand Down
42 changes: 32 additions & 10 deletions Classes/moonchild/score.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
#include <sokoban.hpp>
#include <boss.hpp>
#include <sound.hpp>
#include <PlatformConfig.h>

/* Widescreen support: HUD anchoring offset */
/* Original 4:3: HUD at X=70 | Widescreen: shift to align with new left edge */
#define MC_WIDESCREEN_HUD_OFFSET_X (-112) /* Offset from original 640-based positioning */
#define MC_WIDESCREEN_HUD_OFFSET_Y 0 /* Y stays same for 480 height */
#define MC_HUD_BASE_X 70

// 7x9
static const char* smallfont[] =
Expand Down Expand Up @@ -223,6 +230,14 @@ void score_display(VIEWPORT *player)
UINT16 holdcnt;
static UINT16 diamondknip;

/* Widescreen support: Calculate HUD offset based on actual screen width */
INT16 hudOffsetX = 0;
if (prefs != nullptr && prefs->screenwidth > MC_HUD_BASE_X + 400)
{
/* Widescreen detected: center HUD or keep left-aligned with padding */
hudOffsetX = (prefs->screenwidth - GAME_FRAMEBUFFER_WIDTH) / 2;
}

holdcnt = 0;

if (scoreshift) scoreshift--;
Expand Down Expand Up @@ -265,7 +280,8 @@ void score_display(VIEWPORT *player)

// if (world !=3)
{
frame->draw(*player->loadedmap->blitbuf,70 + (0*40) + ((sinus512[xcnt]*10)>>10) - scoreshift, 414 + ((sinus512[ycnt]*10)>>10) );
/* Widescreen: Apply HUD offset */
frame->draw(*player->loadedmap->blitbuf, hudOffsetX + 70 + (0*40) + ((sinus512[xcnt]*10)>>10) - scoreshift, 414 + ((sinus512[ycnt]*10)>>10) );
}


Expand All @@ -276,9 +292,10 @@ void score_display(VIEWPORT *player)

frame = anim_setsequence(orgheart, 0, SEQ_FORCE);
frame = anim_forceframe (orgheart, 16 - (player->energy >> 1));
frame->draw(*player->loadedmap->blitbuf,70 + (1*40) + ((sinus512[xcnt]*10)>>10) - scoreshift, 414 + ((sinus512[ycnt]*10)>>10) );
/* Widescreen: Apply HUD offset */
frame->draw(*player->loadedmap->blitbuf, hudOffsetX + 70 + (1*40) + ((sinus512[xcnt]*10)>>10) - scoreshift, 414 + ((sinus512[ycnt]*10)>>10) );

scoreposhold[holdcnt ] = 70 + (1*40) + ((sinus512[xcnt]*10)>>10) - scoreshift + 8;
scoreposhold[holdcnt ] = hudOffsetX + 70 + (1*40) + ((sinus512[xcnt]*10)>>10) - scoreshift + 8;
scoreposhold[holdcnt+1 ] = 414 + ((sinus512[ycnt]*10)>>10) + 8;
holdcnt+=2;

Expand Down Expand Up @@ -326,15 +343,16 @@ void score_display(VIEWPORT *player)
frame = anim_forceframe (orgdiamond, 1);
}

scoreposhold[holdcnt ] = 70 + (i*40) + ((sinus512[xcnt]*10)>>10);
scoreposhold[holdcnt ] = hudOffsetX + 70 + (i*40) + ((sinus512[xcnt]*10)>>10);
scoreposhold[holdcnt+1 ] = 414 + ((sinus512[ycnt]*10)>>10) + scoreshift;
holdcnt+=2;

if (player->nrofblack )
{
if (world !=3)
{
frame->draw(*player->loadedmap->blitbuf,70 + (i*40) + ((sinus512[xcnt]*10)>>10), 414 + ((sinus512[ycnt]*10)>>10) + scoreshift );
/* Widescreen: Apply HUD offset */
frame->draw(*player->loadedmap->blitbuf, hudOffsetX + 70 + (i*40) + ((sinus512[xcnt]*10)>>10), 414 + ((sinus512[ycnt]*10)>>10) + scoreshift );
}
}
else
Expand All @@ -348,23 +366,26 @@ void score_display(VIEWPORT *player)
frame = anim_forceframe (orgdiamond, 1);
if (world !=3)
{
frame->draw(*player->loadedmap->blitbuf,70 + (i*40) + ((sinus512[xcnt]*10)>>10), 414 + ((sinus512[ycnt]*10)>>10) + scoreshift );
/* Widescreen: Apply HUD offset */
frame->draw(*player->loadedmap->blitbuf, hudOffsetX + 70 + (i*40) + ((sinus512[xcnt]*10)>>10), 414 + ((sinus512[ycnt]*10)>>10) + scoreshift );
}
}
else if ((i-3) == (((diamondknip-4)&31)/4))
{
frame = anim_forceframe (orgdiamond, 1);
if (world !=3)
{
frame->draw(*player->loadedmap->blitbuf,70 + (i*40) + ((sinus512[xcnt]*10)>>10), 414 + ((sinus512[ycnt]*10)>>10) + scoreshift );
/* Widescreen: Apply HUD offset */
frame->draw(*player->loadedmap->blitbuf, hudOffsetX + 70 + (i*40) + ((sinus512[xcnt]*10)>>10), 414 + ((sinus512[ycnt]*10)>>10) + scoreshift );
}
}
else
{
frame = anim_forceframe (orgdiamond, 0);
if (world !=3)
{
frame->draw(*player->loadedmap->blitbuf,70 + (i*40) + ((sinus512[xcnt]*10)>>10), 414 + ((sinus512[ycnt]*10)>>10) + scoreshift );
/* Widescreen: Apply HUD offset */
frame->draw(*player->loadedmap->blitbuf, hudOffsetX + 70 + (i*40) + ((sinus512[xcnt]*10)>>10), 414 + ((sinus512[ycnt]*10)>>10) + scoreshift );
}
}
}
Expand Down Expand Up @@ -445,9 +466,10 @@ void score_display(VIEWPORT *player)
frame = anim_forceframe (orgcolormond, player->newlife/2);
if (world !=3)
{
frame->draw(*player->loadedmap->blitbuf,70 + (11*40) + ((sinus512[xcnt]*10)>>10) + scoreshift, 414 + ((sinus512[ycnt]*10)>>10) );
/* Widescreen: Apply HUD offset */
frame->draw(*player->loadedmap->blitbuf, hudOffsetX + 70 + (11*40) + ((sinus512[xcnt]*10)>>10) + scoreshift, 414 + ((sinus512[ycnt]*10)>>10) );
}
scoreposhold[holdcnt ] = 70 + (11*40) + ((sinus512[xcnt]*10)>>10) + scoreshift+8;
scoreposhold[holdcnt ] = hudOffsetX + 70 + (11*40) + ((sinus512[xcnt]*10)>>10) + scoreshift+8;
scoreposhold[holdcnt+1 ] = 414 + ((sinus512[ycnt]*10)>>10)+8;
holdcnt+=2;

Expand Down
Loading