Skip to content

Commit

Permalink
Code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
viciious committed Nov 5, 2023
1 parent ac4d37a commit 5eab2ae
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
9 changes: 9 additions & 0 deletions marshw.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,15 @@ void Mars_MCDFlushSfx(void)
while (MARS_SYS_COMM0);
}

void Mars_CopyLLongs(int numllongs)
{
/* transfer nodes to the MD */
while (MARS_SYS_COMM0);
MARS_SYS_COMM2 = numllongs;
MARS_SYS_COMM0 = 0x2400;
while (MARS_SYS_COMM0);
}

void Mars_StopTrack(void)
{
while (MARS_SYS_COMM0);
Expand Down
3 changes: 3 additions & 0 deletions marshw.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ void Mars_MCDStopSfx(uint8_t src_id);
void Mars_MCDFlushSfx(void);
void Mars_MCDLoadSfxFileOfs(uint16_t start_id, int numsfx, const char *name, int *offsetlen);

// copies numllongs number of 64-bit values from the framebufer into MD RAM
void Mars_CopyLLongs(int numllongs);

void Mars_MCDSetFileCache(int length);
void *Mars_MCDGetFileCache(int length);

Expand Down
6 changes: 1 addition & 5 deletions p_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,7 @@ void P_LoadNodes (int lump)
}

#ifdef MARS
/* transfer nodes to the MD */
while (MARS_SYS_COMM0);
MARS_SYS_COMM2 = numnodes;
MARS_SYS_COMM0 = 0x2400;
while (MARS_SYS_COMM0);
Mars_CopyLLongs(numnodes * 2);
#endif
}

Expand Down
21 changes: 10 additions & 11 deletions src-md/crt0.s
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,8 @@ no_cmd:
dc.w update_sfx - prireqtbl
dc.w stop_sfx - prireqtbl
dc.w flush_sfx - prireqtbl
dc.w test_handle - prireqtbl
dc.w get_bbox - prireqtbl
dc.w copy_llongs - prireqtbl
dc.w get_llong - prireqtbl
dc.w open_cd_file_by_name - prireqtbl
dc.w open_cd_file_by_handle - prireqtbl
dc.w read_cd_file - prireqtbl
Expand Down Expand Up @@ -2055,27 +2055,26 @@ flush_sfx:
move.b #1,need_bump_fm
bra main_loop

test_handle:
copy_llongs:
moveq #0,d1
move.w 0xA15122,d1 /* number of nodes */
move.w 0xA15122,d1 /* number of llongs */
add.w d1,d1 /* x2 */
add.w d1,d1 /* x4 */
add.w d1,d1 /* x8 */
add.w d1,d1 /* x16 */

lea MARS_FRAMEBUFFER,a2 /* frame buffer */
lea MARS_FRAMEBUFFER,a2
lea nodes_store,a1

move.l d1,-(sp) /* length */
move.l a2,-(sp) /* framebuffer */
move.l a1,-(sp) /* destination */

move.w 0xA15100,d1
eor.w #0x8000,d1
move.w d1,0xA15100 /* unset FM - disallow SH2 access to FB */
move.w 0xA15100,d0
eor.w #0x8000,d0
move.w d0,0xA15100 /* unset FM - disallow SH2 access to FB */

jsr memcpy
lea 12(sp),sp /* clear the stack */
lea 12(sp),sp /* clear the stack */

move.w 0xA15100,d0
or.w #0x8000,d0
Expand All @@ -2084,7 +2083,7 @@ test_handle:
move.w #0,0xA15120 /* done */
bra main_loop

get_bbox:
get_llong:
move.w 0xA15122,d1 /* offset */

lea nodes_store,a1
Expand Down

0 comments on commit 5eab2ae

Please sign in to comment.