fixed some cc65 stuff, wiz too

This commit is contained in:
Steven Hugg 2022-01-24 18:51:39 -06:00
parent 5a39828bf5
commit 73389b1d1d
8 changed files with 60 additions and 117 deletions

View File

@ -1,4 +1,9 @@
// reserve space for the HGR1 screen buffer
#define CFGFILE apple2-hgr.cfg
#pragma data-name(push,"HGR")
#pragma data-name(pop)
/*
* An Apple ][ port of the Cosmic Impalas game
* described in the book

View File

@ -1,3 +1,9 @@
// reserve space for the HGR1 screen buffer
#define CFGFILE apple2-hgr.cfg
#pragma data-name(push,"HGR")
#pragma data-name(pop)
/*
Test of the LZG decompression library
with a hires graphics image.
@ -38,7 +44,7 @@ void clrscr() {
int main (void)
{
clrscr();
lzg_decode_vram(BITMAP_DATA_LZG, (char*)0x2000, (char*)0x4000);
lzg_decode_vram(BITMAP_DATA_LZG, (unsigned char*)0x2000, (unsigned char*)0x4000);
printf("\nHello! Press a key to reboot...\n");
cgetc();
return EXIT_SUCCESS;

View File

@ -32,6 +32,7 @@
/* Workaround missing clock stuff */
#ifdef __APPLE2__
# define clock() 0
# undef CLK_TCK
# define CLK_TCK 1
#endif

View File

@ -143,7 +143,7 @@ static void DoDiagram (void)
/* Calculate the next points */
X = (int) (((long) (MaxX - 19) * I) / 360);
Y = (int) (((long) Amp * -cc65_sin (I)) / 256);
Y = (int) (((long) Amp * -_sin (I)) / 256);
/* Draw the line */
tgi_lineto (XOrigin + X, YOrigin + Y);

View File

