diff --git a/streams/Makefile b/demos/streams/Makefile similarity index 100% rename from streams/Makefile rename to demos/streams/Makefile diff --git a/streams/snow.s b/demos/streams/snow.s similarity index 100% rename from streams/snow.s rename to demos/streams/snow.s diff --git a/games/tfv/Makefile b/games/tfv/Makefile index e36588ef..924a0c14 100644 --- a/games/tfv/Makefile +++ b/games/tfv/Makefile @@ -62,8 +62,8 @@ TFV_WORLD: tfv_world.o ld65 -o TFV_WORLD tfv_world.o -C ../linker_scripts/apple2_2000.inc tfv_world.o: tfv_world.s \ - tfv_overworld.s tfv_drawmap.s \ - help_overworld.s \ + tfv_overworld.s tfv_drawmap.s tfv_battle.s \ + help_overworld.s rotate_intro.s \ graphics_map/tfv_backgrounds.inc tfv_sprites.inc zp.inc ca65 -o tfv_world.o tfv_world.s -l tfv_world.lst diff --git a/games/tfv/help_overworld.s b/games/tfv/help_overworld.s index 33559411..e3784a45 100644 --- a/games/tfv/help_overworld.s +++ b/games/tfv/help_overworld.s @@ -27,13 +27,12 @@ print_help: rts help_message: - .byte 1,18,"HELP",0 - .byte 3,4,"ARROWS - MOVE",0 - .byte 3,5,"W/A/S/D - MOVE",0 - .byte 3,6,"Z/X - SPEED UP / SLOW DOWN",0 - .byte 3,7,"SPACE - STOP",0 - .byte 3,8,"RETURN - LAND / ENTER / ACTION",0 - .byte 3,9,"I - INVENTORY",0 - .byte 3,10,"M - MAP",0 - .byte 3,11,"ESC - QUIT",0 + .byte 18,1,"HELP",0 + .byte 3,4, "W/A/S/D,ARROWS - MOVE",0 + .byte 3,8, "RETURN - ENTER / ACTION",0 + .byte 3,9, "I - INVENTORY",0 + .byte 3,10,"M - MAP",0 + .byte 3,11,"ESC - QUIT",0 + .byte 3,12,"J - JOYSTICK",0 + .byte 3,13,"CONTROL-T - TOGGLE SOUND",0 .byte $ff diff --git a/games/tfv/tfv_battle.s b/games/tfv/tfv_battle.s index 33e0649b..5a68b39a 100644 --- a/games/tfv/tfv_battle.s +++ b/games/tfv/tfv_battle.s @@ -1,82 +1,205 @@ -#include -#include -#include -#include + ;================================ + ; do battle + ;================================ -#include +do_battle: -#include "gr-sim.h" -#include "tfv_utils.h" -#include "tfv_zp.h" -#include "tfv_defines.h" -#include "tfv_definitions.h" - -#include "tfv_sprites.h" -#include "tfv_backgrounds.h" +; int i,ch; +; int saved_drawpage; +; int ax=34; +; int enemy_count=30; +; int old; -/* Do Battle */ + jsr rotate_intro + +.if 0 + + battle_count=20; + + ; Setup Enemy */ + ; enemy_type=X + ; random, with weight toward proper terrain + ; 50% completely random, 50% terrain based? + enemy_type=random_8()%0x7; +; enemy_hp=enemies[enemy_type].hp_base+ +; (rand()&enemies[enemy_type].hp_mask); -/* Metrocat (summon?) */ + saved_drawpage=ram[DRAW_PAGE]; -/* Environment: grass, beach, forest, ice */ + ram[DRAW_PAGE]=PAGE2; -/* Enemies: HP ATTACK WEAKNESS RESIST */ -/* Killer Crab RND-32 PINCH MALAISE FIRE - Plain Fish BUBBLE FIRE ICE - Evil Tree RND-16 LEAVE FIRE ICE - Wood Elf SING MALAISE BOLT - Giant Bee RND-64 BUZZSAW ICE NONE - Procrastinon RND-32 PUTOFF NONE MALAISE + ;******************/ + ; Draw background */ - Ice Fish RND-32 AUGER FIRE ICE - EvilPenguin WADDLE FIRE ICE + ; Draw sky */ + color_equals(COLOR_MEDIUMBLUE); + for(i=0;i<10;i++) { + hlin_double(ram[DRAW_PAGE],0,39,i); + } -*/ + ; Draw ground */ + color_equals(ground_color); + for(i=10;i<40;i++) { + hlin_double(ram[DRAW_PAGE],0,39,i); + } -/* Battle. -Forest? Grassland? Artic? Ocean? - ATTACK REST - MAGIC LIMIT - SUMMON RUN + ; Draw some background images for variety? */ - SUMMONS -> METROCAT VORTEXCN - MAGIC -> HEAL FIRE - ICE MALAISE - BOLT - LIMIT -> SLICE ZAP - DROP + ram[DRAW_PAGE]=saved_drawpage; - 1 2 3 -0123456789012345678901234567890123456789| -----------------------------------------| - | HP LIMIT | -> FIGHT/LIMIT 21 -KILLER CRAB | DEATER 128/255 128 | ZAP 22 - | | REST 23 - | | RUN AWAY 24 + draw_battle_bottom(enemy_type); -Sound effects? + while(1) { -List hits + gr_copy_to_current(0xc00); -****** ** **** **** ** ** ****** **** ****** ****** ****** -** ** **** ** ** ** ** ** ** ** ** ** ** ** -** ** ** **** **** ****** **** ****** ** ****** ****** -** ** ** ** ** ** ** ** ** ** ** ** ** -****** ****** ****** **** ** **** ****** ** ****** ** + if (hp==0) { + grsim_put_sprite(tfv_defeat,ax-2,24); + } + else if (running) { +; if (battle_count%2) { + grsim_put_sprite(tfv_stand_right,ax,20); + } + else { + grsim_put_sprite(tfv_walk_right,ax,20); + } + } + else { + grsim_put_sprite(tfv_stand_left,ax,20); + grsim_put_sprite(tfv_led_sword,ax-5,20); + } -*/ +; grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); + + draw_battle_bottom(enemy_type); + + page_flip(); + + if (hp==0) { + for(i=0;i<15;i++) usleep(100000); + break; + } + + usleep(100000); + + ch=grsim_input(); + if (ch=='q') return 0; + + if (enemy_count==0) { + ; attack and decrement HP + enemy_attack(ax); + ; update limit count + if (limit<4) limit++; + + ; reset enemy time. FIXME: variable? + enemy_count=50; + } + else { + enemy_count--; + } + + if (battle_count>=64) { + + ; TODO: randomly fail at running? */ + if (running) { + break; + } + + if (menu_state==MENU_NONE) menu_state=MENU_MAIN; + menu_keypress(ch); + + } else { + battle_count++; + } + + old=battle_bar; + battle_bar=(battle_count/16); + if (battle_bar!=old) draw_battle_bottom(enemy_type); + + + if (enemy_hp==0) { + victory_dance(); + break; + } + + + } + + ram[DRAW_PAGE]=PAGE0; + clear_bottom(); + ram[DRAW_PAGE]=PAGE1; + clear_bottom(); + + running=0; +.endif + + rts + +.if 0 + + +; Do Battle */ + + +; Metrocat (summon?) */ + +; Environment: grass, beach, forest, ice */ + +; Enemies: HP ATTACK WEAKNESS RESIST */ +; Killer Crab RND-32 PINCH MALAISE FIRE +; Plain Fish BUBBLE FIRE ICE + +; Evil Tree RND-16 LEAVE FIRE ICE +; Wood Elf SING MALAISE BOLT + +; Giant Bee RND-64 BUZZSAW ICE NONE +; Procrastinon RND-32 PUTOFF NONE MALAISE + +; Ice Fish RND-32 AUGER FIRE ICE +; EvilPenguin WADDLE FIRE ICE + +; Battle. +; Forest? Grassland? Artic? Ocean? +; ATTACK REST +; MAGIC LIMIT +; SUMMON RUN +; +; SUMMONS -> METROCAT VORTEXCN +; MAGIC -> HEAL FIRE +; ICE MALAISE +; BOLT +; LIMIT -> SLICE ZAP +; DROP +; +; 1 2 3 +;0123456789012345678901234567890123456789| +;----------------------------------------| +; | HP LIMIT | -> FIGHT/LIMIT 21 +;KILLER CRAB | DEATER 128/255 128 | ZAP 22 +; | | REST 23 +; | | RUN AWAY 24 +; +;Sound effects? +; +;List hits +; +;****** ** **** **** ** ** ****** **** ****** ****** ****** +;** ** **** ** ** ** ** ** ** ** ** ** ** ** +;** ** ** **** **** ****** **** ****** ** ****** ****** +;** ** ** ** ** ** ** ** ** ** ** ** ** +;****** ****** ****** **** ** **** ****** ** ****** ** static int battle_bar=0; static int susie_out=0; -/* Background depend on map location? */ -/* Room for guinea pig in party? */ +; Background depend on map location? */ +; Room for guinea pig in party? */ -/* Attacks -> HIT, ZAP, HEAL, RUNAWAY */ +; Attacks -> HIT, ZAP, HEAL, RUNAWAY */ #define MAGIC_NONE 0 #define MAGIC_FIRE 1 #define MAGIC_ICE 2 @@ -92,89 +215,89 @@ struct enemy_type { unsigned char *sprite; }; -static struct enemy_type enemies[9]={ - [0]= { - .name="Killer Crab", - .hp_base=50, - .hp_mask=0x1f, - .attack_name="Pinch", - .weakness=MAGIC_MALAISE, - .resist=MAGIC_FIRE, - .sprite=killer_crab, - }, - [1]= { - .name="Plain Fish", - .hp_base=10, - .hp_mask=0x1f, - .attack_name="Bubble", - .weakness=MAGIC_FIRE, - .resist=MAGIC_ICE, - .sprite=plain_fish, - }, - [2]= { - .name="Evil Tree", - .hp_base=10, - .hp_mask=0x1f, - .attack_name="Leaves", - .weakness=MAGIC_FIRE, - .resist=MAGIC_ICE, - .sprite=evil_tree, - }, - [3]= { - .name="Wood Elf", - .hp_base=10, - .hp_mask=0x1f, - .attack_name="Song", - .weakness=MAGIC_MALAISE, - .resist=MAGIC_BOLT|MAGIC_HEAL, - .sprite=wood_elf, - }, - [4]= { - .name="Giant Bee", - .hp_base=10, - .hp_mask=0x1f, - .attack_name="Buzzsaw", - .weakness=MAGIC_ICE, - .resist=MAGIC_NONE, - .sprite=giant_bee, - }, - [5]= { - .name="Procrastinon", - .hp_base=10, - .hp_mask=0x1f, - .attack_name="Putoff", - .weakness=MAGIC_NONE, - .resist=MAGIC_MALAISE, - .sprite=procrastinon, - }, - [6]= { - .name="Ice Fish", - .hp_base=10, - .hp_mask=0x1f, - .attack_name="Auger", - .weakness=MAGIC_FIRE, - .resist=MAGIC_ICE, - .sprite=ice_fish, - }, - [7]= { - .name="Evil Penguin", - .hp_base=10, - .hp_mask=0x1f, - .attack_name="Waddle", - .weakness=MAGIC_FIRE, - .resist=MAGIC_ICE, - .sprite=evil_penguin, - }, - [8]= { - .name="Act.Principl", - .hp_base=10, - .hp_mask=0x1f, - .attack_name="BIRDIE", - .weakness=MAGIC_NONE, - .resist=MAGIC_ICE|MAGIC_FIRE, - .sprite=roboknee1, - }, -}; +;static struct enemy_type enemies[9]={ +; [0]= { +; .name="Killer Crab", +; .hp_base=50, +; .hp_mask=0x1f, +; .attack_name="Pinch", +; .weakness=MAGIC_MALAISE, +; .resist=MAGIC_FIRE, +; .sprite=killer_crab, +; }, +; [1]= { +; .name="Plain Fish", +; .hp_base=10, +; .hp_mask=0x1f, +; .attack_name="Bubble", +; .weakness=MAGIC_FIRE, +; .resist=MAGIC_ICE, +; .sprite=plain_fish, +; }, +; [2]= { +; .name="Evil Tree", +; .hp_base=10, +; .hp_mask=0x1f, +; .attack_name="Leaves", +; .weakness=MAGIC_FIRE, +; .resist=MAGIC_ICE, +; .sprite=evil_tree, +; }, +; [3]= { +; .name="Wood Elf", +; .hp_base=10, +; .hp_mask=0x1f, +; .attack_name="Song", +; .weakness=MAGIC_MALAISE, +; .resist=MAGIC_BOLT|MAGIC_HEAL, +; .sprite=wood_elf, +; }, +; [4]= { +; .name="Giant Bee", +; .hp_base=10, +; .hp_mask=0x1f, +; .attack_name="Buzzsaw", +; .weakness=MAGIC_ICE, +; .resist=MAGIC_NONE, +; .sprite=giant_bee, +; }, +; [5]= { +; .name="Procrastinon", +; .hp_base=10, +; .hp_mask=0x1f, +; .attack_name="Putoff", +; .weakness=MAGIC_NONE, +; .resist=MAGIC_MALAISE, +; .sprite=procrastinon, +; }, +; [6]= { +; .name="Ice Fish", +; .hp_base=10, +; .hp_mask=0x1f, +; .attack_name="Auger", +; .weakness=MAGIC_FIRE, +; .resist=MAGIC_ICE, +; .sprite=ice_fish, +; }, +; [7]= { +; .name="Evil Penguin", +; .hp_base=10, +; .hp_mask=0x1f, +; .attack_name="Waddle", +; .weakness=MAGIC_FIRE, +; .resist=MAGIC_ICE, +; .sprite=evil_penguin, +; }, +; [8]= { +; .name="Act.Principl", +; .hp_base=10, +; .hp_mask=0x1f, +; .attack_name="BIRDIE", +; .weakness=MAGIC_NONE, +; .resist=MAGIC_ICE|MAGIC_FIRE, +; .sprite=roboknee1, +; }, +;}; static int gr_put_num(int xx,int yy,int number) { @@ -201,29 +324,29 @@ static int gr_put_num(int xx,int yy,int number) { return 0; } -/* - ATTACK SKIP - MAGIC LIMIT - SUMMON ESCAPE - - SUMMONS -> METROCAT VORTEXCN - MAGIC -> HEAL FIRE - ICE MALAISE - BOLT - LIMIT -> SLICE ZAP - DROP - - State Machine - - time - BOTTOM -------> MAIN_MENU ----->ATTACK - ------->SKIP - ------->MAGIC_MENU - ------->LIMIT_MENU - ------->SUMMON_MENU - ------->ESCAPE - -*/ +; +; ATTACK SKIP +; MAGIC LIMIT +; SUMMON ESCAPE +; +; SUMMONS -> METROCAT VORTEXCN +; MAGIC -> HEAL FIRE + ; ICE MALAISE +; BOLT +; LIMIT -> SLICE ZAP + ; DROP +; +; State Machine +; +; time +; BOTTOM -------> MAIN_MENU ----->ATTACK +; ------->SKIP +; ------->MAGIC_MENU +; ------->LIMIT_MENU +; ------->SUMMON_MENU +; ------->ESCAPE +; +; #define MENU_NONE 0 #define MENU_MAIN 1 @@ -245,20 +368,20 @@ static int draw_battle_bottom(int enemy_type) { vtab(22); htab(1); move_cursor(); - print(enemies[enemy_type].name); +; print(enemies[enemy_type].name); if (enemy_attacking) { vtab(24); htab(2); move_cursor(); - print_inverse(enemies[enemy_type].attack_name); +; print_inverse(enemies[enemy_type].attack_name); } vtab(22); htab(15); move_cursor(); - // should print "NAMEO" -// print("DEATER"); + ; should print "NAMEO" +; print("DEATER"); print(nameo); if (susie_out) { @@ -270,7 +393,7 @@ static int draw_battle_bottom(int enemy_type) { if (menu_state==MENU_NONE) { - /* TFV Stats */ + ; TFV Stats */ vtab(21); htab(25); @@ -294,7 +417,7 @@ static int draw_battle_bottom(int enemy_type) { print("LIMIT"); } else { - /* Make if flash? set bit 0x40 */ + ; Make if flash? set bit 0x40 */ print_flash("LIMIT"); } @@ -310,8 +433,8 @@ static int draw_battle_bottom(int enemy_type) { move_cursor(); print_byte(mp); - /* Draw Time bargraph */ -// printf("Battle_bar=%d Limit=%d\n",battle_bar,limit); + ; Draw Time bargraph */ +; printf("Battle_bar=%d Limit=%d\n",battle_bar,limit); ram[COLOR]=0xa0; hlin_double(ram[DRAW_PAGE],30,34,42); ram[COLOR]=0x20; @@ -319,7 +442,7 @@ static int draw_battle_bottom(int enemy_type) { hlin_double(ram[DRAW_PAGE],30,30+(battle_bar-1),42); } - /* Draw Limit break bargraph */ + ; Draw Limit break bargraph */ ram[COLOR]=0xa0; hlin_double(ram[DRAW_PAGE],35,39,42); @@ -327,7 +450,7 @@ static int draw_battle_bottom(int enemy_type) { if (limit) hlin_double(ram[DRAW_PAGE],35,35+limit,42); - /* Susie Stats */ + ; Susie Stats */ if (susie_out) { vtab(23); @@ -340,7 +463,7 @@ static int draw_battle_bottom(int enemy_type) { move_cursor(); print_byte(0); #if 0 - /* Draw Time bargraph */ + ; Draw Time bargraph */ ram[COLOR]=0xa0; hlin_double(ram[DRAW_PAGE],30,34,42); ram[COLOR]=0x20; @@ -348,7 +471,7 @@ static int draw_battle_bottom(int enemy_type) { hlin_double(ram[DRAW_PAGE],30,30+(battle_bar-1),42); } - /* Draw Limit break bargraph */ + ; Draw Limit break bargraph */ ram[COLOR]=0xa0; hlin_double(ram[DRAW_PAGE],35,39,42); @@ -497,13 +620,13 @@ static int draw_battle_bottom(int enemy_type) { else print("ZAP"); } - /* Draw inverse separator */ + ; Draw inverse separator */ ram[COLOR]=0x20; for(i=40;i<50;i+=2) { hlin_double(ram[DRAW_PAGE],12,12,i); } -// ram[DRAW_PAGE]=saved_page; +; ram[DRAW_PAGE]=saved_page; return 0; } @@ -555,7 +678,7 @@ static int attack(void) { } grsim_put_sprite(tfv_led_sword,ax-5,20); - grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); +; grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); draw_battle_bottom(enemy_type); @@ -585,21 +708,21 @@ static int enemy_attack(int tfv_x) { while(ax<30) { - // put attack name on - // occasionally attack with that enemy's power? - // occasionally heal self? + ; put attack name on + ; occasionally attack with that enemy's power? + ; occasionally heal self? gr_copy_to_current(0xc00); - // draw first so behind enemy + ; draw first so behind enemy grsim_put_sprite(tfv_stand_left,tfv_x,20); grsim_put_sprite(tfv_led_sword,tfv_x-5,20); if (ax&1) { - grsim_put_sprite(enemies[enemy_type].sprite,ax,20); +; grsim_put_sprite(enemies[enemy_type].sprite,ax,20); } else { - grsim_put_sprite(enemies[enemy_type].sprite,ax,20); +; grsim_put_sprite(enemies[enemy_type].sprite,ax,20); } draw_battle_bottom(enemy_type); @@ -632,7 +755,7 @@ static int victory_dance(void) { saved_drawpage=ram[DRAW_PAGE]; - ram[DRAW_PAGE]=PAGE2; // 0xc00 + ram[DRAW_PAGE]=PAGE2; ; 0xc00 clear_bottom(); @@ -681,10 +804,10 @@ static int rotate_intro(void) { gr_copy(0x400,0xc00); -// gr_copy_to_current(0xc00); -// page_flip(); -// gr_copy_to_current(0xc00); -// page_flip(); +; gr_copy_to_current(0xc00); +; page_flip(); +; gr_copy_to_current(0xc00); +; page_flip(); thetadiff=0; @@ -765,10 +888,10 @@ static void magic_attack(int which) { } - // FIXME: damage based on weakness of enemy - // FIXME: disallow if not enough MP + ; FIXME: damage based on weakness of enemy + ; FIXME: disallow if not enough MP - /* cast the magic */ + ; cast the magic */ i=0; while(i<10) { @@ -776,7 +899,7 @@ static void magic_attack(int which) { grsim_put_sprite(tfv_victory,34,20); - grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); +; grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); draw_battle_bottom(enemy_type); @@ -791,13 +914,13 @@ static void magic_attack(int which) { ay=20; i=0; - /* Actually put the magic */ + ; Actually put the magic */ while(i<=20) { gr_copy_to_current(0xc00); - grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); +; grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); grsim_put_sprite(tfv_stand_left,ax,ay); grsim_put_sprite(tfv_led_sword,ax-5,ay); @@ -817,7 +940,7 @@ static void magic_attack(int which) { gr_copy_to_current(0xc00); - grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); +; grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); grsim_put_sprite(tfv_stand_left,ax,ay); grsim_put_sprite(tfv_led_sword,ax-5,ay); @@ -840,8 +963,8 @@ static void magic_attack(int which) { } -/* Limit Break "Drop" */ -/* Jump into sky, drop down and slice enemy in half */ +; Limit Break "Drop" */ +; Jump into sky, drop down and slice enemy in half */ static void limit_break_drop(void) { @@ -856,7 +979,7 @@ static void limit_break_drop(void) { grsim_put_sprite(tfv_stand_left,ax,ay); grsim_put_sprite(tfv_led_sword,ax-5,ay); - grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); +; grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); draw_battle_bottom(enemy_type); @@ -870,13 +993,13 @@ static void limit_break_drop(void) { ax=10; ay=0; - /* Falling */ + ; Falling */ while(ay<=20) { gr_copy_to_current(0xc00); - grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); +; grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); grsim_put_sprite(tfv_stand_left,ax,ay); grsim_put_sprite(tfv_led_sword,ax-5,ay); @@ -898,7 +1021,7 @@ static void limit_break_drop(void) { gr_copy_to_current(0xc00); - grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); +; grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); grsim_put_sprite(tfv_stand_left,ax,ay); grsim_put_sprite(tfv_led_sword,ax-5,ay); @@ -919,7 +1042,7 @@ static void limit_break_drop(void) { gr_copy_to_current(0xc00); - grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); +; grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); grsim_put_sprite(tfv_stand_left,ax,ay); grsim_put_sprite(tfv_led_sword,ax-5,ay); @@ -939,9 +1062,9 @@ static void limit_break_drop(void) { } -/* Limit Break "Slice" */ -/* Run up and slap a bunch with sword */ -/* TODO: cause damage value to bounce around more? */ +; Limit Break "Slice" */ +; Run up and slap a bunch with sword */ +; TODO: cause damage value to bounce around more? */ static void limit_break_slice(void) { @@ -956,7 +1079,7 @@ static void limit_break_slice(void) { grsim_put_sprite(tfv_stand_left,tx,ty); grsim_put_sprite(tfv_led_sword,tx-5,ty); - grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); +; grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); draw_battle_bottom(enemy_type); @@ -967,12 +1090,12 @@ static void limit_break_slice(void) { usleep(20000); } - /* Slicing */ + ; Slicing */ for(i=0;i<20;i++) { gr_copy_to_current(0xc00); - grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); +; grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); if (i&1) { grsim_put_sprite(tfv_stand_left,tx,20); @@ -984,7 +1107,7 @@ static void limit_break_slice(void) { } damage_enemy(damage); - gr_put_num(2+(i%2),10+((i%2)*2),damage); +; gr_put_num(2+(i%2),10+((i%2)*2),damage); draw_battle_bottom(enemy_type); @@ -998,7 +1121,7 @@ static void limit_break_slice(void) { gr_copy_to_current(0xc00); - grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); +; grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); grsim_put_sprite(tfv_stand_left,tx,ty); grsim_put_sprite(tfv_led_sword,tx-5,ty); @@ -1012,8 +1135,8 @@ static void limit_break_slice(void) { } } -/* Limit Break "Zap" */ -/* Zap with a laser out of the LED sword */ +; Limit Break "Zap" */ +; Zap with a laser out of the LED sword */ static void limit_break_zap(void) { @@ -1024,16 +1147,16 @@ static void limit_break_zap(void) { gr_copy_to_current(0xc00); - /* Draw background */ + ; Draw background */ color_equals(COLOR_AQUA); vlin(12,24,34); hlin_double(ram[DRAW_PAGE],28,38,18); - /* Sword in air */ + ; Sword in air */ grsim_put_sprite(tfv_victory,tx,20); grsim_put_sprite(tfv_led_sword,tx-2,14); - grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); +; grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); draw_battle_bottom(enemy_type); @@ -1045,7 +1168,7 @@ static void limit_break_zap(void) { gr_copy_to_current(0xc00); - grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); +; grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); color_equals(i%16); hlin_double(ram[DRAW_PAGE],5,30,22); @@ -1062,7 +1185,7 @@ static void limit_break_zap(void) { gr_copy_to_current(0xc00); - grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); +; grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); grsim_put_sprite(tfv_stand_left,tx,ty); grsim_put_sprite(tfv_led_sword,tx-5,ty); @@ -1091,7 +1214,7 @@ static void limit_break(int which) { else if (which==MENU_LIMIT_SLICE) limit_break_slice(); else if (which==MENU_LIMIT_ZAP) limit_break_zap(); - /* reset limit counter */ + ; reset limit counter */ limit=0; } @@ -1111,7 +1234,7 @@ static void summon_metrocat(void) { grsim_put_sprite(tfv_stand_left,tx,ty); grsim_put_sprite(tfv_led_sword,tx-5,ty); - grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); +; grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); grsim_put_sprite(metrocat,ax,ay); @@ -1131,7 +1254,7 @@ static void summon_metrocat(void) { grsim_put_sprite(tfv_stand_left,tx,ty); grsim_put_sprite(tfv_led_sword,tx-5,ty); - grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); +; grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); grsim_put_sprite(metrocat,ax,ay); @@ -1151,7 +1274,7 @@ static void summon_metrocat(void) { grsim_put_sprite(tfv_stand_left,tx,ty); grsim_put_sprite(tfv_led_sword,tx-5,ty); - grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); +; grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); grsim_put_sprite(metrocat,ax,ay); @@ -1173,7 +1296,7 @@ static void summon_metrocat(void) { grsim_put_sprite(tfv_stand_left,tx,ty); grsim_put_sprite(tfv_led_sword,tx-5,ty); - grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); +; grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); grsim_put_sprite(metrocat,ax,ay); @@ -1188,7 +1311,7 @@ static void summon_metrocat(void) { gr_copy_to_current(0xc00); - grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); +; grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); grsim_put_sprite(tfv_stand_left,tx,ty); grsim_put_sprite(tfv_led_sword,tx-5,ty); @@ -1210,7 +1333,7 @@ static void summon_vortex_cannon(void) { int i; int ax=20,ay=20; - /* draw the cannon */ + ; draw the cannon */ i=0; while(i<30) { @@ -1220,7 +1343,7 @@ static void summon_vortex_cannon(void) { grsim_put_sprite(tfv_stand_left,tx,ty); grsim_put_sprite(tfv_led_sword,tx-5,ty); - grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); +; grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); grsim_put_sprite(vortex_cannon,ax,ay); @@ -1233,7 +1356,7 @@ static void summon_vortex_cannon(void) { usleep(20000); } - /* Fire vortices */ + ; Fire vortices */ ax=20; for(i=0;i<5;i++) { @@ -1244,7 +1367,7 @@ static void summon_vortex_cannon(void) { grsim_put_sprite(tfv_stand_left,tx,ty); grsim_put_sprite(tfv_led_sword,tx-5,ty); - grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); +; grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); grsim_put_sprite(vortex_cannon,20,20); @@ -1269,7 +1392,7 @@ static void summon_vortex_cannon(void) { gr_copy_to_current(0xc00); - grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); +; grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); grsim_put_sprite(tfv_stand_left,tx,ty); grsim_put_sprite(tfv_led_sword,tx-5,ty); @@ -1292,7 +1415,7 @@ static void summon(int which) { static void done_attack(void) { - // reset battle time + ; reset battle time battle_count=0; menu_state=MENU_NONE; } @@ -1315,7 +1438,7 @@ void menu_keypress(int ch) { switch(menu_position) { case MENU_MAIN_ATTACK: - // attack and decrement HP + ; attack and decrement HP attack(); done_attack(); break; @@ -1374,141 +1497,6 @@ void menu_keypress(int ch) { } -int do_battle(int ground_color) { - - int i,ch; - - int saved_drawpage; - - int ax=34; - int enemy_count=30; - int old; - - rotate_intro(); - - battle_count=20; - - /* Setup Enemy */ - // enemy_type=X - // random, with weight toward proper terrain - // 50% completely random, 50% terrain based? - enemy_type=random_8()%0x7; - enemy_hp=enemies[enemy_type].hp_base+ - (rand()&enemies[enemy_type].hp_mask); - - - saved_drawpage=ram[DRAW_PAGE]; - - ram[DRAW_PAGE]=PAGE2; - - - - /*******************/ - /* Draw background */ - - /* Draw sky */ - color_equals(COLOR_MEDIUMBLUE); - for(i=0;i<10;i++) { - hlin_double(ram[DRAW_PAGE],0,39,i); - } - - /* Draw ground */ - color_equals(ground_color); - for(i=10;i<40;i++) { - hlin_double(ram[DRAW_PAGE],0,39,i); - } - - /* Draw some background images for variety? */ - - ram[DRAW_PAGE]=saved_drawpage; - - draw_battle_bottom(enemy_type); - - while(1) { - - gr_copy_to_current(0xc00); - - if (hp==0) { - grsim_put_sprite(tfv_defeat,ax-2,24); - } - else if (running) { - if (battle_count%2) { - grsim_put_sprite(tfv_stand_right,ax,20); - } - else { - grsim_put_sprite(tfv_walk_right,ax,20); - } - } - else { - grsim_put_sprite(tfv_stand_left,ax,20); - grsim_put_sprite(tfv_led_sword,ax-5,20); - } - - grsim_put_sprite(enemies[enemy_type].sprite,enemy_x,20); - - draw_battle_bottom(enemy_type); - - page_flip(); - - if (hp==0) { - for(i=0;i<15;i++) usleep(100000); - break; - } - - usleep(100000); - - ch=grsim_input(); - if (ch=='q') return 0; - - if (enemy_count==0) { - // attack and decrement HP - enemy_attack(ax); - // update limit count - if (limit<4) limit++; - - // reset enemy time. FIXME: variable? - enemy_count=50; - } - else { - enemy_count--; - } - - if (battle_count>=64) { - - /* TODO: randomly fail at running? */ - if (running) { - break; - } - - if (menu_state==MENU_NONE) menu_state=MENU_MAIN; - menu_keypress(ch); - - } else { - battle_count++; - } - - old=battle_bar; - battle_bar=(battle_count/16); - if (battle_bar!=old) draw_battle_bottom(enemy_type); - - - if (enemy_hp==0) { - victory_dance(); - break; - } - - - } - - ram[DRAW_PAGE]=PAGE0; - clear_bottom(); - ram[DRAW_PAGE]=PAGE1; - clear_bottom(); - - running=0; - - return 0; -} @@ -1537,10 +1525,10 @@ int boss_battle(void) { ram[DRAW_PAGE]=PAGE2; - /*******************/ - /* Draw background */ + ;******************/ + ; Draw background */ - /* Draw sky */ + ; Draw sky */ color_equals(COLOR_BLACK); for(i=0;i<20;i++) { hlin_double(ram[DRAW_PAGE],0,39,i); @@ -1551,9 +1539,9 @@ int boss_battle(void) { hlin_double(ram[DRAW_PAGE],0,39,i); } - /* Draw horizon */ -// color_equals(COLOR_GREY); -// hlin_double(ram[DRAW_PAGE],0,39,10); + ; Draw horizon */ +; color_equals(COLOR_GREY); +; hlin_double(ram[DRAW_PAGE],0,39,10); ram[DRAW_PAGE]=saved_drawpage; @@ -1567,7 +1555,7 @@ int boss_battle(void) { grsim_put_sprite(tfv_defeat,ax-2,24); } else if (running) { - if (battle_count%2) { +; if (battle_count%2) { grsim_put_sprite(tfv_stand_right,ax,20); } else { @@ -1603,12 +1591,12 @@ int boss_battle(void) { if (ch=='q') return 0; if (enemy_count==0) { - // attack and decrement HP + ; attack and decrement HP enemy_attack(ax); - // update limit count + ; update limit count if (limit<4) limit++; - // reset enemy time. FIXME: variable? + ; reset enemy time. FIXME: variable? enemy_count=50; } else { @@ -1617,7 +1605,7 @@ int boss_battle(void) { if (battle_count>=64) { - /* TODO: randomly fail at running? */ + ; TODO: randomly fail at running? */ if (running) { break; } @@ -1635,7 +1623,7 @@ int boss_battle(void) { if (enemy_hp==0) { - // FIXME? + ; FIXME? victory_dance(); break; } @@ -1652,3 +1640,5 @@ int boss_battle(void) { return 0; } + +.endif diff --git a/games/tfv/tfv_overworld.s b/games/tfv/tfv_overworld.s index a38c0b63..61b6a00c 100644 --- a/games/tfv/tfv_overworld.s +++ b/games/tfv/tfv_overworld.s @@ -63,31 +63,31 @@ worldmap_keyboard: jsr get_keypress ; get keypress -; lda LASTKEY - worldmap_handle_q: - cmp #('Q') ; if quit, then return + cmp #'Q' ; if quit, then return bne worldmap_handle_up rts worldmap_handle_up: - cmp #('W') + cmp #'W' bne worldmap_handle_down dec NEWY dec NEWY inc MOVED + jmp worldmap_done_keyboard worldmap_handle_down: - cmp #('S') + cmp #'S' bne worldmap_handle_left inc NEWY inc NEWY inc MOVED + jmp worldmap_done_keyboard worldmap_handle_left: - cmp #('A') + cmp #'A' bne worldmap_handle_right lda DIRECTION ; 0=left, 1=right @@ -97,11 +97,13 @@ left_turn: lda #0 ; change direction to left sta DIRECTION sta ODD ; stand (not walk) if changing - beq worldmap_handle_right ; skip ahead + beq done_handle_left ; bra skip ahead go_left: dec NEWX ; decrement x inc MOVED ; we moved +done_handle_left: + jmp worldmap_done_keyboard worldmap_handle_right: cmp #('D') @@ -115,46 +117,55 @@ right_turn: sta DIRECTION lda #0 ; change to standing sta ODD - beq worldmap_handle_enter ; skip ahead + beq done_handle_right ; bra skip ahead go_right: inc NEWX ; increment X inc MOVED +done_handle_right: + jmp worldmap_done_keyboard + worldmap_handle_enter: cmp #13 bne worldmap_handle_help ; jsr city_map inc REFRESH + jmp worldmap_done_keyboard worldmap_handle_help: cmp #('H') bne worldmap_handle_battle jsr print_help + jmp worldmap_done_keyboard worldmap_handle_battle: - cmp #('B') + cmp #'B' bne worldmap_handle_info - ; jsr do_battle + jsr do_battle inc REFRESH + jmp worldmap_done_keyboard worldmap_handle_info: - cmp #('I') + cmp #'I' bne worldmap_handle_map ; jsr print_info inc REFRESH + jmp worldmap_done_keyboard worldmap_handle_map: cmp #('M') bne worldmap_done_keyboard - jsr show_map + jsr show_map inc REFRESH +; jmp worldmap_done_keyboard + worldmap_done_keyboard: ;=========================== diff --git a/games/tfv/tfv_world.s b/games/tfv/tfv_world.s index d68fc54f..d7166790 100644 --- a/games/tfv/tfv_world.s +++ b/games/tfv/tfv_world.s @@ -51,6 +51,9 @@ .include "gr_offsets.s" .include "wait_keypressed.s" +.include "tfv_battle.s" +.include "rotate_intro.s" + ;=============================================== ; Variables ;=============================================== diff --git a/utils/gr-sim/rotate_wipe/Makefile b/utils/gr-sim/rotate_wipe/Makefile index d8fb4a67..1bbdd5e8 100644 --- a/utils/gr-sim/rotate_wipe/Makefile +++ b/utils/gr-sim/rotate_wipe/Makefile @@ -6,7 +6,8 @@ SDL_LIBS= `sdl-config --libs` SDL_INCLUDE= `sdl-config --cflags` GR_SIM = ../gr-sim.a -all: rotate rotate_zoom_in rotate_zoom_out +all: rotate rotate_zoom_in rotate_zoom_out rotate_in_lookup rotate_latecomer \ + rotate_rotozoom rotate_rotolookup #### @@ -24,6 +25,14 @@ rotate.o: rotate.c demo_title.c #### +rotate_in_lookup: rotate_in_lookup.o $(GR_SIM) + $(CC) -o rotate_in_lookup rotate_in_lookup.o $(GR_SIM) $(SDL_LIBS) $(LFLAGS) + +rotate_in_lookup.o: rotate_in_lookup.c demo_title.c + $(CC) $(CFLAGS) -c rotate_in_lookup.c + +#### + rotate_zoom_in: rotate_zoom_in.o $(GR_SIM) $(CC) -o rotate_zoom_in rotate_zoom_in.o $(GR_SIM) $(SDL_LIBS) $(LFLAGS) @@ -38,8 +47,34 @@ rotate_zoom_out: rotate_zoom_out.o $(GR_SIM) rotate_zoom_out.o: rotate_zoom_out.c demo_title.c $(CC) $(CFLAGS) -c rotate_zoom_out.c +#### + +rotate_latecomer: rotate_latecomer.o $(GR_SIM) + $(CC) -o rotate_latecomer rotate_latecomer.o $(GR_SIM) $(SDL_LIBS) $(LFLAGS) + +rotate_latecomer.o: rotate_latecomer.c demo_title.c + $(CC) $(CFLAGS) -c rotate_latecomer.c + +#### + +rotate_rotozoom: rotate_rotozoom.o $(GR_SIM) + $(CC) -o rotate_rotozoom rotate_rotozoom.o $(GR_SIM) $(SDL_LIBS) $(LFLAGS) + +rotate_rotozoom.o: rotate_rotozoom.c demo_title.c + $(CC) $(CFLAGS) -c rotate_rotozoom.c + +#### + +rotate_rotolookup: rotate_rotolookup.o $(GR_SIM) + $(CC) -o rotate_rotolookup rotate_rotolookup.o $(GR_SIM) $(SDL_LIBS) $(LFLAGS) + +rotate_rotolookup.o: rotate_rotolookup.c demo_title.c + $(CC) $(CFLAGS) -c rotate_rotolookup.c + + + #### clean: - rm -f *~ *.o rotate rotate_zoom_in rotate_zoom_out + rm -f *~ *.o rotate rotate_zoom_in rotate_zoom_out rotate_in_lookup rotate_latecomer rotate_rotozoom rotate_rotolookup diff --git a/utils/gr-sim/rotate_wipe/rotate_in_lookup.c b/utils/gr-sim/rotate_wipe/rotate_in_lookup.c new file mode 100644 index 00000000..0424d5f6 --- /dev/null +++ b/utils/gr-sim/rotate_wipe/rotate_in_lookup.c @@ -0,0 +1,137 @@ +#include +#include +#include +#include + +#include + +#include "gr-sim.h" +#include "tfv_utils.h" +#include "tfv_zp.h" + +#include "demo_title.c" + +#define PI 3.14159265358979323846264 + +static int lookup_table_x[40][40]; +static int lookup_table_y[40][40]; + +static int setup_lookup_table(void) { + + int xx,yy,dx,dy; + double h,theta,thetadiff=PI/16; + double theta2,nx,ny,x2,y2,scale=1.0; + + for(yy=0;yy<40;yy++) { + for(xx=0;xx<40;xx++) { + dx=(xx-20); + dy=(yy-20); + h=scale*sqrt((dx*dx)+(dy*dy)); + theta=atan2(dy,dx); + + theta2=theta+thetadiff; + nx=h*cos(theta2); + ny=h*sin(theta2); + + x2=nx+20; + y2=ny+20; + + if ((x2<0)||(x2>39)) { + lookup_table_x[xx][yy]=-1; + } + else { + lookup_table_x[xx][yy]=x2; + } + + if ((y2<0)||(y2>39)) { + lookup_table_y[xx][yy]=-1; + } + else { + lookup_table_y[xx][yy]=y2; + } + } + } + + return 0; +} + + +int main(int argc, char **argv) { + + int xx,yy,ch,color; + double thetadiff; + int frame=0; + double scale=1.0; + + grsim_init(); + gr(); + + setup_lookup_table(); + +// clear_screens(); + + ram[DRAW_PAGE]=PAGE0; + clear_bottom(); + ram[DRAW_PAGE]=PAGE1; + clear_bottom(); + ram[DRAW_PAGE]=PAGE2; + clear_bottom(); + + +// clear_bottom(PAGE0); +// clear_bottom(PAGE1); +// clear_bottom(PAGE2); + +// grsim_unrle(demo_rle,0x400); + grsim_unrle(demo_rle,0xc00); + +// gr_copy_to_current(0xc00); +// page_flip(); +// gr_copy_to_current(0xc00); +// page_flip(); + + ram[DRAW_PAGE]=PAGE0; + + thetadiff=0; + + while(1) { + grsim_update(); + + ch=grsim_input(); + if (ch=='q') break; + + for(yy=0;yy<40;yy++) { + for(xx=0;xx<40;xx++) { + if ((lookup_table_x[xx][yy]==-1) || + (lookup_table_y[xx][yy]==-1)) { + color=0; + } + else { + color=scrn_page(lookup_table_x[xx][yy], + lookup_table_y[xx][yy], + PAGE2); + } + color_equals(color); + plot(xx,yy); + } + } + thetadiff+=(3.14/16.0); + + scale-=0.008; + + usleep(30000); + + frame++; + /* reset */ + if (frame==128) { + sleep(1); + thetadiff=0; + scale=1.0; + frame=0; + } + + } + + return 0; +} + diff --git a/utils/gr-sim/rotate_wipe/rotate_latecomer.c b/utils/gr-sim/rotate_wipe/rotate_latecomer.c new file mode 100644 index 00000000..48efe90a --- /dev/null +++ b/utils/gr-sim/rotate_wipe/rotate_latecomer.c @@ -0,0 +1,163 @@ +#include +#include +#include +#include + +#include + +#include "gr-sim.h" +#include "tfv_utils.h" +#include "tfv_zp.h" + +#include "demo_title.c" + +#define PI 3.14159265358979323946264 + +int main(int argc, char **argv) { + + int xx,yy,ch,color,i; + double dx,dy,u,v,_u,_v,au,av; + double theta=0; + int frame=0; + double scale=1.0; + + grsim_init(); + gr(); + +// clear_screens(); + + ram[DRAW_PAGE]=PAGE0; + clear_bottom(); + ram[DRAW_PAGE]=PAGE1; + clear_bottom(); + ram[DRAW_PAGE]=PAGE2; + clear_bottom(); + + +// clear_bottom(PAGE0); +// clear_bottom(PAGE1); +// clear_bottom(PAGE2); + +// grsim_unrle(demo_rle,0x400); + grsim_unrle(demo_rle,0xc00); + +// gr_copy_to_current(0xc00); +// page_flip(); +// gr_copy_to_current(0xc00); +// page_flip(); + + ram[DRAW_PAGE]=PAGE0; + + while(1) { + grsim_update(); + +blah: + ch=grsim_input(); + if (ch=='q') break; + if (ch==0) goto blah; + +// ; ----------------- +// ; ROTOZOOM Théorie: +// ; theta: angle de rotation +// ; scale : coeff pour le zoom +// ; xx et yy : coordonnées point écran +// ; u et v : coordonnées du point texture +// ; déplacement : +// ; dx = cos(theta)*scale +// ; dx = sin(theta)*scale +// ; u = u + xx +// ; v = v + yy +// ; texture(u,v)->screen(x,y) +// ; +//; code: +///; +//; ; déplacement +//; dx = cos(theta)*scale; +//; dy = sin(theta)*scale; +//; +//; for(yy=0;yy<24;yy++) { // pour les 24 lignes +//; _u = u; ; on sauve les coordonnées du premier pixel à afficher de la ligne +//; _v = v; ; +//; for(xx=0;xx<40;xx++) { // affichage d'une ligne horizontale (40 points) +//; u = u + dx ; déplacement +//; v = v + dy ; x et y +//; text(u,v) - > screen(xx,yy) +//; } +//; u = _u - dy; // on se place sur le premier pixel de la prochaine ligne a afficher +//; v = _v + dx; +//; } +//; theta++ + + + dx = cos(theta)*scale; + dy = sin(theta)*scale; + + u=0; + v=0; + + for(i=0;i<20;i++) { + u=u-dx; + v=v-dy; + } + v=40-v; + + + for(yy=-20;yy<20;yy++) { + /* save starting point */ + _u=u; + _v=v; + for(xx=-20;xx<20;xx++) { + + /* rotate in center of screen */ + au=u+20; + av=v;//+20; + + // if ((au<0) || (au>39)) color=0; + // else if ((av<0) || (av>39)) color=0; + // else { + color=scrn_page(au,av,PAGE2); + // } + + if ( + ((xx==-20) && (yy==-20)) || + ((xx==0) && (yy==0)) || + ((xx==19) && (yy==19)) + ) { + printf("%d,%d -> %0.2lf,%0.2lf\n",xx,yy,au,av); + } + + color_equals(color); + plot(xx+20,yy+20); + + u=u+dx; + v=v+dy; + + } + /* move on to next line */ + /* since we start in upper left, add dy */ + + /* note: change sign for crazy effects */ + u=_u-dy; + v=_v+dx; + + } + theta+=(PI/4.0); + +// scale-=0.008; + + usleep(30000); + + frame++; + /* reset */ +// if (frame==128) { +// sleep(1); +// theta=0; +// scale=1.0; +// frame=0; +// } + + } + + return 0; +} + diff --git a/utils/gr-sim/rotate_wipe/rotate_rotolookup.c b/utils/gr-sim/rotate_wipe/rotate_rotolookup.c new file mode 100644 index 00000000..bbfdc660 --- /dev/null +++ b/utils/gr-sim/rotate_wipe/rotate_rotolookup.c @@ -0,0 +1,122 @@ +/* based roughly on code from https://www.ocf.berkeley.edu/~horie/qbrotate.html */ + + +#include +#include +#include +#include + +#include + +#include "gr-sim.h" +#include "tfv_utils.h" +#include "tfv_zp.h" + +#include "demo_title.c" + +#define PI 3.14159265358979323946264 + +int main(int argc, char **argv) { + + int xx,yy,ch,color; + double ca,sa,cca,csa; + double theta=0; + int frame=0; + double scale=1.0; + + double yca,ysa,xp,yp; + int xcenter=20,ycenter=20; + + grsim_init(); + gr(); + +// clear_screens(); + + ram[DRAW_PAGE]=PAGE0; + clear_bottom(); + ram[DRAW_PAGE]=PAGE1; + clear_bottom(); + ram[DRAW_PAGE]=PAGE2; + clear_bottom(); + + +// clear_bottom(PAGE0); +// clear_bottom(PAGE1); +// clear_bottom(PAGE2); + +// grsim_unrle(demo_rle,0x400); + grsim_unrle(demo_rle,0xc00); + +// gr_copy_to_current(0xc00); +// page_flip(); +// gr_copy_to_current(0xc00); +// page_flip(); + + ram[DRAW_PAGE]=PAGE0; + + while(1) { + grsim_update(); + +blah: + ch=grsim_input(); + if (ch=='q') break; + if (ch==0) goto blah; + + ca = cos(theta)*scale; + sa = sin(theta)*scale; + + cca = -20*ca; + csa = -20*sa; + + yca=cca+ycenter; + ysa=csa+xcenter; + + for(yy=-20;yy<20;yy++) { + + xp=cca+ysa; + yp=yca-csa; + + for(xx=-20;xx<20;xx++) { + + if ((xp<0) || (xp>39)) color=0; + else if ((yp<0) || (yp>39)) color=0; + else { + color=scrn_page(xp,yp,PAGE2); + } + + if ( + ((xx==-20) && (yy==-20)) || + ((xx==0) && (yy==0)) || + ((xx==19) && (yy==19)) + ) { + printf("%d,%d -> %0.2lf,%0.2lf\n",xx,yy,xp,yp); + } + + color_equals(color); + plot(xx+20,yy+20); + xp=xp+ca; + yp=yp-sa; + } + yca+=ca; + ysa+=sa; + } + theta+=(PI/8.0); + + scale-=0.008; + + usleep(30000); + + frame++; + /* reset */ + if (frame==128) { + sleep(1); + theta=0; + scale=1.0; + frame=0; + } + + } + + return 0; +} + diff --git a/utils/gr-sim/rotate_wipe/rotate_rotozoom.c b/utils/gr-sim/rotate_wipe/rotate_rotozoom.c new file mode 100644 index 00000000..7b8e0a02 --- /dev/null +++ b/utils/gr-sim/rotate_wipe/rotate_rotozoom.c @@ -0,0 +1,119 @@ +/* based roughly on code from https://www.ocf.berkeley.edu/~horie/qbrotate.html */ + + +#include +#include +#include +#include + +#include + +#include "gr-sim.h" +#include "tfv_utils.h" +#include "tfv_zp.h" + +#include "demo_title.c" + +#define PI 3.14159265358979323946264 + +int main(int argc, char **argv) { + + int xx,yy,ch,color; + double ca,sa; + double theta=0; + int frame=0; + double scale=1.0; + + double y0,x0,yca,ysa,xp,yp,xd=20,yd=20; + int ytop=0,ybottom=40,xcenter=20,ycenter=20; + int xleft=0,xright=40; + + grsim_init(); + gr(); + +// clear_screens(); + + ram[DRAW_PAGE]=PAGE0; + clear_bottom(); + ram[DRAW_PAGE]=PAGE1; + clear_bottom(); + ram[DRAW_PAGE]=PAGE2; + clear_bottom(); + + +// clear_bottom(PAGE0); +// clear_bottom(PAGE1); +// clear_bottom(PAGE2); + +// grsim_unrle(demo_rle,0x400); + grsim_unrle(demo_rle,0xc00); + +// gr_copy_to_current(0xc00); +// page_flip(); +// gr_copy_to_current(0xc00); +// page_flip(); + + ram[DRAW_PAGE]=PAGE0; + + while(1) { + grsim_update(); + +blah: + ch=grsim_input(); + if (ch=='q') break; + if (ch==0) goto blah; + + ca = cos(theta)*scale; + sa = sin(theta)*scale; + + y0=ytop-yd; + for(yy=ytop;yy39)) color=0; + else if ((yp<0) || (yp>39)) color=0; + else { + color=scrn_page(xp,yp,PAGE2); + } + + if ( + ((xx==0) && (yy==0)) || + ((xx==20) && (yy==20)) || + ((xx==39) && (yy==39)) + ) { + printf("%d,%d -> %0.2lf,%0.2lf\n",xx,yy,xp,yp); + } + + color_equals(color); + plot(xx,yy); + + } + + } + theta+=(PI/8.0); + +// scale-=0.008; + + usleep(30000); + + frame++; + /* reset */ +// if (frame==128) { +// sleep(1); +// theta=0; +// scale=1.0; +// frame=0; +// } + + } + + return 0; +} +