link dependencies have depenencies too; coleco uses common.[ch]

This commit is contained in:
Steven Hugg 2018-08-12 19:59:08 -04:00
parent b81f4d04b9
commit bb639a0820
24 changed files with 243 additions and 379 deletions

View File

@ -1,9 +1,8 @@
#include <stdlib.h>
#include <string.h>
#include "cv.h"
#include "cvu.h"
#include <cv.h>
#include <cvu.h>
#define DEFINE_BIOS_FN(name,address) \
int name() { __asm call address __endasm; }

110
presets/coleco/common.c Normal file
View File

@ -0,0 +1,110 @@
#include <stdlib.h>
#include <string.h>
#include <cv.h>
#include <cvu.h>
#include "common.h"
volatile bool vint;
volatile uint_fast8_t vint_counter;
void vint_handler(void)
{
vint = true;
vint_counter++;
}
const unsigned char reverse_lookup[16] = {
0x0, 0x8, 0x4, 0xc, 0x2, 0xa, 0x6, 0xe, 0x1, 0x9, 0x5, 0xd, 0x3, 0xb, 0x7, 0xf, };
byte reverse_bits(byte n) {
return (reverse_lookup[n&0b1111] << 4) | reverse_lookup[n>>4];
}
void flip_sprite_patterns(word dest, const byte* patterns, word len) {
word i;
for (i=0; i<len; i++) {
cvu_voutb(reverse_bits(*patterns++), dest++ ^ 16); // swap left/right chars
}
}
char cursor_x;
char cursor_y;
void clrscr() {
cvu_vmemset(IMAGE, 0, COLS*ROWS);
}
byte getchar(byte x, byte y) {
return cvu_vinb(IMAGE + y*COLS + x);
}
void putchar(byte x, byte y, byte attr) {
cvu_voutb(attr, IMAGE + y*COLS + x);
}
void putstring(byte x, byte y, const char* string) {
while (*string) {
putchar(x++, y, CHAR(*string++));
}
}
void wait_vsync() {
vint = false;
while (!vint) ;
}
void delay(byte i) {
while (i--) {
wait_vsync();
}
}
byte rndint(byte a, byte b) {
return ((byte)rand() % (b-a+1)) + a;
}
void memset_safe(void* _dest, char ch, word size) {
byte* dest = _dest;
while (size--) {
*dest++ = ch;
}
}
char in_rect(byte x, byte y, byte x0, byte y0, byte w, byte h) {
return ((byte)(x-x0) < w && (byte)(y-y0) < h); // unsigned
}
void draw_bcd_word(byte x, byte y, word bcd) {
byte j;
x += 3;
for (j=0; j<4; j++) {
putchar(x, y, CHAR('0'+(bcd&0xf)));
x--;
bcd >>= 4;
}
}
// add two 16-bit BCD values
word bcd_add(word a, word b) {
a; b; // to avoid warning
__asm
ld hl,#4
add hl,sp
ld iy,#2
add iy,sp
ld a,0 (iy)
add a, (hl)
daa
ld c,a
ld a,1 (iy)
inc hl
adc a, (hl)
daa
ld b,a
ld l, c
ld h, b
__endasm;
}

59
presets/coleco/common.h Normal file
View File

