Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
timleader committed Jun 10, 2023
1 parent a51167c commit 0d01fed
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 12 deletions.
22 changes: 22 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@

## todo


-------------------------------------

- switching to IRQ enabled gives up access to and alternative r8-r14 (I think r7 might be required for fiq_on / off)

```
.macro fiq_on
msr cpsr, #0x11 // switch r8-r14 to FIQ (IRQ enabled)
.endm
.macro fiq_off
msr cpsr, #0x1F // restore r8-r14
.endm
```

https://github.com/XProger/OpenLara/blob/master/src/platform/gba/asm/common_asm.inc

--------------------------------------

- Character Model / Animation Improvements

- Environment Completion
5 changes: 5 additions & 0 deletions source/common/codegen/codegen_armv4.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ typedef enum armv4_register_e
armv4_register_r8 = 8,
armv4_register_r9 = 9,
armv4_register_r10 = 10,
armv4_register_r11 = 11,
armv4_register_r12 = 12,
armv4_register_r13 = 13,
armv4_register_r14 = 14,
armv4_register_r15 = 15,

} armv4_register_t;

Expand Down
8 changes: 2 additions & 6 deletions source/common/collision/collision.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@ vector2_t collisionClosestPointLineSegment(vector2_t point, line_segment_t* line

fixed16_t magnitudeSqr = mathVector2LengthSqr(&line->vector);
fixed16_t t = fixed16_mul(ap.x, line->vector.x) + fixed16_mul(ap.y, line->vector.y);
t = fixed16_div(t, magnitudeSqr);

if (t < fixed16_zero)
t = fixed16_zero;

if (t >= fixed16_one)
t = fixed16_one;
t = fixed16_div(t, magnitudeSqr);
t = fixed16_clamp(t, fixed16_zero, fixed16_one);

vector2_t result;
mathVector2ScalarMultiply(&result, &line->vector, t);
Expand Down
2 changes: 1 addition & 1 deletion source/common/graphics/graphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
graphics_context_t g_graphics_context; //IWRAM_DATA

// this could all be part of the graphics context
image_ptr boundimage = NULL; // think about bandwidth for texture sampling // make this an array
image_ptr boundimage = NULL; // think about bandwidth for texture sampling // make this an array
int invertedbitwiseWidth = 11;
int invertedbitwiseHeight = 11;
int bitwiseWidth = 5;
Expand Down
2 changes: 2 additions & 0 deletions source/common/graphics/graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ typedef struct graphics_context_s // this is more like graphics_context

span_t frame_dirty_scanline_span;

// palette mode

} graphics_context_t;

//-----------------------------------------------------------------------------
Expand Down
10 changes: 7 additions & 3 deletions source/common/graphics/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,19 @@

typedef uint16_t color555_t;

typedef struct palette_s
typedef struct palette_s // maybe bake both light and dark palettes into one palette
{
uint8_t id;
uint8_t offset;
uint8_t offset; // this is destination offset, offset at which this should be copied into hardware
uint16_t reserved;

uint16_t size;
uint16_t size; // size of palette, this only needs to be a uint8_t
uint16_t reserved2;

// should store the slice idx between light and dark palette

// should store size of 2nd palette

color555_t color555[0];

} palette_t;
Expand Down
9 changes: 7 additions & 2 deletions source/common/utils/bitstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "common/memory.h"


/* BITSTREAM Functions */
//-----------------------------------------------------------------------------
void bitstream_initialize(bitstream_t* bs, const void_ptr ptr, const uint32_t size)
{
uint32_t addr = (uint32_t)ptr;
Expand All @@ -22,6 +22,7 @@ void bitstream_initialize(bitstream_t* bs, const void_ptr ptr, const uint32_t si
bs->value = bs->buffer[bs->buffer_idx];
}

//-----------------------------------------------------------------------------
IWRAM_CODE uint8_t bitstream_read_1(bitstream_t* bs) // should be asm
{
uint8_t ret = ~0;
Expand All @@ -44,6 +45,7 @@ IWRAM_CODE uint8_t bitstream_read_1(bitstream_t* bs) // should be asm
return ret;
}

//-----------------------------------------------------------------------------
IWRAM_CODE uint8_t bitstream_read_8(bitstream_t* bs)
{
uint8_t ret = 0;
Expand All @@ -69,6 +71,7 @@ IWRAM_CODE uint8_t bitstream_read_8(bitstream_t* bs)
return ret;
}

//-----------------------------------------------------------------------------
IWRAM_CODE uint16_t bitstream_read_16(bitstream_t* bs)
{
uint8_t ret = 0;
Expand All @@ -93,6 +96,7 @@ IWRAM_CODE uint16_t bitstream_read_16(bitstream_t* bs)
return ret;
}

//-----------------------------------------------------------------------------
IWRAM_CODE uint32_t bitstream_read_32(bitstream_t* bs)
{
uint32_t ret;
Expand All @@ -117,7 +121,7 @@ IWRAM_CODE uint32_t bitstream_read_32(bitstream_t* bs)
return ret;
}


//-----------------------------------------------------------------------------
IWRAM_CODE uint32_t bitstream_peek_32(bitstream_t* bs)
{
uint32_t ret;
Expand All @@ -136,6 +140,7 @@ IWRAM_CODE uint32_t bitstream_peek_32(bitstream_t* bs)
return ret;
}

//-----------------------------------------------------------------------------
IWRAM_CODE void bitstream_move(bitstream_t* bs, uint16_t bit_count)
{
bit_count += bs->bit_idx;
Expand Down

0 comments on commit 0d01fed

Please sign in to comment.