Double font size, re-align it all

This commit is contained in:
stevenhowes
2021-04-01 22:01:39 +01:00
parent 28b9175835
commit 1e6266077c
7 changed files with 86 additions and 12 deletions
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+11 -1
View File
@@ -11,6 +11,7 @@ _kernel_swi_regs outreg;
// Sprite buffer // Sprite buffer
unsigned char *buffer; unsigned char *buffer;
unsigned char *fontbuffer;
extern int screen; extern int screen;
extern struct CompositionElement composition[128]; extern struct CompositionElement composition[128];
extern int current_element; extern int current_element;
@@ -46,13 +47,20 @@ int main(int argc, char *argv[])
// Load sprite library // Load sprite library
load_sprites("Spr"); load_sprites("Spr");
load_font("Font");
#ifndef SKIP_INTRO
// Intro titles + music // Intro titles + music
intro(); intro();
#endif
// Clear both buffers or we get gibberish
screen_flipbuffer();
screen_clear();
screen_flipbuffer(); screen_flipbuffer();
screen_clear(); screen_clear();
#ifndef SKIP_MISSION1
// Mission 1 // Mission 1
while(lastoutcome == 1) while(lastoutcome == 1)
{ {
@@ -67,7 +75,9 @@ int main(int argc, char *argv[])
lastoutcome = outcome; lastoutcome = outcome;
} }
game1_victory(); game1_victory();
#endif
#ifndef SKIP_MISSION2
lastoutcome = 1; lastoutcome = 1;
// Mission 2 // Mission 2
@@ -83,7 +93,7 @@ int main(int argc, char *argv[])
} }
lastoutcome = outcome; lastoutcome = outcome;
} }
#endif
free(buffer); free(buffer);
+71 -7
View File
@@ -7,6 +7,7 @@ extern _kernel_swi_regs inreg;
extern _kernel_swi_regs outreg; extern _kernel_swi_regs outreg;
extern unsigned char *buffer; extern unsigned char *buffer;
extern unsigned char *fontbuffer;
int screen = 1; int screen = 1;
// Loads sprite file into buffer // Loads sprite file into buffer
@@ -59,6 +60,56 @@ void load_sprites(char* filename)
_kernel_swi(OS_SpriteOp,&inreg,&outreg); _kernel_swi(OS_SpriteOp,&inreg,&outreg);
} }
// Loads sprite file into buffer
void load_font(char* filename)
{
int length;
// Attempt to get file info
inreg.r[0] = 13;
inreg.r[1] = (int) filename;
_kernel_swi(OS_File,&inreg,&outreg);
// Length will be in R4 if it exists
length = outreg.r[4];
// If it's <1 it's fil not found
if(outreg.r[0] < 1)
{
printf("Sprite file %s not found",filename);
exit(0);
}
// Stops us trying to mallocsomething mad if file is too big.
if(length > 200000)
{
printf("Sprite file %s seems unreasonably large at %i bytes",filename, length);
exit(0);
}
// Attempt malloc, die if we cant
fontbuffer = (unsigned char *) malloc(length + 4);
if(fontbuffer==NULL)
{
printf("Couldn't malloc %i bytes for sprite buffer",length);
exit(0);
}
// Store size and other info as required for SpriteOp 9 to init sprite area
*(unsigned int *)fontbuffer = length + 4;
*(unsigned int *)(fontbuffer + 4) = 16;
inreg.r[0] = 256+9;
inreg.r[1] = (unsigned int) fontbuffer;
_kernel_swi(OS_SpriteOp,&inreg,&outreg);
// Load sprite file into buffer
inreg.r[0] = 256+10;
inreg.r[1] = (int) fontbuffer;
inreg.r[2] = (int) filename;
_kernel_swi(OS_SpriteOp,&inreg,&outreg);
}
void display_mode(int mode) void display_mode(int mode)
{ {
int pitch; int pitch;
@@ -131,6 +182,19 @@ void draw_sprite(char* spritename,int x, int y)
_kernel_swi(OS_SpriteOp,&inreg,&outreg); _kernel_swi(OS_SpriteOp,&inreg,&outreg);
} }
void draw_letter(char* spritename,int x, int y)
{
// SpriteOp 34 to put sprite at a location
inreg.r[0] = 256+34;
inreg.r[1] = (int) fontbuffer;
inreg.r[2] = (int) spritename;
inreg.r[3] = x;
inreg.r[4] = y;
inreg.r[5] = 8; // GCOL dest=source and sprite mask
_kernel_swi(OS_SpriteOp,&inreg,&outreg);
}
void draw_spritetext(char* text, int x, int y) void draw_spritetext(char* text, int x, int y)
{ {
int currentx; int currentx;
@@ -144,7 +208,7 @@ void draw_spritetext(char* text, int x, int y)
str[0] = text[i]; str[0] = text[i];
if((text[i] != ' ') && (text[i] != '\n') && (text[i] != '~')) if((text[i] != ' ') && (text[i] != '\n') && (text[i] != '~'))
draw_sprite(str,currentx,currenty); draw_letter(str,currentx,currenty);
switch (text[i]) switch (text[i])
{ {
@@ -153,20 +217,20 @@ void draw_spritetext(char* text, int x, int y)
case 'y': case 'y':
case '.': case '.':
case ',': case ',':
currentx += 6 + 2; currentx += 12 + 4;
break; break;
case '\'': case '\'':
currentx += 4 + 2; currentx += 8 + 4;
break; break;
case 'm': case 'm':
currentx += 14 + 2; currentx += 28 + 4;
break; break;
case 'q': case 'q':
case 'w': case 'w':
currentx += 10 + 2; currentx += 20 + 4;
break; break;
case ' ': case ' ':
currentx += 6 + 2; currentx += 8 + 4;
break; break;
case '=': case '=':
currentx += 22 + 2; currentx += 22 + 2;
@@ -179,7 +243,7 @@ void draw_spritetext(char* text, int x, int y)
currentx -= 2; currentx -= 2;
break; break;
default: default:
currentx += 8 + 2; currentx += 16 + 4;
} }
if(text[i] == '\n') if(text[i] == '\n')
+3 -3
View File
@@ -934,7 +934,7 @@ void game_draw_tractor()
Player.location.Y += PLAYER_X_SPEED * (tick - lasttick) / 6; Player.location.Y += PLAYER_X_SPEED * (tick - lasttick) / 6;
for(tractorx = 0; tractorx <= (Player.hitbox_tr.X - Player.hitbox_bl.X); tractorx++) for(tractorx = 0; tractorx <= (Player.hitbox_tr.X - Player.hitbox_bl.X); tractorx = tractorx + 4)
{ {
colour = tractor1; colour = tractor1;
colour += rand() % (tractormax - tractor1); colour += rand() % (tractormax - tractor1);
@@ -983,7 +983,7 @@ void game1_briefing()
screen_clear(); screen_clear();
draw_spritetext( draw_spritetext(
"~~~~~~~~{chief engineers log - uss archimedes - stardate 1234567890 ~~==========~~===============}\n\n\nthe federation has begun diplomatic relations with the planet korell. their unusual position within an asteroid belt \nmeans their planet has to be protected by a deflector shield. the federation has offered to help enhance this shield. \nonce this upgrade was completed we were preparing to leave when we recieved a priority one transmission from the \narchimedes saying a fleet of fighters from the neighbouring planet of durnovaria was en route to torell. it transpires \nthat the deflector shield may also have some military value that was concealed from the federation. the durnovarians \nhave said our shuttle is now considered a military target and will be treated as such. must to get back to the archimedes \nbefore we get dragged further into the conflict between the two planets.\n\n\n\n\n\n\n\n\n\n\n\n\n\n~~~~~~~~{==========================================~~~~~~~~=======}" "~~~~~~~~{ chief engineers log - uss archimedes - stardate 1234567890 ==}\n\n\nthe federation has begun diplomatic relations with the planet \nkorell. their unusual position within an asteroid belt means \ntheir planet has to be protected by a deflector shield. the \nfederation has offered to help enhance this shield. once this \nupgrade was completed we were preparing to leave when we \nrecieved a priority one transmission from the archimedes \nsaying a fleet of fighters from the neighbouring planet of \ndurnovaria was en route to torell. it transpires that the planet's \nshield may also have some military value that was concealed \nfrom the federation. the durnovarians have said our shuttle is \nnow considered a military target and will be treated as such. \nwe must to get back to the archimedes before we get dragged \nfurther into the conflict between the two planets.\n\n\n\n\n\n\n\n~~~~~~~~{======================~~~~~~~~===========================}"
, 50, 950); , 50, 950);
draw_sprite("spacebar",(DISPLAY_X/2)-106,50); draw_sprite("spacebar",(DISPLAY_X/2)-106,50);
@@ -1006,7 +1006,7 @@ void game1_victory()
screen_clear(); screen_clear();
draw_spritetext( draw_spritetext(
"~~~~~~~~{chief engineers log - uss archimedes - stardate 1234567890 ~~==========~~===============}\n\n\nour shuttlepod has been rescued by the uss archimedes - but our job here isn't done. the archimedes is now under attack \nfrom the durnovarians, and recoverying the shuttle has come at a cost. Several major systems are now offline.\n\n\n\n\n\n\n\n\n\n\n\n\n\n~~~~~~~~{==========================================~~~~~~~~=======}" "~~~~~~~~{ chief engineers log - uss archimedes - stardate 1234567890 ==}\n\n\nour shuttlepod has been rescued by the uss archimedes - but our \njob here isn't done. the archimedes is now under attack from the \ndurnovarians, and recoverying the shuttle has come at a cost. \nSeveral major systems are now offline.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n~~~~~~~~{======================~~~~~~~~===========================}"
, 50, 950); , 50, 950);
draw_sprite("spacebar",(DISPLAY_X/2)-106,50); draw_sprite("spacebar",(DISPLAY_X/2)-106,50);
+1 -1
View File
@@ -77,7 +77,7 @@ void game2_briefing()
screen_clear(); screen_clear();
draw_spritetext( draw_spritetext(
"~~~~~~~~{chief engineers log - uss archimedes - stardate 1234567890 ~~==========~~===============}\n\n\nYour mission is to be dead until I make mission 2. \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n~~~~~~~~{==========================================~~~~~~~~=======}" "~~~~~~~~{ chief engineers log - uss archimedes - stardate 1234567890 ==}\n\n\nYour mission is to be dead until I make mission 2. \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n~~~~~~~~{======================~~~~~~~~===========================}"
, 50, 950); , 50, 950);
draw_sprite("spacebar",(DISPLAY_X/2)-106,50); draw_sprite("spacebar",(DISPLAY_X/2)-106,50);