-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
212 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
|
||
#include <conio.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <peekpoke.h> | ||
#include <string.h> | ||
#include <c64.h> | ||
#include <cbm_petscii_charmap.h> | ||
|
||
#include "sidmacros.h" | ||
#include "common.h" | ||
//#link "common.c" | ||
|
||
void digi_setup(void) { | ||
SID.v1.sr = 0xFF; // Voice 1 Sustain/Release | ||
SID.v2.sr = 0xFF; // Voice 2 Sustain/Release | ||
SID.v3.sr = 0xFF; // Voice 3 Sustain/Release | ||
SID.v1.ctrl = 0x49; // Voice 1 Control Register | ||
SID.v2.ctrl = 0x49; // Voice 2 Control Register | ||
SID.v3.ctrl = 0x49; // Voice 3 Control Register | ||
} | ||
|
||
void cia2_wait() { | ||
byte timer = CIA2.ta_lo; | ||
while (CIA2.ta_lo < timer) ; | ||
} | ||
|
||
void digi_play(const char* snd, unsigned int len) { | ||
unsigned int i; // loop counter | ||
VIC.ctrl1 = 0; // disable video | ||
asm("sei"); // disable interrupts | ||
// setup CIA #2 timer | ||
CIA2.cra = 0x00; // stop timer A | ||
CIA2.ta_lo = IS_PAL() ? 123 : 128; // set lower timer value | ||
CIA2.ta_hi = 0; // set upper timer value | ||
CIA2.cra = 0x11; // start timer, continuous mode | ||
// loop through all samples | ||
for (i = 0; i < len; i++) { | ||
// wait for timer to reset | ||
cia2_wait(); | ||
// send upper 4-bit sample | ||
SID.amp = snd[i] >> 4; | ||
// wait for timer to reset | ||
cia2_wait(); | ||
// send lower 4-bit sample | ||
SID.amp = snd[i] & 15; | ||
// make a video effect | ||
VIC.bordercolor = i; | ||
} | ||
asm("cli"); // enable interrupts | ||
VIC.ctrl1 = 0x1b; // enable video | ||
CIA2.cra = 0x00; // stop timer A | ||
VIC.bordercolor = COLOR_BLUE; | ||
} | ||
|
||
#ifdef __MAIN__ | ||
|
||
const char digisound[] = { | ||
#embed "springchicken-b4.raw" | ||
}; | ||
|
||
void main(void) { | ||
clrscr(); | ||
digi_setup(); | ||
while (1) { | ||
digi_play(digisound, 0xacf8L); | ||
printf("\nPress ENTER to restart digi...\n"); | ||
getchar(); | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
|
||
#include "common.h" | ||
//#link "common.c" | ||
|
||
#include "rasterirq.h" | ||
//#link "rasterirq.ca65" | ||
|
||
#include "bcd.h" | ||
//#link "bcd.c" | ||
|
||
extern const unsigned char sinustable[0x100]; | ||
//#link "sinustable.c" | ||
|
||
///// VARIABLES | ||
|
||
byte frame = 0; | ||
byte target_y; | ||
|
||
byte fld_offsets[25]; | ||
|
||
///// FUNCTIONS | ||
|
||
void line_crunch() { | ||
// load scroll y | ||
asm("lda %v", target_y); | ||
asm("and #7"); | ||
asm("ora #$18"); | ||
asm("tax"); | ||
// get current raster line | ||
asm("lda $d012"); | ||
// wait for next raster line | ||
asm("@loop:"); | ||
asm("cmp $d012"); | ||
asm("beq @loop"); | ||
// set y scroll (ctrl1) | ||
asm("stx $d011"); | ||
} | ||
|
||
static byte target_line = 0; | ||
static byte row; | ||
static byte offset; | ||
|
||
void display_list(void) { | ||
|
||
VIC.bgcolor[0] = COLOR_CYAN; | ||
VIC.bordercolor = COLOR_BLUE; | ||
|
||
// set initial YSCROLL | ||
SET_SCROLL_Y(fld_offsets[0]); | ||
|
||
// set first target scanline | ||
target_line = 48 + (fld_offsets[0] & 7); | ||
|
||
// each row has its own FLD gap | ||
for (row=1; row<25; row++) { | ||
// get this row's gap distance | ||
offset = fld_offsets[row]; | ||
// fire IRQ 3 lines before target | ||
target_y = target_line - 3; | ||
DLIST_NEXT(target_y); | ||
// change Y scroll to avoid badline | ||
line_crunch(); | ||
// set Y scroll for new badline | ||
target_y = target_line + offset; | ||
line_crunch(); | ||
// set target line for next IRQ | ||
target_line += 8 + offset; | ||
VIC.bgcolor[0] = row; | ||
// exit loop if integer overflow | ||
if (target_line < 48) break; | ||
} | ||
|
||
DLIST_RESTART(30); | ||
} | ||
|
||
void main() { | ||
int i; | ||
|
||
clrscr(); | ||
|
||
memset(COLOR_RAM, COLOR_BLUE, 1000); | ||
|
||
for (i=0; i<40*25; i++) | ||
POKE(0x400 + i, 205 + (rand() & 1)); | ||
for (i=40*25; i<1024; i++) | ||
POKE(0x400 + i, i); | ||
for (i=0; i<1024; i+=40) | ||
POKE(0x400 + i, 122); | ||
|
||
SET_VIC_BITMAP(0x1000); | ||
|
||
DLIST_SETUP(display_list); | ||
|
||
// game loop, repeat forever | ||
while (1) { | ||
// wait for end of frame | ||
waitvsync(); | ||
|
||
// animate and set scroll_y | ||
frame += 4; | ||
|
||
// set FLD offsets via sinus table | ||
for (i=0; i<25; i++) { | ||
fld_offsets[i] = sinustable[frame + i*8] >> 5; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters