Skip to content

Commit

Permalink
[MZ] Some tweaks to UI rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFakeMontyOnTheRun committed Jun 30, 2024
1 parent eb4df7c commit 4ab377b
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 25 deletions.
2 changes: 1 addition & 1 deletion mz_frontend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ include_directories(src ../core/src ../core/include include ../common/include
${SDL2_INCLUDE_DIR}
)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSDLW -DENDIANESS_AWARE -DMONOCHROME_VECTORS -DEMBEDDED_DATA -DUSE_OWN_MIN_MAX -DRLE_COMPRESSED_MAPS -DSUPPORTS_ROOM_TRANSITION_ANIMATION -DSUPPORTS_HACKING_MINIGAME -DTRACE_OBJECTS_OVER_FLOOR -DCAN_PICK_OBJECT_AT_ANY_DISTANCE -DRES128X128 -Wall -Wextra -pedantic -Wunused-parameter -DXRES_FRAMEBUFFER=256 -DYRES_FRAMEBUFFER=192 -ggdb3 -DEMIT_QUIT_OPTION -DENDIANESS_AWARE -DSDL_DISABLE_IMMINTRIN_H")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSDLW -DENDIANESS_AWARE -DMONOCHROME_VECTORS -DEMBEDDED_DATA -DUSE_OWN_MIN_MAX -DRLE_COMPRESSED_MAPS -DSUPPORTS_ROOM_TRANSITION_ANIMATION -DSUPPORTS_HACKING_MINIGAME -DTRACE_OBJECTS_OVER_FLOOR -DCAN_PICK_OBJECT_AT_ANY_DISTANCE -DRES128X128 -Wall -Wextra -pedantic -Wunused-parameter -DXRES_FRAMEBUFFER=256 -DYRES_FRAMEBUFFER=160 -ggdb3 -DEMIT_QUIT_OPTION -DENDIANESS_AWARE -DSDL_DISABLE_IMMINTRIN_H")

find_package(SDL2 REQUIRED)

