I have recently got back into some z80 spectrum coding and messing about with some old code that I have written and well, I am a little perplexed and it's my hope that someone can point out how much of a "special" I am
lets get to some code
Code: Select all
#include <stdio.h>
// ZX Spectrum Colours
#define BLACK 0
#define BLUE 1
#define RED 2
#define MAGENTA 3
#define GREEN 4
#define CYAN 5
#define YELLOW 6
#define WHITE 7
// ZX Specrtum Print Control Codes
#define _INK 16
#define _PAPER 17
#define _BRIGHT 19
#define _FLASH 18
#define _OVER 21
#define _INVERSE 20
#define _AT 22
void printf_at( unsigned char x, unsigned char y, char *str); // print at cell postion
void printf_at( unsigned char x, unsigned char y, char *str)
{
printf("%c%c%c%s", 22, y+32, x+32, str ); // put the text to the screen at text cell x,y
// note that cell x is determined by the character column width
}
/* example -
printf_at( x, y, "some text"); ( auto terminates string when parsed on stack)
printf_at( x, y, title_string); ( takes terminated string )
*/
int main( void )
{
char msg[50];
unsigned char _black = 0;
unsigned char _blue = 1;
unsigned char _red = 2;
unsigned char _green = 3;
unsigned char _magenta = 4;
unsigned char _cyan = 5;
unsigned char _yellow = 6;
unsigned char _white = 7;
unsigned char _on = 0;
unsigned char _off = 0;
unsigned char _ink = 16;
unsigned char _paper = 17;
sprintf( msg,"%c%c%c%c%cTest Print 0\0", _AT, 10+32, 0+32, _ink, _black);
printf( "%s",msg );
sprintf( msg,"%c%c%c%c%cTest Print 1\0", _AT, 11+32, 0+32, _ink, _blue);
printf( "%s",msg );
sprintf( msg,"%c%c%c%c%cTest Print 2\0", _AT, 12+32, 0+32, _ink, _red);
printf( "%s",msg );
sprintf( msg,"%c%c%c%c%cTest Print 3\0", _AT, 13+32, 0+32, _ink, _green);
printf( "%s",msg );
sprintf( msg,"%c%c%c%c%cTest Print 4\0", _AT, 14+32, 0+32, _ink, _magenta);
printf( "%s",msg );
sprintf( msg,"%c%c%c%c%cTest Print 5\0", _AT, 15+32, 0+32, _ink, _cyan);
printf( "%s",msg );
sprintf( msg,"%c%c%c%c%cTest Print 6\0", _AT, 16+32, 0+32, _ink, _yellow);
printf( "%s",msg );
sprintf( msg,"%c%c%c%c%cTest Print 7\0", _AT, 17+32, 0+32, _ink, _white);
printf( "%s",msg );
return 1;
}
Code: Select all
#!/bin/bash
zcc +zx -startup=5 -lp3 -DPLUS3 -lm -create-app zxmp.c > build.txt
However, here is the output
clearly I have messed up and after a few hours reading / testing... kinda need a clue
The "printf_at()" works as expected, the Y is 0 - 23 cells and the X is 0 to 63 columns, however will produces the colour / attribute errors in the above picture.