diff --git a/!Run,feb b/!Run,feb index b5bada1..9ab2418 100644 --- a/!Run,feb +++ b/!Run,feb @@ -1,5 +1,5 @@ -Set TheEscape$Dir -IconSprites .!Sprites -WimpSlot -min 512k -max 512k -Dir -Run .!RunImage \ No newline at end of file +Set TheEsc$Dir +IconSprites .!Sprites +WimpSlot -min 128k -max 128k +Dir +Run .!RunImage \ No newline at end of file diff --git a/!RunImage,ff8 b/!RunImage,ff8 index e663ed7..04450d2 100644 Binary files a/!RunImage,ff8 and b/!RunImage,ff8 differ diff --git a/!Sprites,ff9 b/!Sprites,ff9 index 5de963b..2729f6b 100644 Binary files a/!Sprites,ff9 and b/!Sprites,ff9 differ diff --git a/!Sprites22,ff9 b/!Sprites22,ff9 index 6c40a52..b7eee2a 100644 Binary files a/!Sprites22,ff9 and b/!Sprites22,ff9 differ diff --git a/Makefile,fe1 b/Makefile,fe1 index 8da425f..5effb70 100644 --- a/Makefile,fe1 +++ b/Makefile,fe1 @@ -1,4 +1,4 @@ -# Project: CTheEscape +# Project: TheEsc # Toolflags: diff --git a/Spr,ff9 b/Spr,ff9 index 829679f..4f02497 100644 Binary files a/Spr,ff9 and b/Spr,ff9 differ diff --git a/c/CTheEscape b/c/CTheEscape index 0646e35..371a787 100644 --- a/c/CTheEscape +++ b/c/CTheEscape @@ -10,13 +10,13 @@ _kernel_swi_regs outreg; // Sprite buffer unsigned char *buffer; - +extern int screen; extern struct CompositionElement composition[128]; extern int current_element; -#define DISPLAY_MODE 28 +#define DISPLAY_MODE 15 #define DISPLAY_X 1280 -#define DISPLAY_Y 960 +#define DISPLAY_Y 1024 #define PLAYER_Y_START 100 #define PLAYER_X_SPEED 10 @@ -25,8 +25,8 @@ extern int current_element; #define MAX_PROJECTILES 10 enum sprite_e{player_ship, durno_ship, ship_trgt, durno_ship2, ship2_trgt, player_shipl,player_shipr,explode_start,explode_shp2,explode_shp3,explode_shp4,explode_shp5,explode_shp6,explode_shp7,explode_end,photon1,photon2,plasma1,plasma2}; +//char *sprites[] = {"player_ship","durno_ship","ship_trgt","durno_ship2","ship2_trgt","player_shipl","player_shipr","explode_shp1","explode_shp2","explode_shp3","explode_shp4","explode_shp5","explode_shp6","explode_shp7","explode_shp8","photon1","photon2","plasma1","plasma2"}; char *sprites[] = {"player_ship","durno_ship","ship_trgt","durno_ship2","ship2_trgt","player_shipl","player_shipr","explode_shp1","explode_shp2","explode_shp3","explode_shp4","explode_shp5","explode_shp6","explode_shp7","explode_shp8","photon1","photon2","plasma1","plasma2"}; - char hudbuffer[63]; enum font_e{sys_12_8,font_max}; @@ -340,36 +340,40 @@ void game_draw_npcs() int i; for(i = 0; i < MAX_NPCS; i++) { - draw_sprite(sprites[NPCS[i].sprite], NPCS[i].location.X, NPCS[i].location.Y); - - // Next sprite up in index is the appropriate target icon - if(Player.targetleft == i) - draw_sprite(sprites[NPCS[i].sprite + 1], NPCS[i].location.X, NPCS[i].location.Y); - if(Player.targetright == i) - draw_sprite(sprites[NPCS[i].sprite + 1], NPCS[i].location.X, NPCS[i].location.Y); - - if(tick > NPCS[i].explodenextframe) + // Don't bother if they are off the screen + if(NPCS[i].location.Y < DISPLAY_Y) { - if((NPCS[i].sprite >= explode_start) && (NPCS[i].sprite <= explode_end)) + draw_sprite(sprites[NPCS[i].sprite], NPCS[i].location.X, NPCS[i].location.Y); + + // Next sprite up in index is the appropriate target icon + if(Player.targetleft == i) + draw_sprite(sprites[NPCS[i].sprite + 1], NPCS[i].location.X, NPCS[i].location.Y); + if(Player.targetright == i) + draw_sprite(sprites[NPCS[i].sprite + 1], NPCS[i].location.X, NPCS[i].location.Y); + + if(tick > NPCS[i].explodenextframe) { - NPCS[i].sprite++; - if(NPCS[i].sprite > explode_end) - game_respawn_npc(i); + if((NPCS[i].sprite >= explode_start) && (NPCS[i].sprite <= explode_end)) + { + NPCS[i].sprite++; + if(NPCS[i].sprite > explode_end) + game_respawn_npc(i); + } + NPCS[i].explodenextframe = tick + 4; } - NPCS[i].explodenextframe = tick + 4; - } - - if(debugs[dbhitbox]) - { - graphics_colour(colours[debugpink]); + + if(debugs[dbhitbox]) + { + graphics_colour(colours[debugpink]); - // Bounding box debug - draw_rectangle( - NPCS[i].location.X + NPCS[i].hitbox_bl.X, - NPCS[i].location.Y + NPCS[i].hitbox_bl.Y, - NPCS[i].location.X + NPCS[i].hitbox_tr.X, - NPCS[i].location.Y + NPCS[i].hitbox_tr.Y - ); + // Bounding box debug + draw_rectangle( + NPCS[i].location.X + NPCS[i].hitbox_bl.X, + NPCS[i].location.Y + NPCS[i].hitbox_bl.Y, + NPCS[i].location.X + NPCS[i].hitbox_tr.X, + NPCS[i].location.Y + NPCS[i].hitbox_tr.Y + ); + } } } } @@ -596,7 +600,7 @@ void game_draw_debugmenu() if(debugs[dbperformance]) { font_colour(colours[debuggreen],colours[lcars_black],font[sys_12_8]); - sprintf(hudbuffer,"Cents per frame: %i",(tick-lasttick)); + sprintf(hudbuffer,"CPF: %i",(tick-lasttick)); draw_text(hudbuffer,DISPLAY_X-500,DISPLAY_Y-60,font[sys_12_8]); } @@ -950,6 +954,7 @@ void game_tick() { lasttick = tick; tick = clock(); + screen_flipbuffer(); screen_clear(); @@ -976,14 +981,17 @@ int main(int argc, char *argv[]) sound_on(); display_mode(DISPLAY_MODE); + + screen_clear(); + load_sprites("Spr"); + font[sys_12_8] = font_find("Trinity.Medium",12,8); intro(); display_mode(DISPLAY_MODE); - - font[sys_12_8] = font_find("System.Medium",12,8); - + screen_clear(); + game_setup(); while(Player.integrity > 0) diff --git a/c/Graphics b/c/Graphics index ef4046a..33aea88 100644 --- a/c/Graphics +++ b/c/Graphics @@ -7,7 +7,7 @@ extern _kernel_swi_regs inreg; extern _kernel_swi_regs outreg; extern unsigned char *buffer; -unsigned char screen = 1; +int screen = 1; // Loads sprite file into buffer void load_sprites(char* filename) @@ -61,9 +61,30 @@ void load_sprites(char* filename) void display_mode(int mode) { - inreg.r[0] = 0; - inreg.r[1] = mode; - _kernel_swi(OS_ScreenMode,&inreg,&outreg); + int pitch; + int height=256; // TODO: This shouldn't be here! + + // OS_ScreenMode doesn't seem to work in 3.10 + inreg.r[0] = 22; + _kernel_swi(OS_WriteC,&inreg,&outreg); + inreg.r[0] = mode; + _kernel_swi(OS_WriteC,&inreg,&outreg); + + // The SDL library does this if double buffering is enabled - seems + // to be what makes it work - although other examples dont have this + inreg.r[0] = -1; + inreg.r[1] = 6; + _kernel_swi(OS_ReadModeVariable, &inreg, &outreg); + pitch = outreg.r[2]; + + inreg.r[0] = 2; /* Screen area */ + _kernel_swi(OS_ReadDynamicArea, &inreg, &outreg); + inreg.r[1] = (pitch * height * 2) - outreg.r[1]; + if (_kernel_swi(OS_ChangeDynamicArea, &inreg, &outreg) != NULL) + { + printf("Couldn't OS_ChangeDynamicArea"); + exit(0); + } } void draw_dotted_line(int x1,int y1,int x2,int y2) @@ -157,23 +178,21 @@ void graphics_colour(int setcolour) } void screen_flipbuffer() { - inreg.r[0] = 19; - _kernel_swi(OS_Byte,&inreg,&outreg); - -/* inreg.r[0] = 114; - inreg.r[1] = 1; + // Hardware + inreg.r[0] = 113; + inreg.r[1] = screen+1; _kernel_swi(OS_Byte,&inreg,&outreg); - inreg.r[0] = 113; - inreg.r[1] = screen; + screen ^= 1; + + // Drivers + inreg.r[0] = 112; + inreg.r[1] = screen+1; + _kernel_swi(OS_Byte,&inreg,&outreg); + + inreg.r[0] = 19; _kernel_swi(OS_Byte,&inreg,&outreg); - screen++; - if(screen > 3) - screen = 1; - inreg.r[0] = 112; - inreg.r[1] = screen; - _kernel_swi(OS_Byte,&inreg,&outreg);*/ } void screen_clear()