@ -0,0 +1,59 @@
#ifndef _CV_COMMON_H
#define _CV_COMMON_H
/* VRAM map
0x0000 - 0x17ff character pattern table
0x1800 - 0x1aff image table
0x2000 - 0x37ff color table
0x3800 - 0x3bff sprite pattern table
0x3c00 - 0x3fff sprite attribute table
*/
#define PATTERN ((const cv_vmemp)0x0000)
#define IMAGE ((const cv_vmemp)0x1800)
#define COLOR ((const cv_vmemp)0x2000)
#define SPRITE_PATTERNS ((const cv_vmemp)0x3800)
#define SPRITES ((const cv_vmemp)0x3c00)
#define COLS 32
#define ROWS 24
typedef unsigned char byte;
typedef signed char sbyte;
typedef unsigned short word;
uintptr_t __at(0x6a) font_bitmap_a;
uintptr_t __at(0x6c) font_bitmap_0;
#define LOCHAR 0x20
#define HICHAR 0xff
#define CHAR(ch) (ch-LOCHAR)
extern volatile bool vint;
extern volatile uint_fast8_t vint_counter;
extern void vint_handler(void);
extern byte reverse_bits(byte n);
extern void flip_sprite_patterns(word dest, const byte* patterns, word len);
extern char cursor_x;
extern char cursor_y;
extern void clrscr();
extern byte getchar(byte x, byte y);
extern void putchar(byte x, byte y, byte attr);
extern void putstring(byte x, byte y, const char* string);
extern void wait_vsync();
extern void delay(byte i);
extern byte rndint(byte a, byte b);
extern void memset_safe(void* _dest, char ch, word size);
extern char in_rect(byte x, byte y, byte x0, byte y0, byte w, byte h);
// print 4-digit BCD value
extern void draw_bcd_word(byte x, byte y, word bcd);
// add two 16-bit BCD values
extern word bcd_add(word a, word b);
#endif

View File

