made MSX-friendly presets

This commit is contained in:
Steven Hugg 2019-08-19 10:24:22 -04:00
parent b6baab7a5c
commit 0eb1d2eec0
18 changed files with 115 additions and 103 deletions

View File

@ -40,14 +40,15 @@ TODO:
- update bootstrap to 4.0
- batariBasic: proper line numbers, debugging
- granular control over time scrubbing, show CPU state
- compiler flags for final ROM build
- workermain: split build functions, better msg types
- builds:
- compiler flags for final ROM build
- workermain: split build functions, better msg types
- what if >1 file with same name? (local/nonlocal/directory)
- what if .c and .s names collide?
- maybe put stuff in examples/ dir?
- error msg when #link doesn't work
- warning when ROM too big
- detect "libcv.h" and include library automagically?
- sdcc:
- can't link asm files before c files (e.g. acheader.s must be last)
- figure out area names ordering

View File

@ -107,7 +107,7 @@ if (window.location.host.endsWith('8bitworkshop.com')) {
<li class="dropdown dropdown-submenu">
<a tabindex="-1" href="#">Tools</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" target="_8bws_tools" href="./tools/fontgen/">Bitmap Font Generator</a></li>
<li><a class="dropdown-item" target="_8bws_tools" href="//8bitworkshop.com/bitmapfontgenerator/">Bitmap Font Generator</a></li>
<li><a class="dropdown-item" target="_8bws_tools" href="http://tomeko.net/online_tools/file_to_hex.php?lang=en">Binary File to Hex Converter</a></li>
<li class="dropdown dropdown-submenu">
<a tabindex="-1" href="#">Atari 2600/VCS</a>

View File

@ -6,6 +6,8 @@
#include "common.h"
//#link "common.c"
// for SMS
//#link "fonts.s"
#define XOFS 12 // sprite horiz. offset

View File

@ -34,17 +34,17 @@ word getimageaddr(byte x, byte y) {
return IMAGE + y*COLS + x;
}
byte getchar(byte x, byte y) {
byte getcharxy(byte x, byte y) {
return cvu_vinb(getimageaddr(x,y));
}
void putchar(byte x, byte y, byte attr) {
void putcharxy(byte x, byte y, byte attr) {
cvu_voutb(attr, getimageaddr(x,y));
}
void putstring(byte x, byte y, const char* string) {
void putstringxy(byte x, byte y, const char* string) {
while (*string) {
putchar(x++, y, CHAR(*string++));
putcharxy(x++, y, CHAR(*string++));
}
}
@ -73,7 +73,7 @@ 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)));
putcharxy(x, y, CHAR('0'+(bcd&0xf)));
x--;
bcd >>= 4;
}
@ -123,3 +123,13 @@ void set_shifted_pattern(const byte* src, word dest, byte shift) {
dest++;
}
}
void copy_default_character_set() {
#ifdef CV_MSX
static byte __at(0xf91f) CGPNT;
static byte* __at(0xf920) CGADDR;
cvu_memtovmemcpy(PATTERN, CGADDR, 256*8);
#else
cvu_memtovmemcpy(PATTERN, (void *)(font_bitmap_0 - '0'*8), 256*8);
#endif
}

View File

@ -16,17 +16,24 @@
#define SPRITE_PATTERNS ((const cv_vmemp)0x3800)
#define SPRITES ((const cv_vmemp)0x3c00)
#ifndef COLS
#define COLS 32
#endif
#ifndef ROWS
#define ROWS 24
#endif
typedef unsigned char byte;
typedef signed char sbyte;
typedef unsigned short word;
#ifndef CV_SMS
#ifdef CV_CV
uintptr_t __at(0x6a) font_bitmap_a;
uintptr_t __at(0x6c) font_bitmap_0;
#else
#endif
#ifdef CV_SMS
extern char font_bitmap_a[];
extern char font_bitmap_0[];
#endif
@ -34,8 +41,9 @@ extern char font_bitmap_0[];
#define COLOR_FGBG(fg,bg) (((fg)<<4)|(bg))
#define COLOR_FG(fg) (((fg)<<4))
#define LOCHAR 0x20
#define HICHAR 0xff
#ifndef LOCHAR
#define LOCHAR 0x0
#endif
#define CHAR(ch) (ch-LOCHAR)
@ -53,9 +61,9 @@ extern char cursor_y;
extern void clrscr();
extern word getimageaddr(byte x, byte y);
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 byte getcharxy(byte x, byte y);
extern void putcharxy(byte x, byte y, byte attr);
extern void putstringxy(byte x, byte y, const char* string);
extern void delay(byte i);
extern byte rndint(byte a, byte b);
@ -69,4 +77,6 @@ extern word bcd_add(word a, word b);
extern void vdp_setup();
extern void set_shifted_pattern(const byte* src, word dest, byte shift);
extern void copy_default_character_set();
#endif

