Skip to content

Commit

Permalink
Buffer command helpers. Fix: terminate the buffer list.
Browse files Browse the repository at this point in the history
Commands 23,0,0xA0  13,16,19,21,25 and 26
  • Loading branch information
robogeek42 authored and astralaster committed Aug 26, 2024
1 parent 6b04434 commit cc99944
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/agon/vdp_vdu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1036,16 +1036,17 @@ void vdp_adv_call_offset_block_conditional( int bufferId, int offset, int block
void vdp_adv_copy_multiple( int bufferId, int num_buffers, ... )
{
va_list args;
uint16_t buffer_list[num_buffers];
uint16_t buffer_list[num_buffers+1];
vdu_adv_copy_multiple.BID = bufferId;
va_start( args, num_buffers );
for (int b = 0; b < num_buffers; b++)
{
buffer_list[b] = va_arg( args, int );
}
va_end( args );
buffer_list[num_buffers] = -1; // Terminate the list
VDP_PUTS( vdu_adv_copy_multiple );
mos_puts( (char*)buffer_list, num_buffers*2, 0 );
mos_puts( (char*)buffer_list, (num_buffers+1)*2, 0 );
}

void vdp_adv_consolidate( int bufferID )
Expand All @@ -1065,7 +1066,7 @@ void vdp_adv_split( int bufferID, int blockSize )
void vdp_adv_split_multiple( int bufferId, int blockSize, int num_buffers, ... )
{
va_list args;
uint16_t buffer_list[num_buffers];
uint16_t buffer_list[num_buffers+1];
vdu_adv_split_multiple.BID = bufferId;
vdu_adv_split_multiple.w0 = blockSize;
va_start( args, num_buffers );
Expand All @@ -1074,8 +1075,9 @@ void vdp_adv_split_multiple( int bufferId, int blockSize, int num_buffers, ... )
buffer_list[b] = va_arg( args, int );
}
va_end( args );
buffer_list[num_buffers] = -1; // Terminate the list
VDP_PUTS( vdu_adv_split_multiple );
mos_puts( (char*)buffer_list, num_buffers*2, 0 );
mos_puts( (char*)buffer_list, (num_buffers+1)*2, 0 );
}

void vdp_adv_split_multiple_from( int bufferID, int blockSize, int targetBufferID )
Expand All @@ -1097,7 +1099,7 @@ void vdp_adv_split_by_width( int bufferID, int width, int blockCount )
void vdp_adv_split_by_width_multiple( int bufferId, int width, int num_buffers, ... )
{
va_list args;
uint16_t buffer_list[num_buffers];
uint16_t buffer_list[num_buffers+1];
vdu_adv_split_by_width_multiple.BID = bufferId;
vdu_adv_split_by_width_multiple.w0 = width;
va_start( args, num_buffers );
Expand All @@ -1106,8 +1108,9 @@ void vdp_adv_split_by_width_multiple( int bufferId, int width, int num_buffers,
buffer_list[b] = va_arg( args, int );
}
va_end( args );
buffer_list[num_buffers] = -1; // Terminate the list
VDP_PUTS( vdu_adv_split_by_width_multiple );
mos_puts( (char*)buffer_list, num_buffers*2, 0 );
mos_puts( (char*)buffer_list, (num_buffers+1)*2, 0 );
}

void vdp_adv_split_by_width_multiple_from( int bufferID, int width, int blockCount, int targetBufferID )
Expand All @@ -1122,16 +1125,17 @@ void vdp_adv_split_by_width_multiple_from( int bufferID, int width, int blockCou
void vdp_adv_spread_multiple( int bufferId, int num_buffers, ... )
{
va_list args;
uint16_t buffer_list[num_buffers];
uint16_t buffer_list[num_buffers+1];
vdu_adv_spread_multiple.BID = bufferId;
va_start( args, num_buffers );
for (int b = 0; b < num_buffers; b++)
{
buffer_list[b] = va_arg( args, int );
}
va_end( args );
buffer_list[num_buffers] = -1; // Terminate the list
VDP_PUTS( vdu_adv_spread_multiple );
mos_puts( (char*)buffer_list, num_buffers*2, 0 );
mos_puts( (char*)buffer_list, (num_buffers+1)*2, 0 );
}

void vdp_adv_spread_multiple_from( int bufferID, int targetBufferID )
Expand Down Expand Up @@ -1182,31 +1186,33 @@ void vdp_adv_reverse_block_data( int bufferID, int options, int valueSize, int c
void vdp_adv_copy_multiple_by_reference( int bufferId, int num_buffers, ... )
{
va_list args;
uint16_t buffer_list[num_buffers];
uint16_t buffer_list[num_buffers+1];
vdu_adv_copy_multiple_by_reference.BID = bufferId;
va_start( args, num_buffers );
for (int b = 0; b < num_buffers; b++)
{
buffer_list[b] = va_arg( args, int );
}
va_end( args );
buffer_list[num_buffers] = -1; // Terminate the list
VDP_PUTS( vdu_adv_copy_multiple_by_reference );
mos_puts( (char*)buffer_list, num_buffers*2, 0 );
mos_puts( (char*)buffer_list, (num_buffers+1)*2, 0 );
}

void vdp_adv_copy_multiple_consolidate( int bufferId, int num_buffers, ... )
{
va_list args;
uint16_t buffer_list[num_buffers];
uint16_t buffer_list[num_buffers+1];
vdu_adv_copy_multiple_consolidate.BID = bufferId;
va_start( args, num_buffers );
for (int b = 0; b < num_buffers; b++)
{
buffer_list[b] = va_arg( args, int );
}
va_end( args );
buffer_list[num_buffers] = -1; // Terminate the list
VDP_PUTS( vdu_adv_copy_multiple_consolidate );
mos_puts( (char*)buffer_list, num_buffers*2, 0 );
mos_puts( (char*)buffer_list, (num_buffers+1)*2, 0 );
}

void vdp_adv_compress_buffer( int targetBufferID, int sourceBufferId )
Expand Down

0 comments on commit cc99944

Please sign in to comment.