Hi
We are writing an engine (sprites, tiles, maps) and I would like to interface with ZX Basic. The main thread is here (sorry, it's in spanish)
http://www.mojontwins.com/mojoniaplus/vi...f=9&t=1461
Now the engine is in alpha stage and there is a SDCC working demo. This is the code:
My idea is to traslate this code to ZX Basic. The engine set ups a runtime enviroment that leave between 24K and 30K bytes free from $8000 address. Basically there are 2 routines to call: INIT to initialize the engine and FRAME, that put all the stuff in the screen every frame. With this engine you can move between 8 and 16 sprites flicker free at 50fps in 48K and all 128K models. The engine has diferent implementation for each machine (floating bus in 48K, shadow screen in 128K) so the comunication is done by accessing to next memory locations:
More info in the first message of the linked thread
Regards
-----------
Buenas, estamos escribiendo un engine de sprites, tiles y mapas y me gustaría poder usar dicho engine con ZX Basic. En el hilo que enlazo arriba está todo explicado en español. No tengo mucha idea sobre ZX Basic, pero veo que hay una comunidad detrás y me gustaría que me ayudaran a traducir la demo de C a Basic.
Saludos
We are writing an engine (sprites, tiles, maps) and I would like to interface with ZX Basic. The main thread is here (sorry, it's in spanish)
http://www.mojontwins.com/mojoniaplus/vi...f=9&t=1461
Now the engine is in alpha stage and there is a SDCC working demo. This is the code:
Code:
#include "bunuelera.h"
const unsigned char data[32]= {
0x00, 0x42, 0x11, 0,
0x08, 0x60, 0x60, 2,
0x09, 0xa8, 0x48, 3,
0x0a, 0x22, 0x02, 1,
0x0b, 0xd0, 0x6e, 2,
0x0c, 0xb6, 0x34, 3,
0x0d, 0x32, 0x32, 1,
0x04, 0x52, 0x5e, 0};
int main(){
// variables
int i, x= 0, y= 0;
// pasar personajes a sprites
for ( i = 0; i < 32; i++ )
sprites[i>>2][i&3]= data[i];
// inicializar engine
INIT;
// mostrar la primera pantalla al comienzo
screen= 0;
while(1){
// esto hace que el engine procese un frame generando el escenario
FRAME;
// movimiento de los enemigos
for ( i = 1; i < 8; i++ ){
if( sprites[i][3]&1 )
if( sprites[i][2] )
sprites[i][2]--;
else
sprites[i][3]^= 1;
else
if( sprites[i][2]<0x90 )
sprites[i][2]++;
else
sprites[i][3]^= 1;
if( sprites[i][3]&2 )
if( sprites[i][1]>0x08 )
sprites[i][1]--;
else
sprites[i][3]^= 2;
else
if( sprites[i][1]<0xe8 )
sprites[i][1]++;
else
sprites[i][3]^= 2;
}
// movimiento del protagonista
if( ~KeybYUIOP & 0x01 ){ // P
if( sprites[0][1]<0xee )
sprites[0][1]++;
else if( x < 11 )
sprites[0][1]= 0x02,
screen= y*12 + ++x;
}
else if( ~KeybYUIOP & 0x02 ){ // O
if( sprites[0][1]>0x02 )
sprites[0][1]--;
else if( x )
sprites[0][1]= 0xee,
screen= y*12 + --x;
}
if( ~KeybGFDSA & 0x01 ){ // A
if( sprites[0][2]<0xa0 )
sprites[0][2]++;
else if( y < 1 )
sprites[0][2]= 0x01,
screen= ++y*12 + x;
}
else if( ~KeybTREWQ & 0x01 ){ // Q
if( sprites[0][2]>0x01 )
sprites[0][2]--;
else if( y )
sprites[0][2]= 0xa0,
screen= --y*12 + x;
}
}
}
My idea is to traslate this code to ZX Basic. The engine set ups a runtime enviroment that leave between 24K and 30K bytes free from $8000 address. Basically there are 2 routines to call: INIT to initialize the engine and FRAME, that put all the stuff in the screen every frame. With this engine you can move between 8 and 16 sprites flicker free at 50fps in 48K and all 128K models. The engine has diferent implementation for each machine (floating bus in 48K, shadow screen in 128K) so the comunication is done by accessing to next memory locations:
Code:
5b00 number of screen to paint
5b01-5b96 tiles codes of actual screen
5bfe-5bff set to repaint a rectangular area of tiles
5c00-5c3f sprite info, where
5c00-5c02 first sprite
5c00 sprite number, set high bit to disable
5c01 X coord
5c02 Y coord
5c04-5c06 second sprite
...
More info in the first message of the linked thread
Regards
-----------
Buenas, estamos escribiendo un engine de sprites, tiles y mapas y me gustaría poder usar dicho engine con ZX Basic. En el hilo que enlazo arriba está todo explicado en español. No tengo mucha idea sobre ZX Basic, pero veo que hay una comunidad detrás y me gustaría que me ayudaran a traducir la demo de C a Basic.
Saludos