From fcad9abcd9ed7d33d111c96fc48f0d148648fdd6 Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Sun, 21 Aug 2022 23:30:35 -0500 Subject: [PATCH] c64: presets --- presets/c64/multisprite.ca65 | 4 +- presets/c64/test_multispritelib.c | 135 ++++++++++++++++++++++++++++++ src/platform/c64.ts | 3 +- 3 files changed, 140 insertions(+), 2 deletions(-) create mode 100644 presets/c64/test_multispritelib.c diff --git a/presets/c64/multisprite.ca65 b/presets/c64/multisprite.ca65 index 47e37499..d75b7a3a 100644 --- a/presets/c64/multisprite.ca65 +++ b/presets/c64/multisprite.ca65 @@ -1,7 +1,7 @@ MAX_MSPRITES = 28 -MIN_Y_SPACING = 33 +MIN_Y_SPACING = 35 DEBUG = 1 @@ -179,6 +179,7 @@ bailout_line: .res 1 .global _msprite_color .global _msprite_shape .global _msprite_flags +.global _msprite_last_y _msprite_order: .res MAX_MSPRITES _msprite_x_lo: .res MAX_MSPRITES @@ -187,6 +188,7 @@ _msprite_y: .res MAX_MSPRITES _msprite_color: .res MAX_MSPRITES _msprite_shape: .res MAX_MSPRITES _msprite_flags: .res MAX_MSPRITES +_msprite_last_y:.res 1 .global _msprite_x_frac .global _msprite_xvel_lo diff --git a/presets/c64/test_multispritelib.c b/presets/c64/test_multispritelib.c new file mode 100644 index 00000000..58d08c34 --- /dev/null +++ b/presets/c64/test_multispritelib.c @@ -0,0 +1,135 @@ + +#include "common.h" +//#link "common.c" + +#include "multisprite.h" +//#link "multisprite.ca65" + +#include "rasterirq.h" +//#link "rasterirq.ca65" + +#define NUM_TEST_SPRITES 24 + +byte* sprite_bank = (byte*)DEFAULT_SCREEN + 0x3f8; + +/*{w:12,h:21,bpp:2,brev:1}*/ +const char SPRITEMC[3*21] = { + 0x00,0xAA,0x80,0x02,0xAA,0xA0,0x0A,0xAA,0xA8, + 0x0A,0xAE,0xA8,0x0A,0xBB,0xA8,0x0A,0xBA,0xA8, + 0x0A,0xBB,0xA8,0x0A,0xAE,0xA8,0x0A,0xAA,0xA8, + 0x09,0xAA,0x98,0x08,0x6A,0x48,0x08,0x1D,0x08, + 0x02,0x0C,0x20,0x02,0x0C,0x20,0x02,0x0C,0x20, + 0x00,0x8C,0x80,0x00,0x8C,0x80,0x00,0x55,0x40, + 0x00,0x77,0x40,0x00,0x5D,0x40,0x00,0x15,0x00 +}; + +void sprite_shape(char* vicbank, byte index, const char* sprite_data) { + memmove(vicbank + index*64, sprite_data, 64); +} + +void setup_sprites() { + byte i; + sprite_shape((void*)0x0, 255, SPRITEMC); + for (i=0; i>8; + msprite_y[i] = i*0+50; +// msprite_flags[i] = 0; + msprite_shape[i] = 255; + msprite_color[i] = i|8; + } +} + +// constants for display list + +#define Y0 21 +#define Y1 35 +#define YS 42 + +void display_list() { + msprite_render_init(); + msprite_render_section(); + DLIST_NEXT(Y1+YS*1); + msprite_render_section(); + DLIST_NEXT(Y1+YS*2); + msprite_render_section(); + DLIST_NEXT(Y1+YS*3); + msprite_render_section(); + DLIST_NEXT(Y1+YS*4); + msprite_render_section(); + VIC.bordercolor = 3; + msprite_sort(); + VIC.bordercolor = 4; + msprite_add_velocity(NUM_TEST_SPRITES); + VIC.bordercolor = 0; + DLIST_RESTART(Y0); +} + +void msprite_set_position(byte index, int x, byte y) { + asm("sei"); + msprite_x_lo[index] = x; + msprite_x_hi[index] = x >> 8; + msprite_y[index] = y; + asm("cli"); +} + +void msprite_add_position(byte index, byte dx, byte dy) { + int x; + x = msprite_x_lo[index] | msprite_x_hi[index]*256; + x += dx; + asm("sei"); + msprite_x_lo[index] = x; + msprite_x_hi[index] = x >> 8; + msprite_y[index] += dy; + asm("cli"); +} + +void apply_gravity() { + byte i; + for (i=0; i> 8; + msprite_yvel_lo[i] = yvel; + msprite_yvel_hi[i] = yvel >> 8; + } +} + +void do_test() { + byte i; + raster_wait(160); + for (i=0; i