@ -1,14 +1,13 @@
#include <stdint.h>
#include <stdlib.h>
#include <cv.h>
#include <cvu.h>
const uint8_t sprite[0x1][0x20] = {/*{w:16,h:16,remap:[4,0,1,2,3],brev:1}*/
{0xE0, 0xC0, 0xA0, 0x10, 0x0A, 0x04, 0x0B, 0x03, 0x03, 0x0B, 0x04, 0x0A, 0x10, 0xA0, 0xC0, 0xE0, 0x07, 0x03, 0x05, 0x08, 0x50, 0x20, 0xD0, 0xC0, 0xC0, 0xD0, 0x20, 0x50, 0x08, 0x05, 0x03, 0x07}
};
#include "cv.h"
#include "cvu.h"
/* VRAM map
0x0000 - 0x17ff character pattern table
0x1800 - 0x1aff image table

View File

@ -1,9 +1,8 @@
#include <stdlib.h>
#include <string.h>
#include "cv.h"
#include "cvu.h"
#include <cv.h>
#include <cvu.h>
#define SPRITE_PATTERNS ((const cv_vmemp)0x3800)
#define SPRITES ((const cv_vmemp)0x3c00)

View File

@ -2,9 +2,8 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "cv.h"
#include "cvu.h"
#include <cv.h>
#include <cvu.h>
#define IMAGE ((const cv_vmemp)0x1c00)

View File

@ -5,9 +5,8 @@
// Nodes from HUFFMAN_BS to HUFFMAN_RS - 1 do not have child nodes.
// Nodes from HUFFMAN_RS onward only have a left child node.
#include "cvu_compression.h"
#include "cvu.h"
#include <cvu_compression.h>
#include <cvu.h>
#define RLE_ESCAPE (const uint8_t)(253)

View File

@ -2,9 +2,8 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "cv.h"
#include "cvu.h"
#include <cv.h>
#include <cvu.h>
#define PATTERN ((const cv_vmemp)0x0)
#define COLOR ((const cv_vmemp)0x2000)

View File

@ -1,9 +1,8 @@
#include <stdlib.h>
#include <string.h>
#include "cv.h"
#include "cvu.h"
#include <cv.h>
#include <cvu.h>
#define SPRITE_PATTERNS ((const cv_vmemp)0x3800)
#define SPRITES ((const cv_vmemp)0x3c00)

View File

@ -2,9 +2,8 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "cv.h"
#include "cvu.h"
#include <cv.h>
#include <cvu.h>
#define PATTERN ((const cv_vmemp)0x0)
#define COLOR ((const cv_vmemp)0x2000)

View File

@ -2,9 +2,8 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "cv.h"
#include "cvu.h"
#include <cv.h>
#include <cvu.h>
#define PATTERN ((const cv_vmemp)0x0)
#define IMAGE ((const cv_vmemp)0x1800)

View File

@ -1,9 +1,8 @@
#include <stdlib.h>
#include <string.h>
#include "cv.h"
#include "cvu.h"
#include <cv.h>
#include <cvu.h>
#define PATTERN ((const cv_vmemp)0x0000)
#define IMAGE ((const cv_vmemp)0x1800)

View File

@ -1,9 +1,8 @@
#include <stdlib.h>
#include <string.h>
#include "cv.h"
#include "cvu.h"
#include <cv.h>
#include <cvu.h>
#define PATTERN ((const cv_vmemp)0x0000)
#define COLOR ((const cv_vmemp)0x2000)

View File

@ -1,34 +1,11 @@
#include <stdlib.h>
#include <string.h>
#include <cv.h>
#include <cvu.h>
#include "cv.h"
#include "cvu.h"
#define PATTERN ((const cv_vmemp)0x1000)
#define IMAGE ((const cv_vmemp)0x1800)
#define COLOR ((const cv_vmemp)0x2000)
#define SPRITE_PATTERNS ((const cv_vmemp)0x3800)
#define SPRITES ((const cv_vmemp)0x3c00)
#define COLS 32
#define ROWS 24
typedef unsigned char byte;
typedef signed char sbyte;
typedef unsigned short word;
uintptr_t __at(0x6a) font_bitmap_a;
uintptr_t __at(0x6c) font_bitmap_0;
volatile bool vint;
volatile uint_fast8_t vint_counter;
void vint_handler(void)
{
vint = true;
vint_counter++;
}
#include "common.h"
//#link "common.c"
#define XOFS 12 // sprite horiz. offset
@ -143,20 +120,6 @@ const byte sprite_table[NUM_SPRITE_PATTERNS*2][16*2] = {
///
const unsigned char reverse_lookup[16] = {
0x0, 0x8, 0x4, 0xc, 0x2, 0xa, 0x6, 0xe, 0x1, 0x9, 0x5, 0xd, 0x3, 0xb, 0x7, 0xf, };
byte reverse_bits(byte n) {
return (reverse_lookup[n&0b1111] << 4) | reverse_lookup[n>>4];
}
void flip_sprite_patterns(word dest, const byte* patterns, word len) {
word i;
for (i=0; i<len; i++) {
cvu_voutb(reverse_bits(*patterns++), dest++ ^ 16); // swap left/right chars
}
}
#define BGCOL CV_COLOR_BLUE
void setup_32_column_font() {
@ -167,7 +130,7 @@ void setup_32_column_font() {
cv_set_image_table(IMAGE);
cv_set_character_pattern_t(PATTERN);
cvu_memtovmemcpy(PATTERN, (void *)(font_bitmap_0 - '0'*8), 0x800);
cvu_memtovmemcpy(PATTERN, (void *)(font_bitmap_0 - 16*8), 96*8);
cvu_memtovmemcpy(PATTERN+8*64, char_table, sizeof(char_table));
cvu_memtovmemcpy(PATTERN+8*128, static_sprite_table, sizeof(static_sprite_table));
@ -183,43 +146,6 @@ void setup_32_column_font() {
cv_set_sprite_big(true);
}
char cursor_x;
char cursor_y;
void clrscr() {
cvu_vmemset(IMAGE, ' ', COLS*ROWS);
}
#define LOCHAR 0x0
#define HICHAR 0xff
#define CHAR(ch) (ch-LOCHAR)
byte getchar(byte x, byte y) {
return cvu_vinb(IMAGE + y*COLS + x);
}
void putchar(byte x, byte y, byte attr) {
cvu_voutb(attr, IMAGE + y*COLS + x);
}
void putstring(byte x, byte y, const char* string) {
while (*string) {
putchar(x++, y, CHAR(*string++));
}
}
void wait_vsync() {
vint = false;
while (!vint) ;
}
void delay(byte i) {
while (i--) {
wait_vsync();
}
}
///
typedef struct Level {
@ -250,10 +176,6 @@ bool ladder_in_gap(byte x, byte gap) {
return gap && x >= gap && x < gap+GAPSIZE*2;
}
byte rndint(byte a, byte b) {
return ((byte)rand() % (b-a+1)) + a;
}
void make_levels() {
byte i;
byte y=0;

View File

@ -1,46 +1,16 @@
#include <stdlib.h>
#include <string.h>
#include <cv.h>
#include <cvu.h>
#include "cv.h"
#include "cvu.h"
#include "common.h"
//#link "common.c"
/* VRAM map
0x0000 - 0x17ff character pattern table
0x1800 - 0x1aff image table
0x2000 - 0x37ff color table
0x3800 - 0x3bff sprite pattern table
0x3c00 - 0x3fff sprite attribute table
*/
const cv_vmemp PATTERN = 0x0000;
const cv_vmemp IMAGE = 0x1800;
const cv_vmemp COLOR = 0x2000;
const cv_vmemp SPRITE_PATTERNS = 0x3800;
const cv_vmemp SPRITES = 0x3c00;
#define COLS 32
#define ROWS 24
#define NSPRITES 16
#define NMISSILES 8
#define YOFFSCREEN 239
typedef unsigned char byte;
typedef signed char sbyte;
typedef unsigned short word;
uintptr_t __at(0x6a) font_bitmap_a;
uintptr_t __at(0x6c) font_bitmap_0;
volatile bool vint;
volatile uint_fast8_t vint_counter;
void vint_handler(void)
{
vint = true;
vint_counter++;
}
static byte pattern_table[8*2] = {
/*{w:16,h:8,remap:[3,0,1,2]}*/
0xCC, 0xF2, 0xD0, 0xFC, 0xF3, 0xE8, 0xC4, 0x03,
@ -176,85 +146,6 @@ void setup_32_column_font() {
set_shifted_pattern(pattern_table, PATTERN+67*8+i*3*8, i);
}
#define LOCHAR 0x20
#define HICHAR 0xff
#define CHAR(ch) (ch-LOCHAR)
#define BLANK 0
void clrscr() {
cvu_vmemset(IMAGE, CHAR(' '), COLS*ROWS);
}
byte getchar(byte x, byte y) {
return cvu_vinb(IMAGE + y*COLS + x);
}
void putchar(byte x, byte y, byte attr) {
cvu_voutb(attr, IMAGE + y*COLS + x);
}
void putstring(byte x, byte y, const char* string) {
while (*string) {
putchar(x++, y, CHAR(*string++));
}
}
void wait_vsync() {
vint = false;
while (!vint) ;
}
void delay(byte i) {
while (i--) {
wait_vsync();
}
}
void memset_safe(void* _dest, char ch, word size) {
byte* dest = _dest;
while (size--) {
*dest++ = ch;
}
}
char in_rect(byte x, byte y, byte x0, byte y0, byte w, byte h) {
return ((byte)(x-x0) < w && (byte)(y-y0) < h); // unsigned
}
void draw_bcd_word(byte x, byte y, word bcd) {
byte j;
x += 3;
for (j=0; j<4; j++) {
putchar(x, y, CHAR('0'+(bcd&0xf)));
x--;
bcd >>= 4;
}
}
// add two 16-bit BCD values
word bcd_add(word a, word b) {
a; b; // to avoid warning
__asm
ld hl,#4
add hl,sp
ld iy,#2
add iy,sp
ld a,0 (iy)
add a, (hl)
daa
ld c,a
ld a,1 (iy)
inc hl
adc a, (hl)
daa
ld b,a
ld l, c
ld h, b
__endasm;
}
// GAME CODE
typedef struct {
@ -347,6 +238,8 @@ void setup_formation() {
enemies_left = MAX_IN_FORMATION;
}
#define BLANK 0
void draw_row(byte row) {
byte i;
byte x = formation_offset_x / 8;

View File

@ -1,79 +1,22 @@
#include <stdlib.h>
#include <string.h>
#include <cv.h>
#include <cvu.h>
#include "cv.h"
#include "cvu.h"
#define COLOR ((const cv_vmemp)0x2000)
#define IMAGE ((const cv_vmemp)0x1c00)
#define COLS 32
#define ROWS 24
typedef unsigned char byte;
typedef signed char sbyte;
typedef unsigned short word;
uintptr_t __at(0x6a) font_bitmap_a;
uintptr_t __at(0x6c) font_bitmap_0;
volatile bool vint;
volatile uint_fast8_t vint_counter;
void vint_handler(void)
{
vint = true;
vint_counter++;
}
#include "common.h"
//#link "common.c"
void setup_32_column_font() {
cv_set_image_table(IMAGE);
cvu_memtovmemcpy(0x1800, (void *)(font_bitmap_0 - '0'*8), 256*8);
cv_set_character_pattern_t(0x1800);
cvu_memtovmemcpy(PATTERN, (void *)(font_bitmap_0 - 16*8), 96*8);
cv_set_character_pattern_t(PATTERN);
cv_set_screen_mode(CV_SCREENMODE_STANDARD);
cv_set_color_table(COLOR);
cvu_vmemset(COLOR, 0x30, 8); // set color for chars 0-63
cvu_vmemset(COLOR+8, 0x50, 32-8); // set chars 63-255
}
char cursor_x;
char cursor_y;
void clrscr() {
cvu_vmemset(IMAGE, ' ', COLS*ROWS);
}
#define LOCHAR 0x0
#define HICHAR 0xff
#define CHAR(ch) (ch-LOCHAR)
byte getchar(byte x, byte y) {
return cvu_vinb(IMAGE + y*COLS + x);
}
void putchar(byte x, byte y, byte attr) {
cvu_voutb(attr, IMAGE + y*COLS + x);
}
void putstring(byte x, byte y, const char* string) {
while (*string) {
putchar(x++, y, CHAR(*string++));
}
}
void wait_vsync() {
vint = false;
while (!vint) ;
}
void delay(byte i) {
while (i--) {
wait_vsync();
}
}
////////// GAME DATA
typedef struct {
@ -98,7 +41,9 @@ byte frames_per_move;
///////////
const char BOX_CHARS[8] = { '+', '+', '+', '+', '-', '-', '!', '!' };
const char BOX_CHARS[8] = {
CHAR('+'), CHAR('+'), CHAR('+'), CHAR('+'),
CHAR('-'), CHAR('-'), CHAR('!'), CHAR('!') };
void draw_box(byte x, byte y, byte x2, byte y2, const char* chars) {
byte x1 = x;
@ -132,8 +77,8 @@ void init_game() {
memset(players, 0, sizeof(players));
players[0].head_attr = CHAR('1');
players[1].head_attr = CHAR('2');
players[0].tail_attr = '@';
players[1].tail_attr = '%';
players[0].tail_attr = CHAR('@');
players[1].tail_attr = CHAR('%');
frames_per_move = START_SPEED;
}

View File

@ -2,8 +2,8 @@
const uint16_t notes[] = { 12846, 12334, 11086, 10062, 10062, 9806, 10062, 10574, 11086, 10062, 11086, 12430, 11042, 12334, 12878, 14158, 14158, 12878, 13390, 13646, 10574, 9806, 10574, 12430, 12846, 12334, 11086, 10062, 10062, 9806, 10062, 10574, 11086, 10062, 11086, 12430, 11054, 12334, 12878, 14158, 14158, 12878, 13390, 13646, 10574, 10062, 10062, 10126, 11054, 12334, 12878, 14158, 13902, 14158, 14670, 14158, 13646, 12878, 13390, 13646, 3918, 12878, 14158, 13902, 12878, 12366, 12878, 12366, 12878, 11086, 10062, 9870, 12334, 11054, 11086, 10062, 10062, 9806, 10062, 10574, 11086, 10062, 11086, 12430, 11054, 12334, 12878, 14158, 14158, 12878, 13390, 13646, 10574, 10062, 10062, 10126, 0xffff };
#include "cv.h"
#include "cvu_sound.h"
#include <cv.h>
#include <cvu_sound.h>
struct cvu_music music;

View File

@ -1,79 +1,22 @@
#include <stdlib.h>
#include <string.h>
#include <cv.h>
#include <cvu.h>
#include "cv.h"
#include "cvu.h"
#define COLOR ((const cv_vmemp)0x2000)
#define IMAGE ((const cv_vmemp)0x1c00)
#define COLS 32
#define ROWS 24
typedef unsigned char byte;
typedef signed char sbyte;
typedef unsigned short word;
uintptr_t __at(0x6a) font_bitmap_a;
uintptr_t __at(0x6c) font_bitmap_0;
volatile bool vint;
volatile uint_fast8_t vint_counter;
void vint_handler(void)
{
vint = true;
vint_counter++;
}
#include "common.h"
//#link "common.c"
void setup_32_column_font() {
cv_set_image_table(IMAGE);
cvu_memtovmemcpy(0x1800, (void *)(font_bitmap_0 - '0'*8), 256*8);
cv_set_character_pattern_t(0x1800);
cvu_memtovmemcpy(PATTERN, (void *)(font_bitmap_0 - 16*8), 96*8);
cv_set_character_pattern_t(PATTERN);
cv_set_screen_mode(CV_SCREENMODE_STANDARD);
cv_set_color_table(COLOR);
cvu_vmemset(COLOR, 0x36, 8); // set color for chars 0-63
cvu_vmemset(COLOR+8, 0x06, 32-8); // set chars 63-255
}
char cursor_x;
char cursor_y;
void clrscr() {
cvu_vmemset(IMAGE, ' ', COLS*ROWS);
}
#define LOCHAR 0x0
#define HICHAR 0xff
#define CHAR(ch) (ch-LOCHAR)
byte getchar(byte x, byte y) {
return cvu_vinb(IMAGE + y*COLS + x);
}
void putchar(byte x, byte y, byte attr) {
cvu_voutb(attr, IMAGE + y*COLS + x);
}
void putstring(byte x, byte y, const char* string) {
while (*string) {
putchar(x++, y, CHAR(*string++));
}
}
void wait_vsync() {
vint = false;
while (!vint) ;
}
void delay(byte i) {
while (i--) {
wait_vsync();
}
}
void main() {
setup_32_column_font();
cv_set_screen_active(true);

View File

@ -1,8 +1,7 @@
#include <stdlib.h>
#include <string.h>
#include "cv.h"
#include "cvu.h"
#include <cv.h>
#include <cvu.h>
#define PATTERN ((const cv_vmemp)0x0000)
#define COLOR ((const cv_vmemp)0x2000)

View File

@ -1,5 +1,6 @@
#include "cv.h"
#include "cvu.h"
#include <cv.h>
#include <cvu.h>
#define PATTERN 0x0000
#define IMAGE 0x0800

View File

@ -1,8 +1,7 @@
#include <stdio.h>
#include "cv.h"
#include "cvu.h"
#include <cv.h>
#include <cvu.h>
#define PATTERN 0x0000
#define IMAGE 0x1c00

View File

@ -63,7 +63,8 @@ export class CodeProject {
}
} else {
// for .asm -- [.]include "file"
var re2 = /^\s+([.]?include)\s+"(.+?)"/gm;
// for .c -- #include "file"
var re2 = /^\s+([.#]?include)\s+"(.+?)"/gm;
while (m = re2.exec(text)) {
files.push(m[2]);
}
@ -117,20 +118,20 @@ export class CodeProject {
// TODO: add preproc directive for __MAINFILE__
var mainfilename = getFilenameForPath(this.mainpath);
var maintext = this.getFile(this.mainpath);
var files = [mainfilename];
var depfiles = [];
msg.updates.push({path:mainfilename, data:maintext});
for (var dep of depends) {
if (!dep.link) {
msg.updates.push({path:dep.filename, data:dep.data});
files.push(dep.filename);
depfiles.push(dep.filename);
}
}
msg.buildsteps.push({path:mainfilename, files:files, platform:this.platform_id, tool:this.platform.getToolForFilename(this.mainpath), mainfile:true});
msg.buildsteps.push({path:mainfilename, files:[mainfilename].concat(depfiles), platform:this.platform_id, tool:this.platform.getToolForFilename(this.mainpath), mainfile:true});
for (var dep of depends) {
if (dep.data && dep.link) {
this.preloadWorker(dep.filename);
msg.updates.push({path:dep.filename, data:dep.data});
msg.buildsteps.push({path:dep.filename, platform:this.platform_id, tool:this.platform.getToolForFilename(dep.path)});
msg.buildsteps.push({path:dep.filename, files:[dep.filename].concat(depfiles), platform:this.platform_id, tool:this.platform.getToolForFilename(dep.path)});
}
}
return msg;
@ -211,6 +212,7 @@ export class CodeProject {
if (!this.mainpath) throw "need to call setMainFile first";
var maindata = this.getFile(this.mainpath);
var text = typeof maindata === "string" ? maindata : '';
// TODO: load dependencies of non-main files
this.loadFileDependencies(text, (err, depends) => {
if (err) {
console.log(err); // TODO?

View File

@ -986,7 +986,7 @@ function compileSDCC(step) {
populateFiles(step, FS);
// load source file and preprocess
var code = workfs[step.path].data; // TODO
var preproc = preprocessMCPP(code, step.platform);
var preproc = preprocessMCPP(step);
if (preproc.errors) return preproc;
else code = preproc.code;
// pipe file to stdin
@ -1024,8 +1024,9 @@ function compileSDCC(step) {
};
}
function preprocessMCPP(code, platform, toolname) {
function preprocessMCPP(step) {
load("mcpp");
var platform = step.platform;
var params = PLATFORM_PARAMS[platform];
if (!params) throw Error("Platform not supported: " + platform);
// <stdin>:2: error: Can't open include file "foo.h"
@ -1039,7 +1040,7 @@ function preprocessMCPP(code, platform, toolname) {
});
var FS = MCPP['FS'];
setupFS(FS, 'sdcc'); // TODO: toolname
FS.writeFile("main.c", code, {encoding:'utf8'});
populateFiles(step, FS);
// TODO: make configurable by other compilers
var args = [
"-D", "__8BITWORKSHOP__",
@ -1047,7 +1048,7 @@ function preprocessMCPP(code, platform, toolname) {
"-D", "__SDCC_z80",
"-I", "/share/include",
"-Q",
"main.c", "main.i"];
step.path, "main.i"];
if (params.extra_preproc_args) {
args.push.apply(args, params.extra_preproc_args);
}

View File

@ -152,8 +152,9 @@ describe('Worker', function() {
compile('sdcc', csource, 'sound_williams-z80', done, 16384, 6, 0);
});
it('should compile coleco skeleton', function(done) {
var csource = ab2str(fs.readFileSync('presets/coleco/skeleton.sdcc'));
compile('sdcc', csource, 'coleco', done, 32768, 31, 0);
// TODO: can't do skeleton b/c of dependencies
var csource = ab2str(fs.readFileSync('presets/coleco/text.c'));
compile('sdcc', csource, 'coleco', done, 32768, 14, 0);
});
it('should compile verilog example', function(done) {
var csource = ab2str(fs.readFileSync('presets/verilog/lfsr.v'));