diff --git a/!TheEsc/!RunImage,ff8 b/!TheEsc/!RunImage,ff8 index 9751b2d..98eecdc 100644 Binary files a/!TheEsc/!RunImage,ff8 and b/!TheEsc/!RunImage,ff8 differ diff --git a/!TheEsc/Font,ff9 b/!TheEsc/Font,ff9 new file mode 100644 index 0000000..098a878 Binary files /dev/null and b/!TheEsc/Font,ff9 differ diff --git a/!TheEsc/Spr,ff9 b/!TheEsc/Spr,ff9 index aa9c7a0..fefda99 100644 Binary files a/!TheEsc/Spr,ff9 and b/!TheEsc/Spr,ff9 differ diff --git a/!TheEsc/c/CTheEscape b/!TheEsc/c/CTheEscape index ccc9519..92c2811 100644 --- a/!TheEsc/c/CTheEscape +++ b/!TheEsc/c/CTheEscape @@ -11,6 +11,7 @@ _kernel_swi_regs outreg; // Sprite buffer unsigned char *buffer; +unsigned char *fontbuffer; extern int screen; extern struct CompositionElement composition[128]; extern int current_element; @@ -46,13 +47,20 @@ int main(int argc, char *argv[]) // Load sprite library load_sprites("Spr"); + load_font("Font"); +#ifndef SKIP_INTRO // Intro titles + music intro(); +#endif + // Clear both buffers or we get gibberish + screen_flipbuffer(); + screen_clear(); screen_flipbuffer(); screen_clear(); +#ifndef SKIP_MISSION1 // Mission 1 while(lastoutcome == 1) { @@ -67,7 +75,9 @@ int main(int argc, char *argv[]) lastoutcome = outcome; } game1_victory(); +#endif +#ifndef SKIP_MISSION2 lastoutcome = 1; // Mission 2 @@ -83,7 +93,7 @@ int main(int argc, char *argv[]) } lastoutcome = outcome; } - +#endif free(buffer); diff --git a/!TheEsc/c/Graphics b/!TheEsc/c/Graphics index e0d1ecf..f181daf 100644 --- a/!TheEsc/c/Graphics +++ b/!TheEsc/c/Graphics @@ -7,6 +7,7 @@ extern _kernel_swi_regs inreg; extern _kernel_swi_regs outreg; extern unsigned char *buffer; +extern unsigned char *fontbuffer; int screen = 1; // Loads sprite file into buffer @@ -59,6 +60,56 @@ void load_sprites(char* filename) _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) { int pitch; @@ -131,6 +182,19 @@ void draw_sprite(char* spritename,int x, int y) _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) { int currentx; @@ -144,7 +208,7 @@ void draw_spritetext(char* text, int x, int y) str[0] = text[i]; if((text[i] != ' ') && (text[i] != '\n') && (text[i] != '~')) - draw_sprite(str,currentx,currenty); + draw_letter(str,currentx,currenty); switch (text[i]) { @@ -153,20 +217,20 @@ void draw_spritetext(char* text, int x, int y) case 'y': case '.': case ',': - currentx += 6 + 2; + currentx += 12 + 4; break; case '\'': - currentx += 4 + 2; + currentx += 8 + 4; break; case 'm': - currentx += 14 + 2; + currentx += 28 + 4; break; case 'q': case 'w': - currentx += 10 + 2; + currentx += 20 + 4; break; case ' ': - currentx += 6 + 2; + currentx += 8 + 4; break; case '=': currentx += 22 + 2; @@ -179,7 +243,7 @@ void draw_spritetext(char* text, int x, int y) currentx -= 2; break; default: - currentx += 8 + 2; + currentx += 16 + 4; } if(text[i] == '\n') diff --git a/!TheEsc/c/Mission1 b/!TheEsc/c/Mission1 index bb68ba4..fe33f89 100644 --- a/!TheEsc/c/Mission1 +++ b/!TheEsc/c/Mission1 @@ -934,7 +934,7 @@ void game_draw_tractor() 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 += rand() % (tractormax - tractor1); @@ -983,7 +983,7 @@ void game1_briefing() screen_clear(); 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); draw_sprite("spacebar",(DISPLAY_X/2)-106,50); @@ -1006,7 +1006,7 @@ void game1_victory() screen_clear(); 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); draw_sprite("spacebar",(DISPLAY_X/2)-106,50); diff --git a/!TheEsc/c/Mission2 b/!TheEsc/c/Mission2 index db2342f..4fa3bdd 100644 --- a/!TheEsc/c/Mission2 +++ b/!TheEsc/c/Mission2 @@ -77,7 +77,7 @@ void game2_briefing() screen_clear(); 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); draw_sprite("spacebar",(DISPLAY_X/2)-106,50);