Use register variables.

This commit is contained in:
Empathic Qubit 2021-10-11 13:23:51 +02:00
parent 690f50c9f4
commit f30cc2ac3d
4 changed files with 28 additions and 57 deletions

13
.vscode/launch.json vendored
View file

@ -4,19 +4,6 @@
// 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",

View file

@ -26,7 +26,7 @@ env = Environment(
'DISPLAY': display, 'DISPLAY': display,
}, },
AS = 'ca65', AS = 'ca65',
ASFLAGS = ['-t', 'c64', '-g'], ASFLAGS = ['-t', 'c64', '-g', '--cpu', '6502x'],
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',

View file

@ -236,8 +236,10 @@ 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) {
static sprite_handle *start_handle, *comp_handle, *current_handle; register sprite_handle *comp_handle, *current_handle;
static sprite_handle arg, comp; 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 unsigned char index, last_index, hi_mask, comp_y, yarg;
static bool direction, is_last; 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); 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__("ldy #%b", offsetof(struct sprite_data, ena));
__asm__("sta ptr1");
__asm__("stx ptr1+1");
__asm__("ldx %v", hi_mask); __asm__("ldx %v", hi_mask);
__asm__("loop: lda (ptr1),Y"); __asm__("loop: lda (%v),Y", comp);
__asm__("beq done"); __asm__("beq done");
__asm__("txa"); __asm__("txa");
__asm__("sta (ptr1),Y"); __asm__("sta (%v),Y", comp);
__asm__("done: iny"); __asm__("done: iny");
__asm__("tya"); __asm__("tya");
__asm__("sbc #%b", offsetof(struct sprite_data, multi)); __asm__("sbc #%b", offsetof(struct sprite_data, multi));
@ -383,13 +381,11 @@ struct waw {
}; };
typedef struct waw waw; typedef struct waw waw;
void init_waw(waw* w) { void init_waw(register waw* waw) {
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;
@ -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 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;

View file

@ -24,12 +24,10 @@
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)
@ -52,23 +50,11 @@ 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
@ -102,22 +88,7 @@ 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
lda current_sprite
ldx current_sprite+1
sta ptr1
stx ptr1+1
ldy #$00 ; FIXME offsetof(color) ldy #$00 ; FIXME offsetof(color)
; store color and pointer into arrays ; store color and pointer into arrays
@ -156,7 +127,11 @@ write_vic_sprite:
inx inx
stx VIC_HLINE stx VIC_HLINE
; Use enable bit as mask
iny iny
lda (ptr1),Y
eor #$ff
sta hi_mask
himasker VIC_SPR_ENA himasker VIC_SPR_ENA
iny iny
@ -205,6 +180,17 @@ unhandled:
.endproc .endproc
.proc raster_irq .proc raster_irq
; Make sure this is a raster interrupt and we're ready
lda _irq_setup_done
beq unhandled
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
lda ptr1 lda ptr1
ldx ptr1+1 ldx ptr1+1
sta ptr1_save sta ptr1_save
@ -220,4 +206,8 @@ unhandled:
sta ptr1 sta ptr1
stx ptr1+1 stx ptr1+1
rts rts
unhandled:
lda IRQ_NOT_HANDLED
lsr
rts
.endproc .endproc