diff --git a/.vscode/launch.json b/.vscode/launch.json index 0e1c476..81045b8 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -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", diff --git a/SConstruct b/SConstruct index 739c68d..31b1429 100644 --- a/SConstruct +++ b/SConstruct @@ -26,7 +26,7 @@ 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', diff --git a/src/main.c b/src/main.c index 4e9bdf8..86beb3e 100644 --- a/src/main.c +++ b/src/main.c @@ -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; diff --git a/src/main_raster_irq_asm.s b/src/main_raster_irq_asm.s index 1bbde38..01316af 100644 --- a/src/main_raster_irq_asm.s +++ b/src/main_raster_irq_asm.s @@ -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 @@ -205,6 +180,17 @@ unhandled: .endproc .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 ldx ptr1+1 sta ptr1_save @@ -220,4 +206,8 @@ unhandled: sta ptr1 stx ptr1+1 rts +unhandled: + lda IRQ_NOT_HANDLED + lsr + rts .endproc \ No newline at end of file