Compare commits
1 commit
master
...
set_positi
Author | SHA1 | Date | |
---|---|---|---|
b7b18de97b |
9 changed files with 200 additions and 168 deletions
|
@ -1,27 +0,0 @@
|
||||||
{
|
|
||||||
"name": "Your Definition Name Here (Community)",
|
|
||||||
|
|
||||||
// Update the 'image' property with your Docker image name.
|
|
||||||
"image": "docker.io/empathicqubit/vscode-cc65-debugger-build",
|
|
||||||
|
|
||||||
// Set *default* container specific settings.json values on container create.
|
|
||||||
"settings": {},
|
|
||||||
|
|
||||||
// Add the IDs of extensions you want installed when the container is created.
|
|
||||||
"extensions": [],
|
|
||||||
|
|
||||||
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
|
||||||
// "forwardPorts": [],
|
|
||||||
|
|
||||||
// Uncomment to run commands after the container is created - like installing curl
|
|
||||||
// "postCreateCommand": "apt-get update && apt-get install -y curl",
|
|
||||||
|
|
||||||
// Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker.
|
|
||||||
// "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ],
|
|
||||||
|
|
||||||
// Uncomment when using a ptrace-based debugger like C++, Go, and Rust
|
|
||||||
// "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],
|
|
||||||
|
|
||||||
// Comment out to connect as root instead. To add a non-root user, see: https://aka.ms/vscode-remote/containers/non-root.
|
|
||||||
"remoteUser": "vscode"
|
|
||||||
}
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,6 +1,6 @@
|
||||||
*.tab
|
*.tab
|
||||||
*.o
|
*.o
|
||||||
*.sw?
|
*.s??
|
||||||
*~
|
*~
|
||||||
*.dblite
|
*.dblite
|
||||||
build/
|
build/
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
{
|
|
||||||
"configurations": {
|
|
||||||
"CC65 VICE": {
|
|
||||||
"adapter": "cust_cc65-vice",
|
|
||||||
"configuration": {
|
|
||||||
"request": "launch",
|
|
||||||
"name": "CC65 Vice Launch",
|
|
||||||
"debugFile": "${workspaceFolder}/build/machismo.dbg",
|
|
||||||
"mapFile": "${workspaceFolder}/build/machismo.map",
|
|
||||||
"program": "${workspaceFolder}/build/machismo.d64",
|
|
||||||
"build": {
|
|
||||||
"cwd": "${workspaceFolder}",
|
|
||||||
"command": "scons",
|
|
||||||
"args": []
|
|
||||||
},
|
|
||||||
"stopOnEntry": true,
|
|
||||||
"viceArgs": [
|
|
||||||
"-model",
|
|
||||||
"ntsc"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
36
.vscode/launch.json
vendored
36
.vscode/launch.json
vendored
|
@ -4,6 +4,19 @@
|
||||||
// Weitere Informationen finden Sie unter https://go.microsoft.com/fwlink/?linkid=830387
|
// Weitere Informationen finden Sie unter https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
"type": "cc65-vice",
|
"type": "cc65-vice",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
|
@ -16,29 +29,10 @@
|
||||||
},
|
},
|
||||||
"debugFile": "${workspaceFolder}/build/msprite.dbg",
|
"debugFile": "${workspaceFolder}/build/msprite.dbg",
|
||||||
"mapFile": "${workspaceFolder}/build/msprite.map",
|
"mapFile": "${workspaceFolder}/build/msprite.map",
|
||||||
|
"labelFile": "${workspaceFolder}/build/msprite.lbl",
|
||||||
"stopOnEntry": true,
|
"stopOnEntry": true,
|
||||||
"stopOnExit": true,
|
"stopOnExit": true,
|
||||||
"emulatorArgs": [
|
"viceArgs": [
|
||||||
"-model",
|
|
||||||
"ntsc"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "cc65-vice",
|
|
||||||
"request": "launch",
|
|
||||||
"name": "CC65 Vice Launch (Debug Extension)",
|
|
||||||
"program": "${workspaceFolder}/build/msprite.d64",
|
|
||||||
"build": {
|
|
||||||
"cwd": "${workspaceFolder}",
|
|
||||||
"command": "scons",
|
|
||||||
"args": []
|
|
||||||
},
|
|
||||||
"debugFile": "${workspaceFolder}/build/msprite.dbg",
|
|
||||||
"mapFile": "${workspaceFolder}/build/msprite.map",
|
|
||||||
"debugServer": 4711,
|
|
||||||
"stopOnEntry": true,
|
|
||||||
"stopOnExit": true,
|
|
||||||
"emulatorArgs": [
|
|
||||||
"-model",
|
"-model",
|
||||||
"ntsc"
|
"ntsc"
|
||||||
]
|
]
|
||||||
|
|
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
|
@ -40,10 +40,5 @@
|
||||||
"c64.h": "c",
|
"c64.h": "c",
|
||||||
"cstring": "c",
|
"cstring": "c",
|
||||||
"6502.h": "c"
|
"6502.h": "c"
|
||||||
},
|
|
||||||
"workbench.colorCustomizations": {
|
|
||||||
"activityBar.background": "#eee",
|
|
||||||
"activityBar.foreground": "#000000ff",
|
|
||||||
"activityBar.inactiveForeground": "#00000088"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
11
SConstruct
11
SConstruct
|
@ -8,7 +8,7 @@ character_start = 'D800'
|
||||||
if 'CC65_HOME' in os.environ:
|
if 'CC65_HOME' in os.environ:
|
||||||
cc65_home = os.environ['CC65_HOME']
|
cc65_home = os.environ['CC65_HOME']
|
||||||
else:
|
else:
|
||||||
cc65_home = str(Glob(os.environ['HOME'] + '/.vscode/extensions/entan-gl.cc65-vice*/dist/cc65')[0])
|
cc65_home = ''
|
||||||
|
|
||||||
if 'DISPLAY' in os.environ:
|
if 'DISPLAY' in os.environ:
|
||||||
display = os.environ['DISPLAY']
|
display = os.environ['DISPLAY']
|
||||||
|
@ -19,7 +19,6 @@ print(cc65_home)
|
||||||
print(os.environ['PATH'])
|
print(os.environ['PATH'])
|
||||||
|
|
||||||
env = Environment(
|
env = Environment(
|
||||||
tools=['mingw'],
|
|
||||||
BUILDERS = {},
|
BUILDERS = {},
|
||||||
ENV = {
|
ENV = {
|
||||||
'PATH': os.environ["PATH"],
|
'PATH': os.environ["PATH"],
|
||||||
|
@ -27,15 +26,13 @@ env = Environment(
|
||||||
'DISPLAY': display,
|
'DISPLAY': display,
|
||||||
},
|
},
|
||||||
AS = 'ca65',
|
AS = 'ca65',
|
||||||
ASFLAGS = ['-t', 'c64', '-g', '--cpu', '6502x'],
|
ASFLAGS = ['-t', 'c64', '-g'],
|
||||||
CC = 'cl65',
|
CC = 'cl65',
|
||||||
CFLAGS = ['-DSCREEN_START=0x'+screen_start, '-DSPRITE_START=0x'+sprite_start, '-DCHARACTER_START=0x'+character_start, '-O', '-Osir', '-t', 'c64', '-C', 'c64.cfg', '-g', '-Wc', '--debug-tables', '-Wc', '${SOURCE}.tab'],
|
CFLAGS = ['-DSCREEN_START=0x'+screen_start, '-DSPRITE_START=0x'+sprite_start, '-DCHARACTER_START=0x'+character_start, '-O', '-Osir', '-t', 'c64', '-C', 'c64.cfg', '-g', '-Wc', '--debug-tables', '-Wc', '${SOURCE}.tab'],
|
||||||
LINK = 'cl65',
|
LINK = 'cl65',
|
||||||
LINKFLAGS = ['-g', '-C', 'c64.cfg', '-D__HIMEM__=$' + screen_start, '-Wl', '--dbgfile,build/msprite.dbg', '-Wl', '-Lnbuild/msprite.lbl', '-Wl', '--mapfile,build/msprite.map']
|
LINKFLAGS = ['-g', '-C', 'c64.cfg', '-D__HIMEM__=$' + screen_start, '-Wl', '--dbgfile,build/msprite.dbg', '-Wl', '-Lnbuild/msprite.lbl', '-Wl', '--mapfile,build/msprite.map']
|
||||||
)
|
)
|
||||||
|
|
||||||
env.PrependENVPath("PATH", cc65_home + "/bin_linux_x64")
|
|
||||||
|
|
||||||
prg = env.Program(target=["build/msprite.prg", "build/msprite.map", "build/msprite.dbg", "build/msprite.lbl"], source=[Glob('src/*.c'), Glob('src/*_asm.s')])
|
prg = env.Program(target=["build/msprite.prg", "build/msprite.map", "build/msprite.dbg", "build/msprite.lbl"], source=[Glob('src/*.c'), Glob('src/*_asm.s')])
|
||||||
|
|
||||||
sprites = Glob('res/sprites/*.spd')
|
sprites = Glob('res/sprites/*.spd')
|
||||||
|
@ -53,8 +50,8 @@ def disk_func(target, source, env):
|
||||||
typename = 's'
|
typename = 's'
|
||||||
if basename.endswith('prg'):
|
if basename.endswith('prg'):
|
||||||
typename = 'p'
|
typename = 'p'
|
||||||
changes.append(""" -delete "%s" -write "%s" "%s,%s" """ % (basename, str(src), basename, typename))
|
changes.append(""" -delete '%s' -write '%s' '%s,%s'""" % (basename, str(src), basename, typename))
|
||||||
env.Execute("""c1541 -attach "%s" %s """ % (str(target[0]), ''.join(changes)))
|
env.Execute("""c1541 -attach '%s' %s """ % (str(target[0]), ''.join(changes)))
|
||||||
|
|
||||||
disk_image = env.Command(target=["build/msprite.d64"], source=disk_files, action=disk_func)
|
disk_image = env.Command(target=["build/msprite.d64"], source=disk_files, action=disk_func)
|
||||||
|
|
||||||
|
|
Binary file not shown.
178
src/main.c
178
src/main.c
|
@ -178,22 +178,22 @@ unsigned char spritesheet_load(unsigned char* filename) {
|
||||||
#define SPD_SPRITE_COLOR_VALUE_MASK 0x0F
|
#define SPD_SPRITE_COLOR_VALUE_MASK 0x0F
|
||||||
|
|
||||||
struct sprite_data {
|
struct sprite_data {
|
||||||
unsigned char color;
|
|
||||||
unsigned char pointer;
|
|
||||||
unsigned char lo_x;
|
|
||||||
unsigned char lo_y;
|
|
||||||
|
|
||||||
unsigned char ena;
|
unsigned char ena;
|
||||||
unsigned char hi_x;
|
unsigned char hi_x;
|
||||||
unsigned char dbl;
|
unsigned char dbl;
|
||||||
unsigned char multi;
|
unsigned char multi;
|
||||||
|
|
||||||
|
unsigned char color;
|
||||||
|
unsigned char pointer;
|
||||||
|
unsigned char lo_x;
|
||||||
|
unsigned char lo_y;
|
||||||
};
|
};
|
||||||
typedef struct sprite_data* sprite_handle;
|
typedef struct sprite_data* sprite_handle;
|
||||||
|
|
||||||
#define SPRITE_POOL_SIZE 32
|
#define SPRITE_POOL_SIZE 32
|
||||||
struct sprite_data _sprite_pool[SPRITE_POOL_SIZE];
|
struct sprite_data _sprite_pool[SPRITE_POOL_SIZE];
|
||||||
sprite_handle _sprite_list[SPRITE_POOL_SIZE];
|
sprite_handle _sprite_list[SPRITE_POOL_SIZE];
|
||||||
unsigned char sprite_count = 0;
|
unsigned char sprite_count;
|
||||||
|
|
||||||
void init_sprite_pool(void) {
|
void init_sprite_pool(void) {
|
||||||
memset(&_sprite_pool, 0x00, sizeof(struct sprite_data) * SPRITE_POOL_SIZE);
|
memset(&_sprite_pool, 0x00, sizeof(struct sprite_data) * SPRITE_POOL_SIZE);
|
||||||
|
@ -236,10 +236,8 @@ void set_sprite_x(sprite_handle a, unsigned int x) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_sprite_y(sprite_handle a, unsigned char y) {
|
void set_sprite_y(sprite_handle a, unsigned char y) {
|
||||||
register sprite_handle *comp_handle, *current_handle;
|
static sprite_handle *start_handle, *comp_handle, *current_handle;
|
||||||
register sprite_handle comp;
|
static sprite_handle arg, comp;
|
||||||
static sprite_handle* start_handle;
|
|
||||||
static sprite_handle arg;
|
|
||||||
static unsigned char index, last_index, hi_mask, comp_y, yarg;
|
static unsigned char index, last_index, hi_mask, comp_y, yarg;
|
||||||
static bool direction, is_last;
|
static bool direction, is_last;
|
||||||
|
|
||||||
|
@ -277,48 +275,137 @@ void set_sprite_y(sprite_handle a, unsigned char y) {
|
||||||
|
|
||||||
current_handle = start_handle;
|
current_handle = start_handle;
|
||||||
do {
|
do {
|
||||||
if(direction) {
|
|
||||||
comp_handle = current_handle + 1;
|
|
||||||
comp = *comp_handle;
|
|
||||||
is_last = (yarg <= comp->lo_y
|
|
||||||
|| index == last_index);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
comp_handle = current_handle - 1;
|
|
||||||
comp = *comp_handle;
|
|
||||||
is_last = (comp->lo_y <= yarg
|
|
||||||
|| index == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(is_last) {
|
// set ptr3 to pointer to next struct pointer in list
|
||||||
if(current_handle == start_handle) {
|
#define set_comp_list_pointer(add, carry, cond, inc) { \
|
||||||
|
__asm__("lda %v", current_handle); \
|
||||||
|
__asm__("ldy %v+1", current_handle); \
|
||||||
|
__asm__(carry); \
|
||||||
|
__asm__(add " #$02"); \
|
||||||
|
__asm__(cond " handle_" add); \
|
||||||
|
__asm__(inc); \
|
||||||
|
__asm__("handle_" add ": "); \
|
||||||
|
__asm__("sta ptr3"); \
|
||||||
|
__asm__("sty ptr3+1"); \
|
||||||
|
}
|
||||||
|
|
||||||
|
// store comparison struct pointer to ptr1
|
||||||
|
#define set_comp_pointer() { \
|
||||||
|
__asm__("ldy #$00"); \
|
||||||
|
__asm__("lda (ptr3),Y"); \
|
||||||
|
__asm__("sta ptr1"); \
|
||||||
|
\
|
||||||
|
__asm__("iny"); \
|
||||||
|
__asm__("lda (ptr3),Y"); \
|
||||||
|
__asm__("sta ptr1+1"); \
|
||||||
|
}
|
||||||
|
|
||||||
|
__asm__("ldx %v", direction);
|
||||||
|
__asm__("beq false_dir");
|
||||||
|
set_comp_list_pointer("adc", "clc", "bcc", "iny");
|
||||||
|
set_comp_pointer();
|
||||||
|
|
||||||
|
// test if comparison y is greater than or equal to current y
|
||||||
|
__asm__("ldy #%b", offsetof(struct sprite_data, lo_y));
|
||||||
|
|
||||||
|
__asm__("lda (ptr1),Y");
|
||||||
|
__asm__("cmp %v", yarg);
|
||||||
|
__asm__("bcs truth");
|
||||||
|
|
||||||
|
// test if index is the one at the end of the list.
|
||||||
|
__asm__("lda %v", index);
|
||||||
|
__asm__("cmp %v", last_index);
|
||||||
|
__asm__("beq truth");
|
||||||
|
|
||||||
|
__asm__("lda #00");
|
||||||
|
__asm__("beq is_last");
|
||||||
|
__asm__("truth: lda #$01");
|
||||||
|
__asm__("is_last: sta %v", is_last);
|
||||||
|
__asm__("bpl end_dir");
|
||||||
|
__asm__("false_dir: ");
|
||||||
|
// fixme: use x for direction?
|
||||||
|
set_comp_list_pointer("sbc", "sec", "bcs", "dey");
|
||||||
|
set_comp_pointer();
|
||||||
|
|
||||||
|
// test if current y >= comparison y
|
||||||
|
__asm__("ldy #%b", offsetof(struct sprite_data, lo_y));
|
||||||
|
|
||||||
|
__asm__("lda %v", yarg);
|
||||||
|
__asm__("cmp (ptr1),Y");
|
||||||
|
__asm__("bcs back_truth");
|
||||||
|
|
||||||
|
// test if index is the one at the beginning of the list.
|
||||||
|
__asm__("lda %v", index);
|
||||||
|
__asm__("beq back_truth");
|
||||||
|
|
||||||
|
__asm__("lda #00");
|
||||||
|
__asm__("beq back_is_last");
|
||||||
|
__asm__("back_truth: lda #$01");
|
||||||
|
__asm__("back_is_last: sta %v", is_last);
|
||||||
|
__asm__("end_dir: ");
|
||||||
|
|
||||||
|
// copy current_handle to ptr2
|
||||||
|
__asm__("lda %v", current_handle);
|
||||||
|
__asm__("ldx %v+1", current_handle);
|
||||||
|
__asm__("sta ptr2");
|
||||||
|
__asm__("stx ptr2+1");
|
||||||
|
|
||||||
|
__asm__("ldy is_last");
|
||||||
|
|
||||||
|
__asm__("beq not_last");
|
||||||
|
__asm__("cmp %v", start_handle);
|
||||||
|
__asm__("bne not_start_handle");
|
||||||
|
__asm__("cpx %v+1", start_handle);
|
||||||
|
__asm__("bne not_start_handle");
|
||||||
break;
|
break;
|
||||||
}
|
__asm__("not_start_handle: ");
|
||||||
|
|
||||||
comp = arg;
|
__asm__("lda %v", arg);
|
||||||
}
|
__asm__("ldx %v+1", arg);
|
||||||
|
__asm__("sta ptr1");
|
||||||
|
__asm__("stx ptr1+1");
|
||||||
|
__asm__("not_last: ");
|
||||||
|
|
||||||
hi_mask = 1<<(index%VIC_SPR_COUNT);
|
// set hi_mask
|
||||||
|
__asm__("lda %v", index);
|
||||||
|
__asm__("and #$07");
|
||||||
|
__asm__("tay");
|
||||||
|
__asm__("lda #$01");
|
||||||
|
__asm__("shift: asl");
|
||||||
|
__asm__("dey");
|
||||||
|
__asm__("bpl shift");
|
||||||
|
__asm__("ror");
|
||||||
|
__asm__("sta %v", hi_mask);
|
||||||
|
|
||||||
__asm__("ldy #%b", offsetof(struct sprite_data, ena));
|
// prepare to iterate over comp fields in reverse
|
||||||
|
__asm__("ldy #%b", offsetof(struct sprite_data, multi));
|
||||||
|
|
||||||
|
// change hi_mask on ones that are already set
|
||||||
__asm__("ldx %v", hi_mask);
|
__asm__("ldx %v", hi_mask);
|
||||||
__asm__("loop: lda (%v),Y", comp);
|
__asm__("loop:");
|
||||||
|
__asm__("lda (ptr1),Y");
|
||||||
__asm__("beq done");
|
__asm__("beq done");
|
||||||
__asm__("txa");
|
__asm__("txa");
|
||||||
__asm__("sta (%v),Y", comp);
|
__asm__("sta (ptr1),Y");
|
||||||
__asm__("done: iny");
|
__asm__("done: dey");
|
||||||
__asm__("tya");
|
__asm__("bpl loop");
|
||||||
__asm__("sbc #%b", offsetof(struct sprite_data, multi));
|
|
||||||
__asm__("bne loop");
|
|
||||||
|
|
||||||
if(is_last) {
|
// swap comp to current_handle
|
||||||
*current_handle = comp;
|
__asm__("lda ptr1");
|
||||||
break;
|
__asm__("sta (ptr2),y");
|
||||||
}
|
__asm__("iny");
|
||||||
|
__asm__("lda ptr1+1");
|
||||||
|
__asm__("sta (ptr2),y");
|
||||||
|
|
||||||
*current_handle = comp;
|
// if the comp is last, break
|
||||||
*comp_handle = arg;
|
__asm__("ldx %v", is_last);
|
||||||
|
__asm__("bne exitloop");
|
||||||
|
|
||||||
|
__asm__("lda %v+1", arg);
|
||||||
|
__asm__("sta (ptr3),y");
|
||||||
|
__asm__("dey");
|
||||||
|
__asm__("lda %v", arg);
|
||||||
|
__asm__("sta (ptr3),y");
|
||||||
|
|
||||||
if(direction) {
|
if(direction) {
|
||||||
index++;
|
index++;
|
||||||
|
@ -330,6 +417,7 @@ void set_sprite_y(sprite_handle a, unsigned char y) {
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (true);
|
} while (true);
|
||||||
|
__asm__("exitloop: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
void discard_sprite(sprite_handle handle) {
|
void discard_sprite(sprite_handle handle) {
|
||||||
|
@ -381,11 +469,13 @@ struct waw {
|
||||||
};
|
};
|
||||||
typedef struct waw waw;
|
typedef struct waw waw;
|
||||||
|
|
||||||
void init_waw(register waw* waw) {
|
void init_waw(waw* w) {
|
||||||
static unsigned int x, sprite_x;
|
static unsigned int x, sprite_x;
|
||||||
static unsigned char i, j, y, sprite_y, idx;
|
static unsigned char i, j, y, sprite_y, idx;
|
||||||
|
static waw* waw;
|
||||||
static sprite_handle sprite;
|
static sprite_handle sprite;
|
||||||
static sprite_handle* sprites;
|
static sprite_handle* sprites;
|
||||||
|
waw = w;
|
||||||
|
|
||||||
x = waw->x + SCREEN_SPRITE_BORDER_X_START;
|
x = waw->x + SCREEN_SPRITE_BORDER_X_START;
|
||||||
y = waw->y + SCREEN_SPRITE_BORDER_Y_START;
|
y = waw->y + SCREEN_SPRITE_BORDER_Y_START;
|
||||||
|
@ -414,12 +504,14 @@ void init_waw(register waw* waw) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_waw(register waw* waw) {
|
void update_waw(waw* w) {
|
||||||
static unsigned char y;
|
static unsigned char y;
|
||||||
static unsigned char idx;
|
static unsigned char idx;
|
||||||
static signed char change_y, mouth_offset;
|
static signed char change_y, mouth_offset;
|
||||||
static sprite_handle* sprites;
|
static sprite_handle* sprites;
|
||||||
static sprite_handle sprite;
|
static sprite_handle sprite;
|
||||||
|
static waw* waw;
|
||||||
|
waw = w;
|
||||||
mouth_offset = waw->mouth_offset;
|
mouth_offset = waw->mouth_offset;
|
||||||
if(waw->mouth_direction) {
|
if(waw->mouth_direction) {
|
||||||
mouth_offset+=WAW_MOUTHSPEED;
|
mouth_offset+=WAW_MOUTHSPEED;
|
||||||
|
|
|
@ -24,10 +24,12 @@
|
||||||
tax
|
tax
|
||||||
|
|
||||||
ldy __sprite_list,X
|
ldy __sprite_list,X
|
||||||
|
sty current_sprite
|
||||||
sty ptr1
|
sty ptr1
|
||||||
|
|
||||||
inx
|
inx
|
||||||
ldy __sprite_list,X
|
ldy __sprite_list,X
|
||||||
|
sty current_sprite+1
|
||||||
sty ptr1+1
|
sty ptr1+1
|
||||||
|
|
||||||
ldy #$03 ; FIXME offsetof(lo_y)
|
ldy #$03 ; FIXME offsetof(lo_y)
|
||||||
|
@ -50,11 +52,23 @@ vic_sprite: .byte $00
|
||||||
current_y: .byte $00
|
current_y: .byte $00
|
||||||
new_y: .byte $00
|
new_y: .byte $00
|
||||||
hi_mask: .byte $00
|
hi_mask: .byte $00
|
||||||
|
current_sprite: .res 2
|
||||||
raster_clock: .byte $06
|
raster_clock: .byte $06
|
||||||
|
|
||||||
.segment "CODE"
|
.segment "CODE"
|
||||||
|
|
||||||
.proc main_raster_irq
|
.proc main_raster_irq
|
||||||
|
; Make sure this is a raster interrupt and we're ready
|
||||||
|
lda _irq_setup_done
|
||||||
|
jeq unhandled
|
||||||
|
lda VIC_IRQ_RASTER
|
||||||
|
bit VIC_IRR
|
||||||
|
jeq unhandled
|
||||||
|
|
||||||
|
; set the flag so we know we've handled it
|
||||||
|
ora VIC_IRR
|
||||||
|
sta VIC_IRR
|
||||||
|
|
||||||
; if we're at the beginning of the sprite loop, initialize the variables
|
; if we're at the beginning of the sprite loop, initialize the variables
|
||||||
lda sprite_index
|
lda sprite_index
|
||||||
cmp #$ff
|
cmp #$ff
|
||||||
|
@ -88,8 +102,36 @@ sprite_update_loop:
|
||||||
lda new_y
|
lda new_y
|
||||||
sta current_y
|
sta current_y
|
||||||
|
|
||||||
|
lda #$01
|
||||||
|
ldx vic_sprite
|
||||||
|
beq done
|
||||||
|
shift:
|
||||||
|
asl
|
||||||
|
dex
|
||||||
|
bne shift
|
||||||
|
done:
|
||||||
|
eor #$ff
|
||||||
|
sta hi_mask
|
||||||
|
|
||||||
; prep the pointer for struct access
|
; prep the pointer for struct access
|
||||||
ldy #$00 ; FIXME offsetof(color)
|
lda current_sprite
|
||||||
|
ldx current_sprite+1
|
||||||
|
sta ptr1
|
||||||
|
stx ptr1+1
|
||||||
|
ldy #$00 ; FIXME offsetof(ena)
|
||||||
|
|
||||||
|
iny
|
||||||
|
himasker VIC_SPR_ENA
|
||||||
|
|
||||||
|
iny
|
||||||
|
himasker VIC_SPR_HI_X
|
||||||
|
|
||||||
|
iny
|
||||||
|
himasker VIC_SPR_EXP_X
|
||||||
|
sta VIC_SPR_EXP_Y
|
||||||
|
|
||||||
|
iny
|
||||||
|
himasker VIC_SPR_MCOLOR
|
||||||
|
|
||||||
; store color and pointer into arrays
|
; store color and pointer into arrays
|
||||||
ldx vic_sprite
|
ldx vic_sprite
|
||||||
|
@ -127,23 +169,6 @@ write_vic_sprite:
|
||||||
inx
|
inx
|
||||||
stx VIC_HLINE
|
stx VIC_HLINE
|
||||||
|
|
||||||
; Use enable bit as mask
|
|
||||||
iny
|
|
||||||
lda (ptr1),Y
|
|
||||||
eor #$ff
|
|
||||||
sta hi_mask
|
|
||||||
himasker VIC_SPR_ENA
|
|
||||||
|
|
||||||
iny
|
|
||||||
himasker VIC_SPR_HI_X
|
|
||||||
|
|
||||||
iny
|
|
||||||
himasker VIC_SPR_EXP_X
|
|
||||||
sta VIC_SPR_EXP_Y
|
|
||||||
|
|
||||||
iny
|
|
||||||
himasker VIC_SPR_MCOLOR
|
|
||||||
|
|
||||||
; inc sprite_index
|
; inc sprite_index
|
||||||
ldx sprite_index
|
ldx sprite_index
|
||||||
inx
|
inx
|
||||||
|
@ -161,6 +186,7 @@ moarcs:
|
||||||
sta sprite_index
|
sta sprite_index
|
||||||
|
|
||||||
get_next_sprite
|
get_next_sprite
|
||||||
|
|
||||||
; if new_y >= current_y + buffer
|
; if new_y >= current_y + buffer
|
||||||
lda current_y
|
lda current_y
|
||||||
clc
|
clc
|
||||||
|
@ -179,19 +205,6 @@ unhandled:
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
.proc raster_irq
|
.proc raster_irq
|
||||||
; Make sure this is a raster interrupt and we're ready
|
|
||||||
lda VIC_IRQ_RASTER
|
|
||||||
bit VIC_IRR
|
|
||||||
beq unhandled
|
|
||||||
|
|
||||||
; set the flag so we know we've handled it
|
|
||||||
ora VIC_IRR
|
|
||||||
sta VIC_IRR
|
|
||||||
|
|
||||||
; Make sure we're ready to start processing interrupts
|
|
||||||
lda _irq_setup_done
|
|
||||||
beq handled
|
|
||||||
|
|
||||||
lda ptr1
|
lda ptr1
|
||||||
ldx ptr1+1
|
ldx ptr1+1
|
||||||
sta ptr1_save
|
sta ptr1_save
|
||||||
|
@ -207,12 +220,4 @@ unhandled:
|
||||||
sta ptr1
|
sta ptr1
|
||||||
stx ptr1+1
|
stx ptr1+1
|
||||||
rts
|
rts
|
||||||
unhandled:
|
|
||||||
lda IRQ_NOT_HANDLED
|
|
||||||
lsr
|
|
||||||
rts
|
|
||||||
handled:
|
|
||||||
lda IRQ_HANDLED
|
|
||||||
lsr
|
|
||||||
rts
|
|
||||||
.endproc
|
.endproc
|
Loading…
Add table
Reference in a new issue