updated presets for new sdcc lib; remap attribute

This commit is contained in:
Steven Hugg 2017-05-08 07:58:45 -04:00
parent 1675ab628e
commit 21ddfce92a
14 changed files with 410 additions and 38 deletions

View File

@ -37,6 +37,9 @@ body {
<li><a class="dropdown-item" href="#" id="item_share_file">Share File as GitHub Gist...</a></li>
<li><a class="dropdown-item" href="#" id="item_reset_file">Revert to Original...</a></li>
<li><a class="dropdown-item" href="#" id="item_download_rom">Download ROM Image...</a></li>
<!--
<li><a class="dropdown-item" href="#" id="item_record_video">Record Video...</a></li>
-->
<li class="dropdown dropdown-submenu">
<a tabindex="-1" href="#">Platform</a>
<ul class="dropdown-menu">

View File

@ -1,8 +1,8 @@
#include <stdint.h>
const uint8_t sprite[0x1][0x20] = {
{0xa0, 0x40, 0xa0, 0x10, 0xa, 0x4, 0xa, 0, 0, 0xa, 0x4, 0xa, 0x10, 0xa0, 0x40, 0xa0, 0x5, 0x2, 0x5, 0x8, 0x50, 0x20, 0x50, 0, 0, 0x50, 0x20, 0x50, 0x8, 0x5, 0x2, 0x5}
const uint8_t sprite[0x1][0x20] = {/*{w:16,h:16,remap:[4,0,1,2,3],brev:1}*/
{0xa0, 0x40, 0xa0, 0x10, 0xa, 0x4, 0xa, 0x0, 0x0, 0xa, 0x4, 0xa, 0x10, 0xa0, 0x40, 0xa0, 0x5, 0x2, 0x5, 0x8, 0x50, 0x20, 0x50, 0x0, 0x0, 0x50, 0x20, 0x50, 0x8, 0x5, 0x2, 0x5}
};
#include "cv.h"

94
presets/coleco/lines.c Normal file
View File

@ -0,0 +1,94 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "cv.h"
#include "cvu.h"
#define PATTERN ((const cv_vmemp)0x0)
#define COLOR ((const cv_vmemp)0x2000)
#define IMAGE ((const cv_vmemp)0x1800)
#define COLS 32
#define ROWS 24
typedef unsigned char byte;
typedef signed char sbyte;
typedef unsigned short word;
void setup_mode2() {
cvu_vmemset(0, 0, 0x4000);
cv_set_screen_mode(CV_SCREENMODE_BITMAP); // mode 2
cv_set_image_table(IMAGE);
cv_set_character_pattern_t(PATTERN|0x1fff); // AND mask
cv_set_color_table(COLOR|0xfff); // AND mask
cv_set_sprite_attribute_table(0x2800);
{
byte i=0;
do {
cvu_voutb(i, IMAGE+i);
cvu_voutb(i, IMAGE+0x100+i);
cvu_voutb(i, IMAGE+0x200+i);
} while (++i);
}
}
void set_pixel(byte x, byte y, byte color) {
word ofs = (x/8)*8 + (y/8)*256 + (y&7);
byte b = cvu_vinb(PATTERN + ofs);
if (y >= 192) return;
if (color>1) {
b |= 128 >> (x&7);
cvu_voutb(b, PATTERN + ofs);
cvu_voutb(color<<4, COLOR + ofs);
} else {
b &= ~(128 >> (x&7));
cvu_voutb(b, PATTERN + ofs);
}
}
void draw_line(int x0, int y0, int x1, int y1, byte color)
{
int dx, dy, p, x, y;
dx=x1-x0;
dy=y1-y0;
x=x0;
y=y0;
p=2*dy-dx;
while(x<x1)
{
if(p>=0)
{
set_pixel(x,y,color);
y=y+1;
p=p+2*dy-2*dx;
}
else
{
set_pixel(x,y,color);
p=p+2*dy;
}
x=x+1;
}
}
void main() {
setup_mode2();
cv_set_screen_active(true);
while(1)
draw_line(rand()&0xff, rand()&0xff, rand()&0xff, rand()&0xff, rand()&15);
/*
set_pixel(0, 0, 2);
set_pixel(1, 0, 2);
set_pixel(0, 1, 2);
set_pixel(2, 2, 2);
set_pixel(3, 3, 2);
set_pixel(0, 7, 4);
set_pixel(7, 7, 4);
set_pixel(8, 7, 4);
set_pixel(0, 8, 4);
draw_line(20,0,210,150,2);
while(1);
*/
}

97
presets/coleco/mode2.c Normal file
View File

@ -0,0 +1,97 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "cv.h"
#include "cvu.h"
#define PATTERN ((const cv_vmemp)0x0)
#define COLOR ((const cv_vmemp)0x2000)
#define IMAGE ((const cv_vmemp)0x1800)
#define COLS 32
#define ROWS 24
uintptr_t __at(0x6a) font_bitmap_a;
uintptr_t __at(0x6c) font_bitmap_0;
void setup_32_column_font() {
cvu_vmemset(0, 0, 0x4000);
cv_set_image_table(IMAGE);
cvu_memtovmemcpy(PATTERN, (void *)(font_bitmap_0 - '0'*8), 0x800);
cvu_memtovmemcpy(PATTERN+0x800, (void *)(font_bitmap_0 - '0'*2), 0x800);
cvu_memtovmemcpy(PATTERN+0x1000, (void *)(font_bitmap_0 - '0'*0), 0x800);
cv_set_character_pattern_t(PATTERN|0x1fff); // AND mask
cv_set_screen_mode(CV_SCREENMODE_BITMAP); // mode 2
cv_set_color_table(0x2000|0xfff); // AND mask
{
int i;
for (i=0; i<0x800; i++)
cvu_voutb((i&15)|0x2, COLOR+i);
for (i=0x800; i<0x1000; i++)
cvu_voutb(((i&15)|0x2)<<4, COLOR+i);
}
}
char cursor_x;
char cursor_y;
void clrscr() {
cvu_vmemset(IMAGE, ' ', COLS*ROWS);
}
void setup_stdio() {
cursor_x = 0;
cursor_y = 0;
clrscr();
}
void scrollup() {
char buf[COLS];
char y;
for (y=0; y<ROWS-1; y++) {
cvu_vmemtomemcpy(buf, IMAGE + COLS*y + COLS, COLS);
cvu_memtovmemcpy(IMAGE + COLS*y, buf, COLS);
}
cvu_vmemset(IMAGE + COLS*(ROWS-1), ' ', COLS);
}
void newline() {
if (cursor_y >= ROWS-1) {
scrollup();
} else {
cursor_y++;
}
}
int putchar(int ch) {
switch (ch) {
case '\n':
newline(); // TODO: scrolling
case '\r':
cursor_x = 0;
return 0;
}
cvu_voutb(ch, IMAGE + COLS*cursor_y + cursor_x);
cursor_x++;
if (cursor_x >= COLS) {
newline();
cursor_x = 0;
}
}
void main() {
unsigned char byteval = 123;
signed char charval = 123;
short shortval = 12345;
setup_32_column_font();
setup_stdio();
cv_set_screen_active(true);
printf("HELLO WORLD!\n");
while (1) {
printf("char %d byte %u sh %d\n",
charval++, byteval++, shortval++);
}
}

View File

@ -0,0 +1,88 @@
#include <stdlib.h>
#include <string.h>
#include "cv.h"
#include "cvu.h"
#define PATTERN ((const cv_vmemp)0x0000)
#define IMAGE ((const cv_vmemp)0x1800)
#define COLS 64
#define ROWS 48
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;
void setup_multicolor() {
cvu_vmemset(0, 0, 0x4000);
cv_set_image_table(IMAGE);
cv_set_character_pattern_t(PATTERN);
cv_set_screen_mode(CV_SCREENMODE_MULTICOLOR); // mode 3
// set image table
{
byte x,y;
word ofs = IMAGE;
for (y=0; y<ROWS; y++) {
for (x=0; x<COLS/2; x++) {
cvu_voutb(x + (y>>2)*COLS/2, ofs++);
}
}
}
}
static word next_pg[4] = { 0, 0, 0, 0 };
void set_pixel(byte x, byte y, byte color) {
word pg = (x>>1) * 8 + (y & 7) + (y & ~7)*32;
byte b = cvu_vinb(pg);
b |= (x & 1) ? color : color<<4;
cvu_voutb(b, PATTERN + pg);
}
void draw_line(sbyte x0, sbyte y0, sbyte x1, sbyte y1, byte color)
{
int dx, dy, p, x, y;
dx=x1-x0;
dy=y1-y0;
x=x0;
y=y0;
p=2*dy-dx;
while(x<x1)
{
if(p>=0)
{
set_pixel(x,y,color);
y=y+1;
p=p+2*dy-2*dx;
}
else
{
set_pixel(x,y,color);
p=p+2*dy;
}
x=x+1;
}
}
void main() {
setup_multicolor();
set_pixel(0, 0, 4);
set_pixel(1, 0, 4);
set_pixel(COLS-1, 0, 4);
set_pixel(0, 1, 6);
set_pixel(0, 2, 6);
set_pixel(0, 3, 6);
set_pixel(1, 4, 4);
set_pixel(2, 6, 5);
set_pixel(4, 7, 5);
set_pixel(7, 7, 5);
set_pixel(8, 8, 5);
draw_line(0, 0, COLS-1, ROWS-1, 2);
cv_set_screen_active(true);
while (1);
}

View File

@ -0,0 +1,83 @@
#include <stdlib.h>
#include <string.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++;
}
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);
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);
cv_set_vint_handler(&vint_handler);
while(1);
}