View File

@ -5,18 +5,15 @@
#include <cv.h>
#include <cvu.h>
#define IMAGE ((const cv_vmemp)0x1c00)
#define COLS 40
#define ROWS 24
uintptr_t __at(0x6a) font_bitmap_a;
uintptr_t __at(0x6c) font_bitmap_0;
#include "common.h"
//#link "common.c"
void setup_40_column_font() {
cv_set_image_table(IMAGE);
cvu_memtovmemcpy(0x1800, (void *)(font_bitmap_0 - 0x30*8), 2048);
cv_set_character_pattern_t(0x1800);
copy_default_character_set();
cv_set_character_pattern_t(PATTERN);
cv_set_screen_mode(CV_SCREENMODE_TEXT);
}

View File

@ -5,16 +5,7 @@
#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;
#include "common.h"
void setup_mode2() {
cvu_vmemset(0, 0, 0x4000);

View File

@ -1,14 +1,11 @@

#include <stdlib.h>
#include <cv.h>
#include <cvu.h>
#define PATTERN 0x0000 // $0000 - $17ff
#define IMAGE 0x1800 // $1800 - $1aff
#define SPRITES 0x1b00 // not used
#define COLOR 0x2000 // $2000 - $37ff
#include "common.h"
/* link in MODE 2 bitmap data */

View File

@ -5,10 +5,7 @@
#include <cv.h>
#include <cvu.h>
#define PATTERN 0x0000 // $0000 - $17ff
#define IMAGE 0x1800 // $1800 - $1aff
#define SPRITES 0x1b00 // not used
#define COLOR 0x2000 // $2000 - $37ff
#include "common.h"
/* link in MODE 2 bitmap data */

View File

@ -1,17 +1,12 @@

/*
64x48 multicolor mode
*/
#include <stdlib.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;
#include "common.h"
void multicolor_fullscreen_image_table(word ofs) {
byte x,y;

View File

@ -1,4 +1,4 @@

#include <stdlib.h>
#include <string.h>
#include <cv.h>
@ -10,9 +10,8 @@
#include "stars.h"
//#link "stars.c"
#ifdef CV_SMS
// for SMS
//#link "fonts.s"
#endif
#define NSPRITES 16
#define NMISSILES 8
@ -178,8 +177,8 @@ void copy_sprites() {
void add_score(word bcd) {
player_score = bcd_add(player_score, bcd);
draw_bcd_word(0, 1, player_score);
putchar(4, 1, CHAR('0'));
draw_bcd_word(0, 0, player_score);
putcharxy(4, 0, CHAR('0'));
}
void clrobjs() {
@ -593,7 +592,7 @@ void play_round() {
byte end_timer = 255;
player_score = 0;
add_score(0);
putstring(0, 0, "PLAYER 1");
//putstringxy(0, 0, "PLAYER 1");
setup_formation();
clrobjs();
formation_direction = 1;
@ -640,7 +639,7 @@ PATTERN TABLE:
void setup_graphics() {
byte i;
cvu_memtovmemcpy(PATTERN, (void *)(font_bitmap_0 - 16*8), 96*8);
copy_default_character_set();
cvu_memtovmemcpy(SPRITE_PATTERNS, sprite_table, sizeof(sprite_table));
cvu_vmemset(COLOR, COLOR_SCORE<<4, 8); // set color for chars 0-63
cvu_vmemset(COLOR+8, COLOR_FORMATION<<4, 32-8); // set chars 63-255

View File

@ -7,9 +7,8 @@
#include "common.h"
//#link "common.c"
#ifdef CV_SMS
// for SMS
//#link "fonts.s"
#endif
////////// GAME DATA
@ -41,26 +40,26 @@ const char BOX_CHARS[8] = {
void draw_box(byte x, byte y, byte x2, byte y2, const char* chars) {
byte x1 = x;
putchar(x, y, chars[2]);
putchar(x2, y, chars[3]);
putchar(x, y2, chars[0]);
putchar(x2, y2, chars[1]);
putcharxy(x, y, chars[2]);
putcharxy(x2, y, chars[3]);
putcharxy(x, y2, chars[0]);
putcharxy(x2, y2, chars[1]);
while (++x < x2) {
putchar(x, y, chars[5]);
putchar(x, y2, chars[4]);
putcharxy(x, y, chars[5]);
putcharxy(x, y2, chars[4]);
}
while (++y < y2) {
putchar(x1, y, chars[6]);
putchar(x2, y, chars[7]);
putcharxy(x1, y, chars[6]);
putcharxy(x2, y, chars[7]);
}
}
void draw_playfield() {
draw_box(0,1,COLS-1,ROWS-1,BOX_CHARS);
putstring(0,0,"Plyr1:");
putstring(20,0,"Plyr2:");
putchar(7,0,CHAR(players[0].score+'0'));
putchar(27,0,CHAR(players[1].score+'0'));
putstringxy(0,0,"Plyr1:");
putstringxy(20,0,"Plyr2:");
putcharxy(7,0,CHAR(players[0].score+'0'));
putcharxy(27,0,CHAR(players[1].score+'0'));
}
typedef enum { D_RIGHT, D_DOWN, D_LEFT, D_UP } dir_t;
@ -86,14 +85,14 @@ void reset_players() {
}
void draw_player(Player* p) {
putchar(p->x, p->y, p->head_attr);
putcharxy(p->x, p->y, p->head_attr);
}
void move_player(Player* p) {
putchar(p->x, p->y, p->tail_attr);
putcharxy(p->x, p->y, p->tail_attr);
p->x += DIR_X[p->dir];
p->y += DIR_Y[p->dir];
if (getchar(p->x, p->y) != CHAR(' '))
if (getcharxy(p->x, p->y) != CHAR(' '))
p->collided = 1;
draw_player(p);
}
@ -118,7 +117,7 @@ byte ai_try_dir(Player* p, dir_t dir, byte shift) {
dir &= 3;
x = p->x + (DIR_X[dir] << shift);
y = p->y + (DIR_Y[dir] << shift);
if (x < 29 && y < 27 && getchar(x, y) == CHAR(' ')) {
if (x < 29 && y < 27 && getcharxy(x, y) == CHAR(' ')) {
p->dir = dir;
return 1;
} else {
@ -179,9 +178,9 @@ void declare_winner(byte winner) {
draw_box(i,i,COLS-1-i,ROWS-1-i,BOX_CHARS);
delay(1);
}
putstring(12,10,"WINNER:");
putstring(12,13,"PLAYER ");
putchar(12+7, 13, CHAR('1')+winner);
putstringxy(12,10,"WINNER:");
putstringxy(12,13,"PLAYER ");
putcharxy(12+7, 13, CHAR('1')+winner);
delay(75);
gameover = 1;
}
@ -219,8 +218,8 @@ void play_game() {
}
void setup_32_column_font() {
copy_default_character_set();
cv_set_colors(0, CV_COLOR_BLUE);
cvu_memtovmemcpy(PATTERN, (void *)(font_bitmap_0 - 16*8), 96*8);
cvu_vmemset(COLOR, COLOR_FG(CV_COLOR_YELLOW), 8); // set color for chars 0-63
cvu_vmemset(COLOR+8, COLOR_FG(CV_COLOR_WHITE), 32-8); // set chars 63-255
}

View File

@ -18,9 +18,11 @@ byte starfield_get_tile_xy(byte x, byte y) {
}
void starfield_setup() {
// clear star patterns
cvu_vmemset(PATTERN+starfield_base_char*8, 0, 16*8);
for (byte x=0; x<32; x++) {
for (byte y=0; y<28; y++) {
putchar(x, y, starfield_get_tile_xy(x, y));
putcharxy(x, y, starfield_get_tile_xy(x, y));
}
cvu_voutb(COLOR_FG(CV_COLOR_WHITE),
COLOR+((starfield_base_char+x)>>3));

View File

@ -2,18 +2,15 @@
#include <cv.h>
#include <cvu.h>
#define PATTERN 0x0000
#define IMAGE 0x0800
uintptr_t __at(0x6a) font_bitmap_a;
uintptr_t __at(0x6c) font_bitmap_0;
#include "common.h"
//#link "common.c"
void setup_text_mode() {
cv_set_screen_mode(CV_SCREENMODE_TEXT);
cv_set_image_table(IMAGE);
cv_set_character_pattern_t(PATTERN);
cvu_vmemset(0, 0, 0x4000);
cvu_memtovmemcpy(PATTERN, (void *)(font_bitmap_0 - '0'*8), 256*8);
copy_default_character_set();
}
void show_text() {

View File

@ -2,14 +2,8 @@
#include <cv.h>
#include <cvu.h>
#define PATTERN 0x0000 // 256*8 = 2048 bytes
#define IMAGE 0x0800 // 32*24 = 768 bytes
#define COLOR 0x0b00 // 32 bytes
#define SPRITE_PATTERNS 0x3800 // 32*32 = 1024 bytes
#define SPRITES 0x3c00 // 4*32 = 128 bytes
uintptr_t __at(0x6a) font_bitmap_a;
uintptr_t __at(0x6c) font_bitmap_0;
#include "common.h"
//#link "common.c"
void setup_32_column_font() {
cv_set_screen_mode(CV_SCREENMODE_STANDARD);
@ -19,7 +13,7 @@ void setup_32_column_font() {
cv_set_sprite_pattern_table(SPRITE_PATTERNS);
cv_set_sprite_attribute_table(SPRITES);
cvu_vmemset(0, 0, 0x4000);
cvu_memtovmemcpy(PATTERN, (void *)(font_bitmap_0 - '0'*8), 2048);
copy_default_character_set();
cvu_vmemset(COLOR, 0x36, 8); // set color for chars 0-63
cvu_vmemset(COLOR+8, 0x06, 32-8); // set chars 63-255
}
@ -35,6 +29,6 @@ void main() {
setup_32_column_font();
show_text();
while (1) {
cvu_vmemset(COLOR, i++, 8); // set color for chars 0-63
cvu_vmemset(COLOR+8, i++, 4); // set color for chars 64-95
}
}

View File

@ -13,13 +13,31 @@ import { TMS9918A } from "../video/tms9918a";
// https://www.msx.org/wiki/Slots
// https://www.msx.org/wiki/SDCC
var MSX_PRESETS = [
var MSX_BIOS_PRESETS = [
{id:'helloworld.asm', name:'Hello World (ASM)'},
{id:'redbook_kbd.asm', name:'Redbook Keyboard Scanner (ASM)'},
{id:'siegegame.c', name:'Siege Game'},
{id:'eliza.c', name:'Eliza'},
];
// TODO: share with coleco, sms
var LIBCV_PRESETS = [
{ id: 'text.c', name: 'Text Mode' },
{ id: 'hello.c', name: 'Scrolling Text' },
{ id: 'text32.c', name: '32-Column Color Text' },
{ id: 'stars.c', name: 'Scrolling Starfield' },
{ id: 'cursorsmooth.c', name: 'Moving Cursor' },
{ id: 'simplemusic.c', name: 'Simple Music' },
{ id: 'musicplayer.c', name: 'Multivoice Music' },
{ id: 'mode2bitmap.c', name: 'Mode 2 Bitmap' },
{ id: 'mode2compressed.c', name: 'Mode 2 Bitmap (LZG)' },
{ id: 'lines.c', name: 'Mode 2 Lines' },
{ id: 'multicolor.c', name: 'Multicolor Mode' },
{ id: 'siegegame.c', name: 'Siege Game' },
{ id: 'shoot.c', name: 'Solarian Game' },
{ id: 'climber.c', name: 'Platform Game' },
];
var MSX_KEYCODE_MAP = makeKeycodeMap([
[Keys.UP, 0, 0x1],
[Keys.DOWN, 0, 0x2],
@ -78,7 +96,7 @@ class MSXPlatform extends BasicZ80ScanlinePlatform implements Platform {
slotmask : number = 0;
ppi_c : number = 0;
getPresets() { return MSX_PRESETS; }
getPresets() { return MSX_BIOS_PRESETS; }
getKeyboardMap() { return MSX_KEYCODE_MAP; }
@ -276,8 +294,12 @@ class MSXPlatform extends BasicZ80ScanlinePlatform implements Platform {
///
class MSXLibCVPlatform extends MSXPlatform implements Platform {
getPresets() { return LIBCV_PRESETS; }
}
PLATFORMS['msx'] = MSXPlatform;
PLATFORMS['msx-libcv'] = MSXPlatform;
PLATFORMS['msx-libcv'] = MSXLibCVPlatform;
///

View File

@ -323,7 +323,6 @@ var PLATFORM_PARAMS = {
},
};
PLATFORM_PARAMS['coleco.mame'] = PLATFORM_PARAMS['coleco'];
PLATFORM_PARAMS['sms-sms-libcv'] = PLATFORM_PARAMS['sms-sg1000-libcv'];
var _t1;

View File

@ -78,7 +78,7 @@ function doBuild(msgs, callback, outlen, nlines, nerrors, options) {
describe('Worker', function() {
it('should assemble DASM', function(done) {
compile('dasm', '\tprocessor 6502\n\torg $f000\nfoo lda #0\n', 'vcs', done, 2, 1);
compile('dasm', '\tprocessor 6502\n\torg $f000\nfoo lda #0\n', 'vcs.mame', done, 2, 1);
});
it('should NOT assemble DASM', function(done) {
compile('dasm', '\tprocessor 6502\n\torg $f000 ; this is a comment\nfoo asl a\n', 'vcs', done, 0, 0, 1);
@ -98,7 +98,7 @@ describe('Worker', function() {
});
*/
it('should compile CC65', function(done) {
compile('cc65', 'int main() {\nint x=1;\nreturn x+2;\n}', 'nes', done, 40976, 3);
compile('cc65', 'int main() {\nint x=1;\nreturn x+2;\n}', 'nes.mame', done, 40976, 3);
});
it('should NOT compile CC65 (compile error)', function(done) {
compile('cc65', 'int main() {\nint x=1;\nprintf("%d",x);\nreturn x+2;\n}', 'nes', done, 0, 0, 1);