@ -664,7 +664,7 @@ bool check_collision(Actor* a) {
///
void draw_blimp(struct cvu_sprite* sprite) {
void draw_blimp() {
/*
sprite->name = 48;
wait_vblank();
@ -680,7 +680,6 @@ void draw_blimp(struct cvu_sprite* sprite) {
cvu_set_sprite(SPRITES, 31, sprite);
refresh_actors();
*/
sprite=sprite;
}
void blimp_pickup_scene() {

View File

@ -1,23 +1,12 @@
import "msx";
bank rom1 @ 0x4000 : [constdata; 0x4000];
bank rom2 @ 0x8000 : [constdata; 0x4000];
bank rom @ 0x4000 : [constdata; 0x4000];
bank ram @ 0xE000 : [vardata; 0x2000];
in ram {
struct Word {
low : u8,
high : u8,
}
in ram {}
struct Enemy {
hp : Word
}
var enemy_data : [Enemy; 32];
}
in rom1 {
in rom {
// FIXME: add support for MSX ROM header format directly in Wiz.
namespace header {
const id = "AB";
const init_handler = main;
@ -30,93 +19,41 @@ in rom1 {
#[fallthrough] func main() {
interrupt = false;
io_write(msx.io.ppi.primary_slot, a = 0b11_01_01_00);
msx.ppi.secondary_slot = a = 0b11_11_11_11;
// Set border color.
msx.bios.border_color = a = msx.vdp.color.BLACK;
msx.bios.vdp_apply_colors();
// Init VDP.
c = msx.io.vdp.control;
hl = &vdp_init_data as u16;
b = vdp_init_data.len;
do { io_write_inc_repeat(c, hl, b); } while !zero;
{
var enemy_ptr : *Enemy in ix;
enemy_ptr.hp.low = 1;
enemy_ptr.hp.high = 1;
bc = sizeof(Enemy);
<>:enemy_ptr += bc;
}
// Clear VRAM.
io_write(msx.io.vdp.control, a = <:0x0000);
io_write(msx.io.vdp.control, a = >:0x0000 | msx.io.vdp.CONTROL_ACCESS_VRAM_WRITE);
bc = 0x4000;
do {
io_write(msx.io.vdp.data, a = 0);
bc--;
a = b | c;
} while !zero;
// Load background colormap.
io_write(msx.io.vdp.control, a = <:0x2000);
io_write(msx.io.vdp.control, a = >:0x2000 | msx.io.vdp.CONTROL_ACCESS_VRAM_WRITE);
bc = 0x1800;
do {
io_write(msx.io.vdp.data, a = (msx.vdp.color.WHITE << 4) | msx.vdp.color.LIGHT_BLUE);
bc--;
a = b | c;
} while !zero;
// Load background tileset.
io_write(msx.io.vdp.control, a = <:0x0000);
io_write(msx.io.vdp.control, a = >:0x0000 | msx.io.vdp.CONTROL_ACCESS_VRAM_WRITE);
hl = &bkg_tileset as u16;
bc = sizeof(typeof(bkg_tileset));
do {
io_write(msx.io.vdp.data, a = *(hl as *u8));
hl++;
bc--;
a = b | c;
} while !zero;
io_write(msx.io.vdp.control, a = <:0x0800);
io_write(msx.io.vdp.control, a = >:0x0800 | msx.io.vdp.CONTROL_ACCESS_VRAM_WRITE);
hl = &bkg_tileset as u16;
bc = sizeof(typeof(bkg_tileset));
do {
io_write(msx.io.vdp.data, a = *(hl as *u8));
hl++;
bc--;
a = b | c;
} while !zero;
io_write(msx.io.vdp.control, a = <:0x1000);
io_write(msx.io.vdp.control, a = >:0x1000 | msx.io.vdp.CONTROL_ACCESS_VRAM_WRITE);
hl = &bkg_tileset as u16;
bc = sizeof(typeof(bkg_tileset));
do {
io_write(msx.io.vdp.data, a = *(hl as *u8));
hl++;
bc--;
a = b | c;
} while !zero;
// Init screen mode.
load_inc_repeat(
de = <>:&msx.bios.screen_2_nametable,
hl = <>:&screen_init_data,
bc = sizeof(typeof(screen_init_data)));
msx.bios.init_screen_2(
msx.bios.screen_2_nametable,
msx.bios.screen_2_tile_color_table,
msx.bios.screen_2_tile_pattern_table,
msx.bios.screen_2_sprite_attribute_table,
msx.bios.screen_2_sprite_pattern_table
);
// Disable the screen so we can access VRAM. (Initializing the screen mode also enables the screen).
msx.bios.disable_screen();
// Load tileset colors.
let COLOR_ATTRIBUTE = (msx.vdp.color.WHITE << 4) | msx.vdp.color.LIGHT_BLUE;
msx.bios.vdp_vram_fill_block(msx.vdp.screen2.TILESET_COLOR_RAM_ADDRESS, COLOR_ATTRIBUTE, msx.vdp.screen2.TILESET_COLOR_RAM_SIZE);
// Load tileset patterns.
msx.bios.vdp_vram_write_block(msx.vdp.screen2.TILESET_PATTERN_BANK_TOP_ADDRESS, &bkg_tileset[0], sizeof(typeof(bkg_tileset)));
msx.bios.vdp_vram_write_block(msx.vdp.screen2.TILESET_PATTERN_BANK_MIDDLE_ADDRESS, &bkg_tileset[0], sizeof(typeof(bkg_tileset)));
msx.bios.vdp_vram_write_block(msx.vdp.screen2.TILESET_PATTERN_BANK_BOTTOM_ADDRESS, &bkg_tileset[0], sizeof(typeof(bkg_tileset)));
// Clear nametable.
msx.bios.vdp_vram_fill_block(msx.vdp.screen2.NAMETABLE_ADDRESS, 0, msx.vdp.screen2.NAMETABLE_SIZE);
// Write text to nametable.
io_write(msx.io.vdp.control, a = <:0x190A);
io_write(msx.io.vdp.control, a = >:0x190A | msx.io.vdp.CONTROL_ACCESS_VRAM_WRITE);
hl = &message as u16;
bc = message.len;
do {
io_write(msx.io.vdp.data, a = *(hl as *u8));
hl++;
bc--;
a = b | c;
} while !zero;
// Turn screen on
io_write(msx.io.vdp.control, a = msx.vdp.MODE_CONTROL_1_ENABLE);
io_write(msx.io.vdp.control, a = msx.vdp.mode_control_1 | msx.io.vdp.CONTROL_ACCESS_REGISTER);
let START_OFFSET_Y = 8;
let START_OFFSET_X = 10;
let MESSAGE_DEST_ADDRESS = msx.vdp.screen2.NAMETABLE_ADDRESS + START_OFFSET_Y * 32 + START_OFFSET_X;
msx.bios.vdp_vram_write_block(MESSAGE_DEST_ADDRESS, &message[0], sizeof(typeof(message)));
// Turn screen on.
msx.bios.enable_screen();
interrupt = true;
@ -125,20 +62,14 @@ in rom1 {
}
}
const vdp_init_data : [u8] = [
msx.vdp.MODE_CONTROL_0_M4, msx.vdp.mode_control_0 | msx.io.vdp.CONTROL_ACCESS_REGISTER,
0, msx.vdp.mode_control_1 | msx.io.vdp.CONTROL_ACCESS_REGISTER,
0x1800 >> msx.vdp.NAMETABLE_ADDRESS_SHIFT, msx.vdp.nametable_address | msx.io.vdp.CONTROL_ACCESS_REGISTER,
0x2000 >> msx.vdp.COLORTABLE_ADDRESS_SHIFT, msx.vdp.colortable_address | msx.io.vdp.CONTROL_ACCESS_REGISTER,
0x0000 >> msx.vdp.TILE_PATTERN_ADDRESS_SHIFT, msx.vdp.tile_pattern_address | msx.io.vdp.CONTROL_ACCESS_REGISTER,
0x1B00 >> msx.vdp.SPRITE_ATTRIBUTE_ADDRESS_SHIFT, msx.vdp.sprite_attribute_address | msx.io.vdp.CONTROL_ACCESS_REGISTER,
0x3800 >> msx.vdp.SPRITE_PATTERN_ADDRESS_SHIFT, msx.vdp.sprite_pattern_address | msx.io.vdp.CONTROL_ACCESS_REGISTER,
msx.vdp.color.BLACK, msx.vdp.overscan_color | msx.io.vdp.CONTROL_ACCESS_REGISTER,
const screen_init_data : [u16] = [
msx.vdp.screen2.NAMETABLE_ADDRESS,
msx.vdp.screen2.TILESET_COLOR_RAM_ADDRESS,
msx.vdp.screen2.TILESET_PATTERN_RAM_ADDRESS,
msx.vdp.screen2.SPRITE_ATTRIBUTE_ADDRESS,
msx.vdp.screen2.SPRITE_PATTERN_ADDRESS,
];
const message = "HELLO WORLD";
}
in rom2 {
const bkg_tileset = embed "hello_tiles.chr";
}

View File

@ -243,7 +243,7 @@ export function compileCC65(step: BuildStep): BuildStepResult {
loadNative("cc65");
var params = step.params;
// stderr
var re_err1 = /(.*?)[(](\d+)[)].*?: (.+)/;
var re_err1 = /(.*?):(\d+): (.+)/;
var errors: WorkerError[] = [];
var errline = 0;
function match_fn(s) {
@ -283,7 +283,7 @@ export function compileCC65(step: BuildStep): BuildStepResult {
if (step.mainfile) {
args.unshift.apply(args, ["-D", "__MAIN__"]);
}
var customArgs = params.extra_compiler_args || ['-T', '-g', '-Oirs', '-Cl'];
var customArgs = params.extra_compiler_args || ['-T', '-g', '-Oirs', '-Cl', '-W', '-pointer-sign'];
args = args.concat(customArgs, args);
args.push(step.path);
//console.log(args);

View File

@ -110,3 +110,4 @@ testPlatform(ex, 'zmachine', 'Z-Machine', 19);
//testPlatform(ex, 'atari8-800xl.mame', 'Atari 800XL', 9);
testPlatform(ex, 'msx', 'MSX', 5);
testPlatform(ex, 'zx', 'ZX', 3);
testPlatform(ex, 'c64', 'Commodore 64', 15);