Compare commits

...
Sign in to create a new pull request.

7 commits

Author SHA1 Message Date
11f5fad8aa Color customizations. Another launch config 2022-11-26 02:54:56 +01:00
b376f241bf on windows 2022-11-01 23:48:32 +01:00
empathicqubit
bc82bec9dd
Update devcontainer.json 2022-10-29 19:23:09 +02:00
empathicqubit
2eb8bebeb9 Add devcontainer 2022-10-29 15:22:18 +00:00
0660bf94ac Add sprite file 2022-10-29 16:59:46 +02:00
2564809c6d Path stuff 2021-11-22 18:54:21 +01:00
f30cc2ac3d Use register variables. 2021-10-11 13:23:51 +02:00
9 changed files with 120 additions and 66 deletions

View file

@ -0,0 +1,27 @@
{
"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
View file

@ -1,6 +1,6 @@
*.tab
*.o
*.s??
*.sw?
*~
*.dblite
build/

24
.vimspector.json Normal file
View file

@ -0,0 +1,24 @@
{
"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
View file

@ -4,19 +4,6 @@
// Weitere Informationen finden Sie unter https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "cc65-vice",
"request": "launch",
@ -29,10 +16,29 @@
},
"debugFile": "${workspaceFolder}/build/msprite.dbg",
"mapFile": "${workspaceFolder}/build/msprite.map",
"labelFile": "${workspaceFolder}/build/msprite.lbl",
"stopOnEntry": true,
"stopOnExit": true,
"viceArgs": [
"emulatorArgs": [
"-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",
"ntsc"
]

View file

@ -40,5 +40,10 @@
"c64.h": "c",
"cstring": "c",
"6502.h": "c"
},
"workbench.colorCustomizations": {
"activityBar.background": "#eee",
"activityBar.foreground": "#000000ff",
"activityBar.inactiveForeground": "#00000088"
}
}

View file

@ -8,7 +8,7 @@ character_start = 'D800'
if 'CC65_HOME' in os.environ:
cc65_home = os.environ['CC65_HOME']
else:
cc65_home = ''
cc65_home = str(Glob(os.environ['HOME'] + '/.vscode/extensions/entan-gl.cc65-vice*/dist/cc65')[0])
if 'DISPLAY' in os.environ:
display = os.environ['DISPLAY']
@ -19,6 +19,7 @@ print(cc65_home)
print(os.environ['PATH'])
env = Environment(
tools=['mingw'],
BUILDERS = {},
ENV = {
'PATH': os.environ["PATH"],
@ -26,13 +27,15 @@ env = Environment(
'DISPLAY': display,
},
AS = 'ca65',
ASFLAGS = ['-t', 'c64', '-g'],
ASFLAGS = ['-t', 'c64', '-g', '--cpu', '6502x'],
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'],
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']
)
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')])
sprites = Glob('res/sprites/*.spd')
@ -50,8 +53,8 @@ def disk_func(target, source, env):
typename = 's'
if basename.endswith('prg'):
typename = 'p'
changes.append(""" -delete '%s' -write '%s' '%s,%s'""" % (basename, str(src), basename, typename))
env.Execute("""c1541 -attach '%s' %s """ % (str(target[0]), ''.join(changes)))
changes.append(""" -delete "%s" -write "%s" "%s,%s" """ % (basename, str(src), basename, typename))
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)

BIN
res/sprites/sprites.spd Normal file

Binary file not shown.

View file

