1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-27 17:50:37 +00:00

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 * An Apple ][ port of the Cosmic Impalas game
* described in the book * 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 Test of the LZG decompression library
with a hires graphics image. with a hires graphics image.
@ -38,7 +44,7 @@ void clrscr() {
int main (void) int main (void)
{ {
clrscr(); 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"); printf("\nHello! Press a key to reboot...\n");
cgetc(); cgetc();
return EXIT_SUCCESS; return EXIT_SUCCESS;

View File

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

View File

@ -143,7 +143,7 @@ static void DoDiagram (void)
/* Calculate the next points */ /* Calculate the next points */
X = (int) (((long) (MaxX - 19) * I) / 360); 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 */ /* Draw the line */
tgi_lineto (XOrigin + X, YOrigin + Y); 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; sprite->name = 48;
wait_vblank(); wait_vblank();
@ -680,7 +680,6 @@ void draw_blimp(struct cvu_sprite* sprite) {
cvu_set_sprite(SPRITES, 31, sprite); cvu_set_sprite(SPRITES, 31, sprite);
refresh_actors(); refresh_actors();
*/ */
sprite=sprite;
} }
void blimp_pickup_scene() { void blimp_pickup_scene() {

View File

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

View File

@ -243,7 +243,7 @@ export function compileCC65(step: BuildStep): BuildStepResult {
loadNative("cc65"); loadNative("cc65");
var params = step.params; var params = step.params;
// stderr // stderr
var re_err1 = /(.*?)[(](\d+)[)].*?: (.+)/; var re_err1 = /(.*?):(\d+): (.+)/;
var errors: WorkerError[] = []; var errors: WorkerError[] = [];
var errline = 0; var errline = 0;
function match_fn(s) { function match_fn(s) {
@ -283,7 +283,7 @@ export function compileCC65(step: BuildStep): BuildStepResult {
if (step.mainfile) { if (step.mainfile) {
args.unshift.apply(args, ["-D", "__MAIN__"]); 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 = args.concat(customArgs, args);
args.push(step.path); args.push(step.path);
//console.log(args); //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, 'atari8-800xl.mame', 'Atari 800XL', 9);
testPlatform(ex, 'msx', 'MSX', 5); testPlatform(ex, 'msx', 'MSX', 5);
testPlatform(ex, 'zx', 'ZX', 3); testPlatform(ex, 'zx', 'ZX', 3);
testPlatform(ex, 'c64', 'Commodore 64', 15);