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

Feature: Enable/Disable in game messaging. #147

Merged
merged 1 commit into from
Jul 15, 2024
Merged
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
12 changes: 10 additions & 2 deletions ab3d2_source/c/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#define MSG_LENGTH_MASK 0x3FFF
#define MSG_TAG_SHIFT 14

extern UBYTE Prefs_ShowMessages_b;

extern UBYTE Vid_FullScreen_b;
extern UWORD Vid_LetterBoxMarginHeight_w;
extern void* Lvl_DataPtr_l;
Expand Down Expand Up @@ -151,6 +153,10 @@ void Msg_Init(void)
*/
void Msg_PushLine(REG(a0, const char* textPtr), REG(d0, UWORD lengthAndTag))
{
if (!Prefs_ShowMessages_b) {
return;
}

UWORD textLength = lengthAndTag & MSG_LENGTH_MASK;
UWORD maxFit = Vid_FullScreen_b ?
msg_Buffer.guranteedTextFitLimitFullScreen :
Expand Down Expand Up @@ -189,8 +195,10 @@ void Msg_PushLine(REG(a0, const char* textPtr), REG(d0, UWORD lengthAndTag))
void Msg_PushLineDedupLast(REG(a0, const char* textPtr), REG(d0, UWORD lengthAndTag))
{
if (
textPtr != msg_Buffer.lastMessagePtr ||
Sys_CheckTimeGE(&Sys_FrameTimeECV_q[0], &msg_Buffer.nextDuplicateTickECV)
Prefs_ShowMessages_b && (
textPtr != msg_Buffer.lastMessagePtr ||
Sys_CheckTimeGE(&Sys_FrameTimeECV_q[0], &msg_Buffer.nextDuplicateTickECV)
)
) {
msg_Buffer.nextDuplicateTickECV = Sys_FrameTimeECV_q[0];
Sys_AddTime(&msg_Buffer.nextDuplicateTickECV, msg_Buffer.deduplicationPeriod);
Expand Down
6 changes: 6 additions & 0 deletions ab3d2_source/c/message.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,10 @@ extern BOOL Msg_SmallScreenNeedsRedraw(void);

extern void Msg_Tick(void);

static __inline BOOL Msg_Enabled(void) {
extern UBYTE Prefs_ShowMessages_b;
return Prefs_ShowMessages_b;
}


#endif // MESSAGE_H
10 changes: 6 additions & 4 deletions ab3d2_source/c/screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ static void CopyFrameBuffer(UBYTE *dst, const UBYTE *src, WORD dstBytesPerRow, W

void Vid_Present()
{
if (Vid_FullScreen_b) {
if (Vid_FullScreen_b && Msg_Enabled()) {
/** Render any buffered up messages before we submit the screen */
Msg_RenderFullscreen();
}
Expand Down Expand Up @@ -506,7 +506,7 @@ void Vid_Present()

CopyFrameBuffer(dst, src, bmBytesPerRow, SMALL_WIDTH, height);

if (Msg_SmallScreenNeedsRedraw()) {
if (Msg_Enabled() && Msg_SmallScreenNeedsRedraw()) {
Msg_RenderSmallScreenRTG(bmPixelData, bmBytesPerRow);
}
}
Expand All @@ -522,7 +522,7 @@ void Vid_Present()
#endif
} else {
CallAsm(&Vid_ConvertC2P);
if (!Vid_FullScreen_b && Msg_SmallScreenNeedsRedraw()) {
if (!Vid_FullScreen_b && Msg_Enabled() && Msg_SmallScreenNeedsRedraw()) {
PLANEPTR planes[3] = {
Draw_FastRamPlanePtr,
&Vid_Screen1Ptr_l[PLANE_OFFSET(DRAW_TEXT_PLANE_NUM) + DRAW_TEXT_SMALL_PLANE_OFFSET ],
Expand All @@ -539,5 +539,7 @@ void Vid_Present()
}
Draw_UpdateBorder_Planar();
}
Msg_Tick();
if (Msg_Enabled()) {
Msg_Tick();
}
}
5 changes: 4 additions & 1 deletion ab3d2_source/controlloop.s
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ Prefs_Unused_b: dc.b 0
Prefs_CustomOptionsBuffer_vb:
Prefs_OriginalMouse_b: dc.b 0
Prefs_AlwaysRun_b: dc.b 0
DECLC Prefs_ShowMessages_b
dc.b 255

align 4
_Prefs_PersistedEnd::
Expand Down Expand Up @@ -562,7 +564,7 @@ customOptions:
; copy current setting over to menu
move.l #Prefs_CustomOptionsBuffer_vb,a0
move.l #optionLines+17,a1
moveq #1,d1
moveq #2,d1
.copyOpts:
move.b (a0)+,d0

Expand Down Expand Up @@ -601,6 +603,7 @@ customOptions:
.co3:
cmp.w #2,d0
bne.s .co4
not.b Prefs_ShowMessages_b
bra .w8
.co4:
cmp.w #3,d0
Expand Down
4 changes: 2 additions & 2 deletions ab3d2_source/menu/menunb.s
Original file line number Diff line number Diff line change
Expand Up @@ -1768,7 +1768,7 @@ mnu_MYCUSTOMOPTSTEXT:
optionLines: ;12345678901234567890
dc.b ' ORIGINAL MOUSE ',1;OFF ',1
dc.b ' ALWAYS RUN ',1;OFF ',1
dc.b ' OPTION 3 ',1;OFF ',1
dc.b ' SHOW MESSAGES ',1;OFF ',1
dc.b ' OPTION 4 ',1;OFF ',1
dc.b ' OPTION 5 ',1
dc.b ' OPTION 6 ',1
Expand Down Expand Up @@ -1800,7 +1800,7 @@ KEY_LINES:
dc.b ' FORCE S/S ',132+$67,' ',1
dc.b ' S/S LEFT ',132+$39,' ',1
dc.b ' S/S RIGHT ',132+$3a,' ',1
dc.b ' DUCK ',132+$22,' ',1
dc.b ' CROUCH ',132+$22,' ',1
dc.b ' MORE ',0

EVEN
Expand Down