Skip to content

Commit

Permalink
Load the source board from extra memory during editor copy block. (#495)
Browse files Browse the repository at this point in the history
* Load the source board from extra memory during editor copy block.
* Enable extra memory hacks in sanitizer CI builds.
* Fix annoying clang warning.
  • Loading branch information
AliceLR authored Oct 21, 2024
1 parent 4938ee3 commit b1fed77
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ jobs:
run: sudo apt update && sudo apt install -y --no-install-recommends $MZXDEPS_DEBIAN_SDL2
- uses: actions/checkout@v4
- name: Configure
run: ./config.sh --platform unix-devel --enable-asan
run: ./config.sh --platform unix-devel --enable-asan --enable-extram
- name: Build
run: $MZX_MAKE
- name: Run tests
Expand All @@ -327,7 +327,7 @@ jobs:
# wget https://github.com/AliceLR/megazeux-dependencies/releases/download/v2.93c/megazeux-dependencies-2.93c-r0-linux-msan.tar.xz;
# tar -xJf megazeux-dependencies-*-linux-msan.tar.xz)
# - name: Configure
# run: ./config.sh --platform unix-devel --prefix scripts/deps/linux-msan/x86_64 --enable-msan --disable-sdl --disable-libpng --disable-x11
# run: ./config.sh --platform unix-devel --prefix scripts/deps/linux-msan/x86_64 --enable-msan --disable-sdl --disable-libpng --disable-x11 --enable-extram
# - name: Build
# run: $MZX_MAKE V=1
# - name: Run tests
Expand All @@ -344,7 +344,7 @@ jobs:
run: sudo apt update && sudo apt install -y --no-install-recommends $MZXDEPS_DEBIAN_SDL2
- uses: actions/checkout@v4
- name: Configure
run: ./config.sh --platform unix-devel --enable-ubsan
run: ./config.sh --platform unix-devel --enable-ubsan --enable-extram
- name: Build
run: $MZX_MAKE
- name: Run tests
Expand Down
2 changes: 2 additions & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ USERS
+ Fixed sai.frag not being installed by "make install" or
distributed with Unix-style packages for Linux/BSD/Darwin.
+ Fixed the board editor show thing hotkeys (broken by 2.93b).
+ Fixed a crash that would occur in builds using extra memory
hacks (DOS) when copying blocks between boards in the editor.

DEVELOPERS

Expand Down
11 changes: 11 additions & 0 deletions src/editor/block.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "../core.h"
#include "../data.h"
#include "../event.h"
#include "../extmem.h"
#include "../mzm.h"
#include "../robot.h"
#include "../window.h"
Expand Down Expand Up @@ -416,6 +417,7 @@ void do_block_command(struct world *mzx_world, struct block_info *block,
int block_height = block->height;
int dest_block_width = block_width;
int dest_block_height = block_height;
boolean loaded_src_board = false;

if(block->command == BLOCK_CMD_NONE)
return;
Expand All @@ -425,6 +427,11 @@ void do_block_command(struct world *mzx_world, struct block_info *block,
{
case EDIT_BOARD:
if(block->src_board == NULL) break;
if(block->src_board != mzx_world->current_board)
{
retrieve_board_from_extram(block->src_board);
loaded_src_board = true;
}
src_board = block->src_board;
src_char = NULL;
src_color = src_board->level_color;
Expand Down Expand Up @@ -732,6 +739,10 @@ void do_block_command(struct world *mzx_world, struct block_info *block,

update_undo_frame(dest_history);
}

// TODO: it might be better to keep it in regular memory for repeat copies.
if(loaded_src_board)
store_board_to_extram(src_board);
}

//--------------------------
Expand Down
3 changes: 2 additions & 1 deletion src/extmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,8 @@ static boolean retrieve_buffer_from_extram(struct extram_data *data,
ptr = platform_extram_retrieve(block, len);
if(!ptr)
{
debug("--EXTRAM-- failed to retrieve buffer %p from non-mapped platform RAM.\n", *src);
debug("--EXTRAM-- failed to retrieve buffer %p from non-mapped platform RAM.\n",
(void *)*src);
goto err;
}
block = ptr;
Expand Down

0 comments on commit b1fed77

Please sign in to comment.