View File

@ -52,7 +52,7 @@ const char __at (0x5000) palette[32] = {/*{pal:332,n:4}*/
0x00,0xff,0x0f,0xf0,0x00,0x7f,0x0f,0xdf,
};
const char __at (0x4000) tilerom[0x1000] = {/*{w:8,h:8,bpp:1,np:2,pofs:2048,count:256}*/
const char __at (0x4000) tilerom[0x1000] = {/*{w:16,h:16,remap:[3,0,1,2,4,5,6,7,8,9,10],brev:1,np:2,pofs:2048,count:64}*/
0x00,0xfe,0x82,0x82,0x82,0xfe,0xfe,0x00,0x00,0x00,0xfe,0xfe,0xc0,0x00,0x00,0x00,0x00,0xf2,0xf2,0x92,0x92,0x9e,0x9e,0x00,0x00,0xfe,0xfe,0x92,0x92,0x82,0x00,0x00,0x08,0xfe,0xfe,0x88,0x88,0xf8,0xf8,0x00,0x00,0x9e,0x9e,0x92,0x92,0xf2,0xf2,0x00,0x00,0x9e,0x92,0x92,0x92,0xfe,0xfe,0x00,0x00,0xf0,0xf0,0x9e,0x9e,0x80,0x80,0x00,0x00,0xfe,0x92,0x92,0x92,0xfe,0xfe,0x00,0x00,0xfe,0x92,0x92,0x92,0xf2,0xf0,0x00,0x00,0xfe,0xc8,0x88,0x88,0xfe,0xfe,0x00,0x00,0xee,0x92,0x92,0x92,0xfe,0xfe,0x00,0x00,0x82,0x82,0x82,0x86,0xfe,0xfe,0x00,0x00,0xfc,0x86,0x82,0x82,0xfe,0xfe,0x00,0x00,0x82,0x92,0x92,0x92,0xfe,0xfe,0x00,0x00,0x80,0x90,0x90,0x90,0xfe,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xc8,0x88,0x88,0xfe,0xfe,0x00,0x00,0xee,0x92,0x92,0x92,0xfe,0xfe,0x00,0x00,0x82,0x82,0x82,0x86,0xfe,0xfe,0x00,0x00,0xfc,0x86,0x82,0x82,0xfe,0xfe,0x00,0x00,0x82,0x92,0x92,0x92,0xfe,0xfe,0x00,0x80,0x90,0x90,0x90,0x90,0xfe,0xfe,0x00,0x00,0x9e,0x92,0x82,0x82,0xfe,0xfe,0x00,0xfe,0xfe,0x10,0x10,0x10,0xfe,0xfe,0x00,0x00,0x00,0xbe,0xbe,0x00,0x00,0x00,0x00,0xfc,0xfe,0x06,0x02,0x02,0x02,0x00,0x00,0x00,0x82,0x44,0x28,0x18,0xfe,0xfe,0x00,0x02,0x02,0x02,0x06,0xfe,0xfe,0x00,0x00,0xfe,0x40,0x20,0x18,0x20,0xfe,0xfe,0x00,0xfe,0x0c,0x08,0x10,0x20,0xfe,0xfe,0x00,0xfe,0x82,0x82,0x82,0x86,0xfe,0xfe,0x00,
0x00,0xf8,0x88,0x88,0x88,0xfe,0xfe,0x00,0x7e,0x86,0x8a,0x82,0x82,0xfe,0xfe,0x00,0xf8,0x8a,0x8c,0x88,0x88,0xfe,0xfe,0x00,0x00,0x9e,0x96,0x92,0x92,0xf2,0xf2,0x00,0x80,0x80,0xfe,0xfe,0x80,0x80,0x00,0x00,0x00,0xfe,0x06,0x02,0x02,0xfe,0xfe,0x00,0xf0,0x08,0x04,0x06,0x0c,0xf8,0xf0,0x00,0xf8,0x06,0x0c,0x18,0x0c,0xfe,0xf8,0x00,0x82,0x44,0x28,0x38,0x6c,0xc6,0x82,0x00,0x80,0x40,0x30,0x1e,0x3e,0x40,0x80,0x00,0xc2,0xe2,0xb2,0x9e,0x8e,0x86,0x82,0x00,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x80,0x80,0x78,0x7e,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x78,0x80,0x80,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x28,0x07,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x80,0xe0,0xf0,0x07,0x07,0x28,0x10,0x00,0x00,0x00,0x00,0xe0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x04,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x80,0xe0,0xe0,0x07,0x27,0x18,0x00,0x00,0x00,0x00,0x00,0xf0,0xf8,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x04,0x02,0x03,0x07,0x27,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xe0,0x3f,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xf0,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x01,0x01,0x01,0x23,0x3f,0x07,0x00,0x00,0x00,0x00,0x80,0xc0,0xc0,0xe0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x13,0x1f,0x07,0x03,0x00,0x00,0x80,0x80,0x80,0xc0,0xe0,0xf0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xe0,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x09,0x0f,0x07,0x07,0x00,0x80,0x40,0x80,0x80,0xc0,0xc0,0xc0,0x03,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0xc0,0xc0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x08,0x04,0x03,0x03,0x03,0x00,0x00,0x10,0x08,0x10,0x60,0xe0,0xe0,0x03,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0xe0,0xc0,0xc0,0x80,0x00,0x00,0x00,0x00,

View File

@ -97,7 +97,7 @@ const char __at (0x5000) palette[32] = {/*{pal:332,n:4}*/
0x00,0xff,0x0f,0xf0,0x00,0x7f,0x0f,0xdf,
};
const char __at (0x4000) tilerom[0x1000] = {/*{w:8,h:8,bpp:1,np:2,pofs:2048,count:256}*/
const char __at (0x4000) tilerom[0x1000] = {/*{w:16,h:16,remap:[3,0,1,2,4,5,6,7,8,9,10],brev:1,np:2,pofs:2048,count:64}*/
0x00,0xfe,0x82,0x82,0x82,0xfe,0xfe,0x00,0x00,0x00,0xfe,0xfe,0xc0,0x00,0x00,0x00,0x00,0xf2,0xf2,0x92,0x92,0x9e,0x9e,0x00,0x00,0xfe,0xfe,0x92,0x92,0x82,0x00,0x00,0x08,0xfe,0xfe,0x88,0x88,0xf8,0xf8,0x00,0x00,0x9e,0x9e,0x92,0x92,0xf2,0xf2,0x00,0x00,0x9e,0x92,0x92,0x92,0xfe,0xfe,0x00,0x00,0xf0,0xf0,0x9e,0x9e,0x80,0x80,0x00,0x00,0xfe,0x92,0x92,0x92,0xfe,0xfe,0x00,0x00,0xfe,0x92,0x92,0x92,0xf2,0xf0,0x00,0x00,0xfe,0xc8,0x88,0x88,0xfe,0xfe,0x00,0x00,0xee,0x92,0x92,0x92,0xfe,0xfe,0x00,0x00,0x82,0x82,0x82,0x86,0xfe,0xfe,0x00,0x00,0xfc,0x86,0x82,0x82,0xfe,0xfe,0x00,0x00,0x82,0x92,0x92,0x92,0xfe,0xfe,0x00,0x00,0x80,0x90,0x90,0x90,0xfe,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0xc8,0x88,0x88,0xfe,0xfe,0x00,0x00,0xee,0x92,0x92,0x92,0xfe,0xfe,0x00,0x00,0x82,0x82,0x82,0x86,0xfe,0xfe,0x00,0x00,0xfc,0x86,0x82,0x82,0xfe,0xfe,0x00,0x00,0x82,0x92,0x92,0x92,0xfe,0xfe,0x00,0x80,0x90,0x90,0x90,0x90,0xfe,0xfe,0x00,0x00,0x9e,0x92,0x82,0x82,0xfe,0xfe,0x00,0xfe,0xfe,0x10,0x10,0x10,0xfe,0xfe,0x00,0x00,0x00,0xbe,0xbe,0x00,0x00,0x00,0x00,0xfc,0xfe,0x06,0x02,0x02,0x02,0x00,0x00,0x00,0x82,0x44,0x28,0x18,0xfe,0xfe,0x00,0x02,0x02,0x02,0x06,0xfe,0xfe,0x00,0x00,0xfe,0x40,0x20,0x18,0x20,0xfe,0xfe,0x00,0xfe,0x0c,0x08,0x10,0x20,0xfe,0xfe,0x00,0xfe,0x82,0x82,0x82,0x86,0xfe,0xfe,0x00,
0x00,0xf8,0x88,0x88,0x88,0xfe,0xfe,0x00,0x7e,0x86,0x8a,0x82,0x82,0xfe,0xfe,0x00,0xf8,0x8a,0x8c,0x88,0x88,0xfe,0xfe,0x00,0x00,0x9e,0x96,0x92,0x92,0xf2,0xf2,0x00,0x80,0x80,0xfe,0xfe,0x80,0x80,0x00,0x00,0x00,0xfe,0x06,0x02,0x02,0xfe,0xfe,0x00,0xf0,0x08,0x04,0x06,0x0c,0xf8,0xf0,0x00,0xf8,0x06,0x0c,0x18,0x0c,0xfe,0xf8,0x00,0x82,0x44,0x28,0x38,0x6c,0xc6,0x82,0x00,0x80,0x40,0x30,0x1e,0x3e,0x40,0x80,0x00,0xc2,0xe2,0xb2,0x9e,0x8e,0x86,0x82,0x00,0x00,0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x80,0x80,0x78,0x7e,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7e,0x78,0x80,0x80,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x28,0x07,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x80,0xe0,0xf0,0x07,0x07,0x28,0x10,0x00,0x00,0x00,0x00,0xe0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x04,0x03,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x80,0xe0,0xe0,0x07,0x27,0x18,0x00,0x00,0x00,0x00,0x00,0xf0,0xf8,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x04,0x02,0x03,0x07,0x27,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xe0,0x3f,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xf0,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x01,0x01,0x01,0x23,0x3f,0x07,0x00,0x00,0x00,0x00,0x80,0xc0,0xc0,0xe0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x13,0x1f,0x07,0x03,0x00,0x00,0x80,0x80,0x80,0xc0,0xe0,0xf0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xe0,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x09,0x0f,0x07,0x07,0x00,0x80,0x40,0x80,0x80,0xc0,0xc0,0xc0,0x03,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0xc0,0xc0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x08,0x04,0x03,0x03,0x03,0x00,0x00,0x10,0x08,0x10,0x60,0xe0,0xe0,0x03,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0xe0,0xc0,0xc0,0x80,0x00,0x00,0x00,0x00,

View File

@ -1,7 +1,6 @@
#include <string.h>
#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
typedef unsigned char byte;
typedef unsigned short word;
@ -35,6 +34,7 @@ byte __at (0x8980) watchdog;
//
void main();
void __sdcc_heap_init(void); // for malloc()
void start() {
__asm
@ -48,6 +48,7 @@ __asm
LDIR
__endasm;
// init heap for malloc() and run main pgm.
__sdcc_heap_init();
main();
}
@ -360,15 +361,6 @@ void draw_wireframe_ortho(const Wireframe* wf, const Matrix* m) {
} while (1);
}
static word lfsr = 1;
word rand() {
byte lsb = lfsr & 1;
lfsr >>= 1;
if (lsb) lfsr ^= 0xd400;
return lfsr;
}
// SHAPE CACHE
const Vector8 tetra_v[] = { {0,-86,86},{86,86,86},{-86,86,86},{0,0,-86} };
@ -527,10 +519,6 @@ void draw_actor_rect(Actor* a) {
VCTR(0,-86*2,2);
}
inline byte abs(sbyte x) {
return (x>=0) ? x : -x;
}
inline word get_distance_squared(byte dx, byte dy) {
mathbox_sum = 0;
mul16(dx,dx);

View File

@ -1,6 +1,5 @@
#include <string.h>
#include <malloc.h>
typedef unsigned char byte;
typedef unsigned short word;
@ -34,7 +33,6 @@ byte __at (0x8980) watchdog;
//
void main();
void _sdcc_heap_init(void); // for malloc()
void start() {
__asm
@ -47,8 +45,6 @@ __asm
LD HL, #s__INITIALIZER
LDIR
__endasm;
// init heap for malloc() and run main pgm.
_sdcc_heap_init();
main();
}

View File

@ -1,3 +1,4 @@
#include <string.h>
typedef unsigned char byte;

View File

@ -199,23 +199,39 @@ function replaceHexBytes(s, bytes) {
return result;
}
function remapBits(x, arr) {
if (!arr) return x;
var y = 0;
for (var i=0; i<arr.length; i++) {
var s = arr[i];
if (s < 0) {
s = -s-1;
y ^= 1 << s;
}
if (x & (1 << i)) {
y ^= 1 << s;
}
}
return y;
}
function convertBytesToImages(bytes, fmt) {
var count = fmt.count ? fmt.count : 1;
var width = fmt.w;
var height = fmt.h;
var bpp = fmt.bpp ? fmt.bpp : 1;
var bytesperline = fmt.sl ? fmt.sl : Math.ceil(width * bpp / 8);
//console.log(width,height,bytesperline);
var count = fmt.count || 1;
var bpp = fmt.bpp || 1;
var nplanes = fmt.np || 1;
var bytesperline = fmt.sl || Math.ceil(width * bpp / 8);
var mask = (1 << bpp)-1;
var images = [];
var nplanes = fmt.np ? fmt.np : 1;
for (var n=0; n<count; n++) {
var imgdata = [];
for (var y=0; y<height; y++) {
var ofs = n*bytesperline*height + y*bytesperline;
var ofs0 = n*bytesperline*height + y*bytesperline;
var shift = 0;
for (var x=0; x<width; x++) {
var color = 0;
var ofs = remapBits(ofs0, fmt.remap);
for (var p=0; p<nplanes; p++) {
var byte = bytes[ofs + p*(fmt.pofs|0)];
color |= ((fmt.brev ? byte>>(8-shift-bpp) : byte>>shift) & mask) << (p*bpp);
@ -223,7 +239,7 @@ function convertBytesToImages(bytes, fmt) {
imgdata.push(color);
shift += bpp;
if (shift >= 8) {
ofs += 1;
ofs0 += 1;
shift = 0;
}
}
@ -234,29 +250,30 @@ function convertBytesToImages(bytes, fmt) {
}
function convertImagesToBytes(images, fmt) {
var count = fmt.count ? fmt.count : 1;
var width = fmt.w;
var height = fmt.h;
var bpp = fmt.bpp ? fmt.bpp : 1;
var bytesperline = fmt.sl ? fmt.sl : Math.ceil(fmt.w * bpp / 8);
var count = fmt.count || 1;
var bpp = fmt.bpp || 1;
var nplanes = fmt.np || 1;
var bytesperline = fmt.sl || Math.ceil(fmt.w * bpp / 8);
var mask = (1 << bpp)-1;
var nplanes = fmt.np ? fmt.np : 1;
var bytes = new Uint8Array(bytesperline * height * nplanes * count);
for (var n=0; n<count; n++) {
var imgdata = images[n];
var i = 0;
for (var y=0; y<height; y++) {
var ofs = n*bytesperline*height + y*bytesperline;
var ofs0 = n*bytesperline*height + y*bytesperline;
var shift = 0;
for (var x=0; x<width; x++) {
var color = imgdata[i++];
var ofs = remapBits(ofs0, fmt.remap);
for (var p=0; p<nplanes; p++) {
var c = (color >> (p*bpp)) & mask;
bytes[ofs + p*(fmt.pofs|0)] |= (fmt.brev ? (c << (8-shift-bpp)) : (c << shift));
}
shift += bpp;
if (shift >= 8) {
ofs += 1;
ofs0 += 1;
shift = 0;
}
}

View File

@ -9,6 +9,7 @@
// http://bifi.msxnet.org/msxnet//tech/tms9918a.txt
// http://www.colecovision.dk/tools.htm?refreshed
// http://www.theadamresource.com/manuals/technical/ColecoVision%20Coding%20Guide.pdf
// http://www.unige.ch/medecine/nouspikel/ti99/tms9918a.htm
var ColecoVision_PRESETS = [
{id:'text.c', name:'Text Mode'},

View File

@ -145,16 +145,20 @@ describe('Worker', function() {
});
it('should compile vector skeleton', function(done) {
var csource = ab2str(fs.readFileSync('presets/vector-z80color/skeleton.sdcc'));
compile('sdcc', csource, 'vector-z80color', done, 32768, 24, 0);
compile('sdcc', csource, 'vector-z80color', done, 32768, 23, 0);
});
it('should compile williams skeleton', function(done) {
var csource = ab2str(fs.readFileSync('presets/williams-z80/skeleton.sdcc'));
compile('sdcc', csource, 'williams-z80', done, 38912, 39, 0);
compile('sdcc', csource, 'williams-z80', done, 38912, 38, 0);
});
it('should compile williams_sound skeleton', function(done) {
var csource = ab2str(fs.readFileSync('presets/sound_williams-z80/skeleton.sdcc'));
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);
});
it('should NOT compile SDCC', function(done) {
compile('sdcc', 'foobar', 'mw8080bw', done, 0, 0, 1);
});