Expand Down
2 changes: 1 addition & 1 deletion mz_frontend/Makefile.286
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CFLAGS = -fomit-frame-pointer -fno-exceptions -ffast-math \
-Iinclude -I../core/include -I../common/include -IEngine3D \
-DMSDOS -DCLI_BUILD -DRES128X128 -DCAN_PICK_OBJECT_AT_ANY_DISTANCE -DENDIANESS_AWARE -DXRES=128 -DYRES=128\
-DSDLW -DENDIANESS_AWARE -DMONOCHROME_VECTORS -DEMBEDDED_DATA -DRLE_COMPRESSED_MAPS -DSUPPORTS_ROOM_TRANSITION_ANIMATION -DSUPPORTS_HACKING_MINIGAME -DTRACE_OBJECTS_OVER_FLOOR -DCAN_PICK_OBJECT_AT_ANY_DISTANCE -DRES128X128 -Wall -Wextra -pedantic -Wunused-parameter -DXRES_FRAMEBUFFER=256 -DYRES_FRAMEBUFFER=192 -DENDIANESS_AWARE \
-DSDLW -DENDIANESS_AWARE -DMONOCHROME_VECTORS -DEMBEDDED_DATA -DRLE_COMPRESSED_MAPS -DSUPPORTS_ROOM_TRANSITION_ANIMATION -DSUPPORTS_HACKING_MINIGAME -DTRACE_OBJECTS_OVER_FLOOR -DCAN_PICK_OBJECT_AT_ANY_DISTANCE -DRES128X128 -Wall -Wextra -pedantic -Wunused-parameter -DXRES_FRAMEBUFFER=256 -DYRES_FRAMEBUFFER=160 -DENDIANESS_AWARE \
-DSUPPORTS_ROOM_TRANSITION_ANIMATION -DSUPPORTS_ROOM_TRANSITION_ANIMATION -DENDIANESS_AWARE -DUSE_OWN_MIN_MAX \
-Iinclude -I../common/include -I../core/include -I../common/include -IEngine3D -I../core/include \
-I../common/include -I../core/include -Imenu/include -ISoundSystem -I../core/include -IEngine3D
Expand Down
2 changes: 1 addition & 1 deletion mz_frontend/Makefile.atari
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ CC = m68k-atari-mint-gcc
STRIP=m68k-atari-mint-strip
CFLAGS = -std=c99 -c -m68000 -s -fexpensive-optimizations -fomit-frame-pointer -Ofast \
-DATARIST -DCLI_BUILD -DRES128X128 -DCAN_PICK_OBJECT_AT_ANY_DISTANCE -DENDIANESS_AWARE -DXRES=128 -DYRES=128\
-DSDLW -DENDIANESS_AWARE -DMONOCHROME_VECTORS -DEMBEDDED_DATA -DRLE_COMPRESSED_MAPS -DSUPPORTS_ROOM_TRANSITION_ANIMATION -DSUPPORTS_HACKING_MINIGAME -DTRACE_OBJECTS_OVER_FLOOR -DCAN_PICK_OBJECT_AT_ANY_DISTANCE -DRES128X128 -Wall -Wextra -pedantic -Wunused-parameter -DXRES_FRAMEBUFFER=256 -DYRES_FRAMEBUFFER=192 -DENDIANESS_AWARE \
-DSDLW -DENDIANESS_AWARE -DMONOCHROME_VECTORS -DEMBEDDED_DATA -DRLE_COMPRESSED_MAPS -DSUPPORTS_ROOM_TRANSITION_ANIMATION -DSUPPORTS_HACKING_MINIGAME -DTRACE_OBJECTS_OVER_FLOOR -DCAN_PICK_OBJECT_AT_ANY_DISTANCE -DRES128X128 -Wall -Wextra -pedantic -Wunused-parameter -DXRES_FRAMEBUFFER=256 -DYRES_FRAMEBUFFER=160 -DENDIANESS_AWARE \
-DSUPPORTS_ROOM_TRANSITION_ANIMATION -DUSE_OWN_MIN_MAX \
-Iinclude -I../common/include -IAmigaVersion -I../core/include -I../common/include -IEngine3D -I../core/include -Isrc/AtariVersion \
-I../common/include -I../core/include -Imenu/include -ISoundSystem -IAtariVersion -I../core/include -IEngine3D
Expand Down
2 changes: 1 addition & 1 deletion mz_frontend/Makefile.ocs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CFLAGS = \
-Isrc -I../core/src -I../core/include -Iinclude -I../common/include \
-I../common/include -IAmigaVersion -I../core/include -I../common/include -IEngine3D -I../core/include -Isrc/AmigaVersion \
-Imenu/include -ISoundSystem \
-DSDLW -DENDIANESS_AWARE -DMONOCHROME_VECTORS -DEMBEDDED_DATA -DRLE_COMPRESSED_MAPS -DSUPPORTS_ROOM_TRANSITION_ANIMATION -DSUPPORTS_HACKING_MINIGAME -DTRACE_OBJECTS_OVER_FLOOR -DCAN_PICK_OBJECT_AT_ANY_DISTANCE -DRES128X128 -Wall -Wextra -pedantic -Wunused-parameter -DXRES_FRAMEBUFFER=256 -DYRES_FRAMEBUFFER=192 -DENDIANESS_AWARE \
-DSDLW -DENDIANESS_AWARE -DMONOCHROME_VECTORS -DEMBEDDED_DATA -DRLE_COMPRESSED_MAPS -DSUPPORTS_ROOM_TRANSITION_ANIMATION -DSUPPORTS_HACKING_MINIGAME -DTRACE_OBJECTS_OVER_FLOOR -DCAN_PICK_OBJECT_AT_ANY_DISTANCE -DRES128X128 -Wall -Wextra -pedantic -Wunused-parameter -DXRES_FRAMEBUFFER=256 -DYRES_FRAMEBUFFER=160 -DENDIANESS_AWARE \
-DCLI_BUILD -DINCLUDE_ITEM_DESCRIPTIONS -DAGA5BPP -DRES128X128 -DTRACE_OBJECTS_OVER_FLOOR -DUSE_OWN_MIN_MAX \
-DCAN_PICK_OBJECT_AT_ANY_DISTANCE -DUSE_FILLED_POLYS -DSUPPORTS_ROOM_TRANSITION_ANIMATION -DENDIANESS_AWARE