@ -193,7 +193,7 @@ typedef struct sprite_data* sprite_handle;
#define SPRITE_POOL_SIZE 32
struct sprite_data _sprite_pool[SPRITE_POOL_SIZE];
sprite_handle _sprite_list[SPRITE_POOL_SIZE];
unsigned char sprite_count;
unsigned char sprite_count = 0;
void init_sprite_pool(void) {
memset(&_sprite_pool, 0x00, sizeof(struct sprite_data) * SPRITE_POOL_SIZE);
@ -236,8 +236,10 @@ void set_sprite_x(sprite_handle a, unsigned int x) {
}
void set_sprite_y(sprite_handle a, unsigned char y) {
static sprite_handle *start_handle, *comp_handle, *current_handle;
static sprite_handle arg, comp;
register sprite_handle *comp_handle, *current_handle;
register sprite_handle comp;
static sprite_handle* start_handle;
static sprite_handle arg;
static unsigned char index, last_index, hi_mask, comp_y, yarg;
static bool direction, is_last;
@ -298,17 +300,13 @@ void set_sprite_y(sprite_handle a, unsigned char y) {
hi_mask = 1<<(index%VIC_SPR_COUNT);
__asm__("lda %v", comp);
__asm__("ldx %v+1", comp);
__asm__("ldy #%b", offsetof(struct sprite_data, ena));
__asm__("sta ptr1");
__asm__("stx ptr1+1");
__asm__("ldx %v", hi_mask);
__asm__("loop: lda (ptr1),Y");
__asm__("loop: lda (%v),Y", comp);
__asm__("beq done");
__asm__("txa");
__asm__("sta (ptr1),Y");
__asm__("sta (%v),Y", comp);
__asm__("done: iny");
__asm__("tya");
__asm__("sbc #%b", offsetof(struct sprite_data, multi));
@ -383,13 +381,11 @@ struct waw {
};
typedef struct waw waw;
void init_waw(waw* w) {
void init_waw(register waw* waw) {
static unsigned int x, sprite_x;
static unsigned char i, j, y, sprite_y, idx;
static waw* waw;
static sprite_handle sprite;
static sprite_handle* sprites;
waw = w;
x = waw->x + SCREEN_SPRITE_BORDER_X_START;
y = waw->y + SCREEN_SPRITE_BORDER_Y_START;
@ -418,14 +414,12 @@ void init_waw(waw* w) {
}
}
void update_waw(waw* w) {
void update_waw(register waw* waw) {
static unsigned char y;
static unsigned char idx;
static signed char change_y, mouth_offset;
static sprite_handle* sprites;
static sprite_handle sprite;
static waw* waw;
waw = w;
mouth_offset = waw->mouth_offset;
if(waw->mouth_direction) {
mouth_offset+=WAW_MOUTHSPEED;

View file

@ -24,12 +24,10 @@
tax
ldy __sprite_list,X
sty current_sprite
sty ptr1
inx
ldy __sprite_list,X
sty current_sprite+1
sty ptr1+1
ldy #$03 ; FIXME offsetof(lo_y)
@ -52,23 +50,11 @@ vic_sprite: .byte $00
current_y: .byte $00
new_y: .byte $00
hi_mask: .byte $00
current_sprite: .res 2
raster_clock: .byte $06
.segment "CODE"
.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
lda sprite_index
cmp #$ff
@ -102,22 +88,7 @@ sprite_update_loop:
lda new_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
lda current_sprite
ldx current_sprite+1
sta ptr1
stx ptr1+1
ldy #$00 ; FIXME offsetof(color)
; store color and pointer into arrays
@ -156,7 +127,11 @@ write_vic_sprite:
inx
stx VIC_HLINE
; Use enable bit as mask
iny
lda (ptr1),Y
eor #$ff
sta hi_mask
himasker VIC_SPR_ENA
iny
@ -186,7 +161,6 @@ moarcs:
sta sprite_index
get_next_sprite
; if new_y >= current_y + buffer
lda current_y
clc
@ -205,6 +179,19 @@ unhandled:
.endproc
.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
ldx ptr1+1
sta ptr1_save
@ -220,4 +207,12 @@ unhandled:
sta ptr1
stx ptr1+1
rts
unhandled:
lda IRQ_NOT_HANDLED
lsr
rts
handled:
lda IRQ_HANDLED
lsr
rts
.endproc