From 5e1618b4de956790bd34e3491329f3883fb0e263 Mon Sep 17 00:00:00 2001 From: nino-porcino Date: Thu, 23 Dec 2021 14:28:59 +0100 Subject: [PATCH] prepare for KickC upgrade --- demos/tetris/ckboard.h | 36 +++++++++++++++++++----------------- demos/tetris/grboard.h | 31 ++++++++++++++++++------------- demos/tetris/tetris.c | 3 --- lib/apple1.h | 2 +- lib/interrupt.h | 16 ++++++++-------- lib/tms9918.h | 8 ++++---- lib/utils.h | 7 +++++++ 7 files changed, 57 insertions(+), 46 deletions(-) diff --git a/demos/tetris/ckboard.h b/demos/tetris/ckboard.h index dceeff5..6d24aba 100644 --- a/demos/tetris/ckboard.h +++ b/demos/tetris/ckboard.h @@ -40,11 +40,13 @@ void ck_init() { void ck_drawpiece(sprite *pl) { tile_offset *data = get_piece_offsets(pl->piece, pl->angle); for(byte t=0; t<4; t++) { - // int x = pl->x; byte x1 = data->offset_x; x+= (int) x1; - // int y = pl->y; byte y1 = data->offset_y; y+= (int) y1; - - int x = pl->x + (int) data->offset_x; - int y = pl->y + (int) data->offset_y; + #ifdef KICKC_NIGHTLY + int x = pl->x + (int) data->offset_x; + int y = pl->y + (int) data->offset_y; + #else + int x = pl->x; byte x1 = data->offset_x; x+= (int) x1; + int y = pl->y; byte y1 = data->offset_y; y+= (int) y1; + #endif WRITE_BOARD(y,x,pl->piece); data++; @@ -55,12 +57,12 @@ void ck_drawpiece(sprite *pl) { void ck_erasepiece(sprite *pl) { tile_offset *data = get_piece_offsets(pl->piece, pl->angle); for(byte t=0; t<4; t++) { - #ifdef BUG736 - int x = pl->x; byte x1 = data->offset_x; x+= (int) x1; - int y = pl->y; byte y1 = data->offset_y; y+= (int) y1; - #else + #ifdef KICKC_NIGHTLY int x = pl->x + (int) data->offset_x; int y = pl->y + (int) data->offset_y; + #else + int x = pl->x; byte x1 = data->offset_x; x+= (int) x1; + int y = pl->y; byte y1 = data->offset_y; y+= (int) y1; #endif WRITE_BOARD(y,x,EMPTY); @@ -72,12 +74,12 @@ void ck_erasepiece(sprite *pl) { void ck_markpiece(sprite *pl) { tile_offset *data = get_piece_offsets(pl->piece, pl->angle); for(byte t=0; t<4; t++) { - #ifdef BUG736 - int x = pl->x; byte x1 = data->offset_x; x+= (int) x1; - int y = pl->y; byte y1 = data->offset_y; y+= (int) y1; - #else + #ifdef KICKC_NIGHTLY int x = pl->x + (int) data->offset_x; int y = pl->y + (int) data->offset_y; + #else + int x = pl->x; byte x1 = data->offset_x; x+= (int) x1; + int y = pl->y; byte y1 = data->offset_y; y+= (int) y1; #endif WRITE_BOARD(y,x,MARKED); @@ -89,12 +91,12 @@ void ck_markpiece(sprite *pl) { int collides(sprite *pl) { tile_offset *data = get_piece_offsets(pl->piece, pl->angle); for(byte t=0; t<4; t++) { - #ifdef BUG736 - int x = pl->x; byte x1 = data->offset_x; x+= (int) x1; - int y = pl->y; byte y1 = data->offset_y; y+= (int) y1; - #else + #ifdef KICKC_NIGHTLY int x = pl->x + (int) data->offset_x; int y = pl->y + (int) data->offset_y; + #else + int x = pl->x; byte x1 = data->offset_x; x+= (int) x1; + int y = pl->y; byte y1 = data->offset_y; y+= (int) y1; #endif if(x<0) return 1; // does it collide with left border? if(x>=BCOLS) return 1; // does it collide with right border? diff --git a/demos/tetris/grboard.h b/demos/tetris/grboard.h index 8ac0900..7cc5c00 100644 --- a/demos/tetris/grboard.h +++ b/demos/tetris/grboard.h @@ -188,8 +188,13 @@ void gr_erasepiece(sprite *p) { } for(byte t=0; t<4; t++) { - int x = px + (int) data->offset_x; - int y = py + (int) data->offset_y; + #ifdef KICKC_NIGHTLY + int x = px + (int) data->offset_x; + int y = py + (int) data->offset_y; + #else + int x = px; byte x1 = data->offset_x; x+= (int) x1; + int y = py; byte y1 = data->offset_y; y+= (int) y1; + #endif data++; draw_tile((byte)x,(byte)y,EMPTY_GR_CHAR,EMPTY_GR_COLOR); } @@ -208,18 +213,18 @@ void gr_erasepiece_unmarked(sprite *p) { py += STARTBOARD_Y; for(byte t=0; t<4; t++) { - #ifdef BUG736 - int x = px; byte x1 = data->offset_x; x+= (int) x1; - int y = py; byte y1 = data->offset_y; y+= (int) y1; - - int cx = p->x; cx += (int) x1; - int cy = p->y; cy += (int) y1; - #else + #ifdef KICKC_NIGHTLY int x = px + (int) data->offset_x; int y = py + (int) data->offset_y; int cx = p->x + (int) data->offset_x; int cy = p->y + (int) data->offset_y; + #else + int x = px; byte x1 = data->offset_x; x+= (int) x1; + int y = py; byte y1 = data->offset_y; y+= (int) y1; + + int cx = p->x; cx += (int) x1; + int cy = p->y; cy += (int) y1; #endif data++; @@ -248,12 +253,12 @@ void gr_drawpiece(sprite *p) { byte piece = p->piece; for(byte t=0; t<4; t++) { - #ifdef BUG736 - int x = px + (int) data->offset_x; - int y = py + (int) data->offset_y; - else + #ifdef KICKC_NIGHTLY int x = px + (int) data->offset_x; int y = py + (int) data->offset_y; + #else + int x = px; byte x1 = data->offset_x; x+= (int) x1; + int y = py; byte y1 = data->offset_y; y+= (int) y1; #endif data++; diff --git a/demos/tetris/tetris.c b/demos/tetris/tetris.c index b60550d..0988b74 100644 --- a/demos/tetris/tetris.c +++ b/demos/tetris/tetris.c @@ -10,9 +10,6 @@ // previous implementations for the Laser 310 and Laser 500 // -// KickC bug waiting to be fixed -#define BUG736 1 - // standard libraries #include // memset, memcopy (memcopy no longer necessary) #include // for sprintf, rand diff --git a/lib/apple1.h b/lib/apple1.h index b040b8e..7821c3b 100644 --- a/lib/apple1.h +++ b/lib/apple1.h @@ -119,7 +119,7 @@ byte apple1_readkey() { inline void apple1_eprom_init() { // copy the initializaton data from ROM to lowram where "Data" segment is allocated - memcpy(LOWRAM_START, DATAINCODE, LOWRAM_SIZE); + memcpy((byte *)LOWRAM_START, (byte *)DATAINCODE, LOWRAM_SIZE); } #endif diff --git a/lib/interrupt.h b/lib/interrupt.h index 92f5e1b..8f8d02a 100644 --- a/lib/interrupt.h +++ b/lib/interrupt.h @@ -11,18 +11,18 @@ inline void acknowledge_interrupt() { asm { lda VDP_REG }; } -export __address(0) byte IRQ_JUMP_OPCODE; // location 0 contains the opcode for "JMP" -export __address(1) word IRQ_JUMP_ADDRESS; // location 1 and 2 contain the jump address +EXPORT __address(0) byte IRQ_JUMP_OPCODE; // location 0 contains the opcode for "JMP" +EXPORT __address(1) word IRQ_JUMP_ADDRESS; // location 1 and 2 contain the jump address // storage for a simple watch timer -export volatile byte _ticks; -export volatile byte _seconds; -export volatile byte _minutes; -export volatile byte _hours; -export volatile byte _irq_trigger; +EXPORT volatile byte _ticks; +EXPORT volatile byte _seconds; +EXPORT volatile byte _minutes; +EXPORT volatile byte _hours; +EXPORT volatile byte _irq_trigger; // interrupt routine called every 1/60th by the CPU after TMS9918 sets the /INT pin -export __interrupt(hardware_all) void interrupt_handler() { +EXPORT __interrupt(hardware_all) void interrupt_handler() { // update the watch if(++_ticks == 60) { _ticks = 0; diff --git a/lib/tms9918.h b/lib/tms9918.h index 33ecfa3..fa03a90 100644 --- a/lib/tms9918.h +++ b/lib/tms9918.h @@ -17,11 +17,11 @@ #include "utils.h" #ifdef APPLE1 - const byte *VDP_DATA = 0xCC00; // TMS9918 data port (VRAM) - const byte *VDP_REG = 0xCC01; // TMS9918 register port (write) or status (read) + const byte *VDP_DATA = (byte *) 0xCC00; // TMS9918 data port (VRAM) + const byte *VDP_REG = (byte *) 0xCC01; // TMS9918 register port (write) or status (read) #else - const byte *VDP_DATA = 0xA000; // TMS9918 data port (VRAM) - const byte *VDP_REG = 0xA001; // TMS9918 register port (write) or status (read) + const byte *VDP_DATA = (byte *) 0xA000; // TMS9918 data port (VRAM) + const byte *VDP_REG = (byte *) 0xA001; // TMS9918 register port (write) or status (read) #endif // control port bits diff --git a/lib/utils.h b/lib/utils.h index fcc831f..5802137 100644 --- a/lib/utils.h +++ b/lib/utils.h @@ -4,8 +4,15 @@ #define POKE(a,b) (*((byte *)(a))=(byte)(b)) #define PEEK(a) (*((byte *)(a))) +#ifdef KICKC_NIGHTLY +#define HIBYTE(c) (BYTE1(c)) +#define LOBYTE(c) (BYTE0(c)) +#define EXPORT __export +#else #define HIBYTE(c) (>(c)) #define LOBYTE(c) (<(c)) +#define EXPORT export +#endif #define NOP asm { nop }