diff --git a/presets/c64/c64-sid.cfg b/presets/c64/c64-sid.cfg index 30b69ac2..a3c23039 100644 --- a/presets/c64/c64-sid.cfg +++ b/presets/c64/c64-sid.cfg @@ -5,7 +5,7 @@ SYMBOLS { __LOADADDR__: type = import; __EXEHDR__: type = import; __STACKSIZE__: type = weak, value = $0800; # 2k stack - __HIMEM__: type = weak, value = $D000; + __HIMEM__: type = weak, value = $8000; } MEMORY { ZP: file = "", define = yes, start = $0002, size = $001A; @@ -15,6 +15,7 @@ MEMORY { SIDFILE: file = %O, define = yes, start = $1000, size = $1000, fill = yes; MAIN: file = %O, define = yes, start = $2000, size = __HIMEM__ - $2000; BSS: file = "", start = __ONCE_RUN__, size = __HIMEM__ - __STACKSIZE__ - __ONCE_RUN__; + VICBANK: file = %O, start = $8000, size = $4000; } SEGMENTS { ZEROPAGE: load = ZP, type = zp; @@ -29,6 +30,7 @@ SEGMENTS { INIT: load = MAIN, type = rw; ONCE: load = MAIN, type = ro, define = yes; BSS: load = BSS, type = bss, define = yes; + VICBANK: load = MAIN, type = ro, optional = yes; } FEATURES { CONDES: type = constructor, diff --git a/presets/c64/climber.c b/presets/c64/climber.c index 1cf0c3e2..fc775437 100644 --- a/presets/c64/climber.c +++ b/presets/c64/climber.c @@ -5,6 +5,16 @@ #include #include +//#resource "c64-sid.cfg" +#define CFGFILE c64-sid.cfg + +//#resource "sidmusic1.bin" +//#link "sidplaysfx.ca65" +#include "sidplaysfx.h" + +//#link "rasterirq.ca65" +#include "rasterirq.h" + #include "bcd.h" //#link "bcd.c" @@ -17,13 +27,6 @@ #include "sprites.h" //#link "sprites.c" -//#resource "c64-sid.cfg" -#define CFGFILE c64-sid.cfg - -//#resource "sidmusic1.bin" -//#link "sidplaysfx.ca65" -#include "sidplaysfx.h" - // indices of sound effects #define SND_JUMP 0 #define SND_HIT 2 @@ -755,6 +758,16 @@ void play_scene() { blimp_pickup_scene(); } +// main display list +void game_displaylist(void) { + VIC.bordercolor = 2; + sid_update(); + VIC.bordercolor = 0; +// DLIST_NEXT(42); +// VIC.bordercolor = 3; + DLIST_RESTART(20); +} + // main program void main() { byte i; @@ -767,14 +780,16 @@ void main() { sprite_shape(hidbuf, 32+i, SPRITE_DATA[i]); } sprshad.spr_mcolor = 0xff; - sprshad.spr_mcolor0 = 0x0f; - sprshad.spr_mcolor1 = 0x00; + VIC.spr_mcolor0 = 0x0f; + VIC.spr_mcolor1 = 0x00; // select character set 2 VIC.addr = 0x15; // start scrolling @ bottom of level origin_y = START_ORIGIN_Y; // install joystick joy_install (joy_static_stddrv); + // setup display list + DLIST_SETUP(game_displaylist); // main game loop while (1) { make_floors(); diff --git a/presets/c64/hello.dasm b/presets/c64/hello.dasm index 906aa2c2..899940d3 100644 --- a/presets/c64/hello.dasm +++ b/presets/c64/hello.dasm @@ -7,6 +7,7 @@ Start sei ; turn off interrupts ldy #0 sty $d020 ; reset border color + Loop lda Message,y ; load message byte beq EOM ; 0 = end of string diff --git a/presets/c64/rasterirq.ca65 b/presets/c64/rasterirq.ca65 new file mode 100644 index 00000000..ad58d1fb --- /dev/null +++ b/presets/c64/rasterirq.ca65 @@ -0,0 +1,86 @@ + +USE_INTERRUPTOR = 0 + +.segment "DATA" + +StartDlist: .word NullDlist-1 +NextDlist: .word NullDlist-1 + +.segment "CODE" + +.global _dlist_setup +.global DLIST_IRQ_NEXT +.global DLIST_IRQ_RESTART +.if USE_INTERRUPTOR +.interruptor DLIST_IRQ +.endif + +_dlist_setup: + SEI ; set interrupt bit, make the CPU ignore interrupt requests + + sta StartDlist+0 ; save XA as pointer to start of dlist + stx StartDlist+1 + + LDA #%01111111 ; switch off interrupt signals from CIA-1 + STA $DC0D + + AND $D011 ; clear most significant bit of VIC's raster register + STA $D011 + + LDA $DC0D ; acknowledge pending interrupts from CIA-1 + LDA $DD0D ; acknowledge pending interrupts from CIA-2 + + LDA #252 ; set rasterline where interrupt shall occur + STA $D012 + +.if !USE_INTERRUPTOR + LDA #DLIST_IRQ + STA $0315 +.endif + + LDA #%00000001 ; enable raster interrupt signals from VIC + STA $D01A + cli + rts + +DLIST_IRQ: +DLIST_CALL: + lda NextDlist+1 + pha + lda NextDlist+0 + pha + rts + +DLIST_IRQ_RESTART: + sta $d012 + lda StartDlist+0 + sta NextDlist+0 + lda StartDlist+1 + sta NextDlist+1 + bne DLIST_ACK + +DLIST_IRQ_STOP: + lda #0 ; disable raster interrupt signals from VIC + sta $D01A + bne DLIST_ACK + +DLIST_IRQ_NEXT: + sta $d012 + pla + sta NextDlist+0 + pla + sta NextDlist+1 +DLIST_ACK: + ASL $D019 ; acknowledge the interrupt by clearing the VIC's interrupt flag +.if USE_INTERRUPTOR + clc + rts +.else + JMP $EA31 ; jump into KERNAL's standard interrupt service routine to handle keyboard scan, cursor display etc. +.endif + +NullDlist: + lda #252 + jmp DLIST_IRQ_RESTART diff --git a/presets/c64/rasterirq.h b/presets/c64/rasterirq.h new file mode 100644 index 00000000..087300d1 --- /dev/null +++ b/presets/c64/rasterirq.h @@ -0,0 +1,19 @@ +#ifndef _RASTERIRQ_H +#define _RASTERIRQ_H + + +void dlist_setup(void* ptr); + +#define DLIST_SETUP(func) \ + dlist_setup(((char*)func)-1) + +#define DLIST_NEXT(line) \ + __A__ = line; \ + asm ("jsr DLIST_IRQ_NEXT"); + +#define DLIST_RESTART(line) \ + __A__ = line; \ + asm ("jmp DLIST_IRQ_RESTART"); + + +#endif diff --git a/presets/c64/scroll4.c b/presets/c64/scroll4.c index 846b0361..7c3c07c7 100644 --- a/presets/c64/scroll4.c +++ b/presets/c64/scroll4.c @@ -8,183 +8,92 @@ #include #include -typedef uint8_t byte; -typedef uint16_t word; -typedef int8_t sbyte; +#include "common.h" +//#link "common.c" -#define COLS 40 -#define ROWS 25 +#include "scrolling.h" +//#link "scrolling.c" -void raster_wait(unsigned char line) { - while (VIC.rasterline < line) ; -} +#include "sprites.h" +//#link "sprites.c" -void wait_vblank() { - raster_wait(255); // TODO -} - -sbyte scroll_fine_x; -sbyte scroll_fine_y; -byte origin_x; -byte origin_y; -byte curbuf; -byte* scrnbuf[2]; // screen buffer(s) -byte tempbuf[COLS*ROWS]; - -void draw_cell(byte x, byte y) { +static void draw_cell(word ofs, byte x, byte y) { byte xx = x + origin_x; byte yy = y + origin_y; byte ch = xx ^ yy; - word ofs = x+y*COLS; - scrnbuf[curbuf][ofs] = ch; // character - tempbuf[ofs] = ch; // color + hidbuf[ofs] = ch; // character + colorbuf[ofs] = ch; // color } void scroll_draw_column(byte col) { byte y; + word ofs = col; for (y=0; y