Expand Down
2 changes: 1 addition & 1 deletion mz_frontend/Makefile.sm4
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ CCFLAGS = -m68000 -Wall -Wextra -std=c99 -ffreestanding -fcommon -Ofast -Wno-un
-DSMD -fomit-frame-pointer -fno-exceptions -ffast-math \
-Iinclude -I../core/include -I../common/include -IEngine3D \
-DRES128X128 -DCAN_PICK_OBJECT_AT_ANY_DISTANCE -DENDIANESS_AWARE -DXRES=128 -DYRES=128\
-DENDIANESS_AWARE -DMONOCHROME_VECTORS -DEMBEDDED_DATA -DRLE_COMPRESSED_MAPS -DSUPPORTS_ROOM_TRANSITION_ANIMATION -DSUPPORTS_HACKING_MINIGAME -DTRACE_OBJECTS_OVER_FLOOR -DCAN_PICK_OBJECT_AT_ANY_DISTANCE -DRES128X128 -Wall -Wextra -pedantic -Wunused-parameter -DXRES_FRAMEBUFFER=256 -DYRES_FRAMEBUFFER=192 -DENDIANESS_AWARE \
-DENDIANESS_AWARE -DMONOCHROME_VECTORS -DEMBEDDED_DATA -DRLE_COMPRESSED_MAPS -DSUPPORTS_ROOM_TRANSITION_ANIMATION -DSUPPORTS_HACKING_MINIGAME -DTRACE_OBJECTS_OVER_FLOOR -DCAN_PICK_OBJECT_AT_ANY_DISTANCE -DRES128X128 -Wall -Wextra -pedantic -Wunused-parameter -DXRES_FRAMEBUFFER=256 -DYRES_FRAMEBUFFER=160 -DENDIANESS_AWARE \
-DSUPPORTS_ROOM_TRANSITION_ANIMATION -DSUPPORTS_ROOM_TRANSITION_ANIMATION -DENDIANESS_AWARE \
-Iinclude -I../common/include -I../core/include -I../common/include -IEngine3D -I../core/include \
-I../common/include -I../core/include -Imenu/include -ISoundSystem -I../core/include -IEngine3D
Expand Down
11 changes: 0 additions & 11 deletions mz_frontend/include/Renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,6 @@ enum DIRECTION {

#define STIPPLE_COLOUR_THRESHOLD 8


/* not rendered and blocks visibility */
#define BLOCK_CELL '#'

struct CellPattern {
uint8_t ceiling: 4;
uint8_t elementsMask: 4;
uint8_t geometryType: 7;
uint8_t blockMovement: 1;
};

#define getPaletteEntry(c) (( (c) - 0xFF000000 ) % 3)

void clearGraphics(void);
Expand Down
10 changes: 10 additions & 0 deletions mz_frontend/src/AtariVersion/AtariRenderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,16 @@ void drawLine(uint16_t x0, uint8_t y0, uint16_t x1, uint8_t y1, uint8_t colour)
}
}

void fillRect(uint16_t x0, uint8_t y0, uint16_t x1, uint8_t y1, uint8_t colour, uint8_t stipple) {
int x, y;
for (y = y0; y < y1; ++y) {
for (x = x0; x < x1; ++x) {
realPut(x, y, colour);
}
}
}


void drawTextAtWithMarginWithFiltering(const int x, const int y, int margin, const char *text, const uint8_t fg,
char charToReplaceHifenWith) {

Expand Down
9 changes: 3 additions & 6 deletions mz_frontend/src/Crawler.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,10 @@ void HUD_refresh(void) {
needsToRedrawHUD = 0;

drawWindow(0,
(128 / 8),
(YRES / 8) + 1,
(XRES_FRAMEBUFFER / 8) / 2,
(YRES_FRAMEBUFFER / 8) - 17,
"Status");

drawTextAt(1, YRES_TEXT - 7, "In room:", 2);
drawTextAt(1, YRES_TEXT - 4, "In hand:", 2);
5,
"In hand:");

struct Item *item;

Expand Down
2 changes: 1 addition & 1 deletion mz_frontend/src/KeyboardUI.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void HUD_initialPaint(void) {

drawWindowWithOptions(
1 + (XRES_FRAMEBUFFER / 2) / 8,
(YRES_FRAMEBUFFER / 8) - 3 - /*kMainMenuOptionsCount*/ 6,
(YRES_FRAMEBUFFER / 8) - 3 - 5,
(XRES_FRAMEBUFFER / 8) - (1 + (XRES_FRAMEBUFFER / 2) / 8) - 1,
(YRES_FRAMEBUFFER / 8) - ((YRES_FRAMEBUFFER / 8) - 3 - /*kMainMenuOptionsCount*/ 6 - 1) - 2,
"Actions",
Expand Down
10 changes: 10 additions & 0 deletions mz_frontend/src/MSDOSVersion/msdos.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,16 @@ void startFrame(int x, int y, int width, int height) {

}

void fillRect(uint16_t x0, uint8_t y0, uint16_t x1, uint8_t y1, uint8_t colour, uint8_t stipple) {
int x, y;
for (y = y0; y < y1; ++y) {
for (x = x0; x < x1; ++x) {
realPut(x, y, colour);
}
}
}


void endFrame(void) {

uint8_t *bufferPtr = &imageBuffer[0];
Expand Down
9 changes: 9 additions & 0 deletions mz_frontend/src/MegaDriveVersion/megadrive.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ void realPut(int x, int y, uint8_t colour) {
BMP_setPixelFast(x, y, colour);
}

void fillRect(uint16_t x0, uint8_t y0, uint16_t x1, uint8_t y1, uint8_t colour, uint8_t stipple) {
int x, y;
for (y = y0; y < y1; ++y) {
for (x = x0; x < x1; ++x) {
realPut(x, y, colour);
}
}
}

void vLine(int16_t x0, int16_t y0, int16_t y1, uint16_t colour) {

if (y0 > y1) {
Expand Down
57 changes: 55 additions & 2 deletions mz_frontend/src/UI.c
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
/*
Created by Daniel Monteiro on 11/07/2023.
*/
#ifdef WIN32
#include "Win32Int.h"
#else
#ifndef SMD
#include <stdint.h>
#include <stdlib.h>
#else
#include <genesis.h>
typedef unsigned long size_t;
#endif
#endif

#include "Enums.h"
#include "UI.h"
#include "Core.h"
#include "Renderer.h"
#include "Engine.h"
#include "SoundSystem.h"
#include "Common.h"
#include "MapWithCharKey.h"
#include "FixP.h"
#include "CTile3DProperties.h"

extern uint8_t playerLocation;

extern int8_t cursorPosition;

extern const struct CellPattern patterns[127];

extern int8_t map[32][32];

uint8_t waitForKey = 0;
Expand All @@ -24,6 +36,8 @@ uint8_t redrawMap;

uint8_t needsToRedrawHUD;

extern struct MapWithCharKey tileProperties;

void drawGraphic(int x, int y, int dx, int dy, const uint8_t *graphic) {
const uint8_t *ptr = graphic;

Expand Down Expand Up @@ -65,8 +79,47 @@ void showMessage(const char *message) {
waitForKey = 1;
}

uint8_t isPositionAllowed(int8_t x, int8_t y) {
uint8_t pattern = map[y][x];
struct CTile3DProperties *prop =
(struct CTile3DProperties *) getFromMap(&tileProperties, pattern);

return prop->mBlockMovement;
}


void drawMap(void) {
uint8_t x, y;

if (!redrawMap) {
return;
}

if (playerLocation == 0) {
return;
}

redrawMap = 0;

drawWindow((XRES_FRAMEBUFFER / 8) / 2,
0,
(XRES_FRAMEBUFFER / 8) / 2 - 1,
(YRES_FRAMEBUFFER / 8) / 2 + 1,
"");

for (y = 0; y < 32; ++y) {
for (x = 0; x < 32; ++x) {

if (isPositionAllowed(x, y)) {
fillRect((XRES_FRAMEBUFFER / 2) + (x * 3),
(y * 3),
(XRES_FRAMEBUFFER / 2) + (x * 3) + 3,
(y * 3) + 3,
2,
0);
}
}
}
}

void performAction(void) {
Expand Down

0 comments on commit 4ab377b

Please sign in to comment.