A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd
at master 165 lines 3.2 kB view raw
1/* 2 * xrick/scroller.c 3 * 4 * Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). 5 * Copyright (C) 2008-2014 Pierluigi Vicinanza. 6 * All rights reserved. 7 * 8 * The use and distribution terms for this software are contained in the file 9 * named README, which can be found in the root of this distribution. By 10 * using this software in any fashion, you are agreeing to be bound by the 11 * terms of this license. 12 * 13 * You must not remove this notice, or any other, from this software. 14 */ 15 16#include "xrick/scroller.h" 17 18#include "xrick/game.h" 19#include "xrick/debug.h" 20#include "xrick/draw.h" 21#include "xrick/maps.h" 22#include "xrick/ents.h" 23 24/* 25 * Local variables 26 */ 27static U8 period; 28 29/* 30 * Scroll up 31 * 32 */ 33U8 34scroll_up(void) 35{ 36 U8 i, j; 37 static U8 n = 0; 38 39 /* last call: restore */ 40 if (n == 8) { 41 n = 0; 42 game_period = period; 43 return SCROLL_DONE; 44 } 45 46 /* first call: prepare */ 47 if (n == 0) { 48 period = game_period; 49 game_period = SCROLL_PERIOD; 50 } 51 52 /* translate map */ 53 for (i = MAP_ROW_SCRTOP; i < MAP_ROW_HBBOT; i++) 54 for (j = 0x00; j < 0x20; j++) 55 map_map[i][j] = map_map[i + 1][j]; 56 57 /* translate entities */ 58 for (i = 0; ent_ents[i].n != 0xFF; i++) { 59 if (ent_ents[i].n) { 60 ent_ents[i].ysave -= 8; 61 ent_ents[i].trig_y -= 8; 62 ent_ents[i].y -= 8; 63 if (ent_ents[i].y & 0x8000) { /* map coord. from 0x0000 to 0x0140 */ 64 IFDEBUG_SCROLLER( 65 sys_printf("xrick/scroller: entity %#04X is gone\n", i); 66 ); 67 ent_ents[i].n = 0; 68 } 69 } 70 } 71 72 /* display */ 73 draw_map(); 74 ent_draw(); 75 draw_drawStatus(); 76 map_frow++; 77 78 /* loop */ 79 if (n++ == 7) { 80 /* activate visible entities */ 81 ent_actvis(map_frow + MAP_ROW_HBTOP, map_frow + MAP_ROW_HBBOT); 82 83 /* prepare map */ 84 map_expand(); 85 86 /* display */ 87 draw_map(); 88 ent_draw(); 89 draw_drawStatus(); 90 } 91 92 game_rects = &draw_SCREENRECT; 93 94 return SCROLL_RUNNING; 95} 96 97/* 98 * Scroll down 99 * 100 */ 101U8 102scroll_down(void) 103{ 104 U8 i, j; 105 static U8 n = 0; 106 107 /* last call: restore */ 108 if (n == 8) { 109 n = 0; 110 game_period = period; 111 return SCROLL_DONE; 112 } 113 114 /* first call: prepare */ 115 if (n == 0) { 116 period = game_period; 117 game_period = SCROLL_PERIOD; 118 } 119 120 /* translate map */ 121 for (i = MAP_ROW_SCRBOT; i > MAP_ROW_HTTOP; i--) 122 for (j = 0x00; j < 0x20; j++) 123 map_map[i][j] = map_map[i - 1][j]; 124 125 /* translate entities */ 126 for (i = 0; ent_ents[i].n != 0xFF; i++) { 127 if (ent_ents[i].n) { 128 ent_ents[i].ysave += 8; 129 ent_ents[i].trig_y += 8; 130 ent_ents[i].y += 8; 131 if (ent_ents[i].y > 0x0140) { /* map coord. from 0x0000 to 0x0140 */ 132 IFDEBUG_SCROLLER( 133 sys_printf("xrick/scroller: entity %#04X is gone\n", i); 134 ); 135 ent_ents[i].n = 0; 136 } 137 } 138 } 139 140 /* display */ 141 draw_map(); 142 ent_draw(); 143 draw_drawStatus(); 144 map_frow--; 145 146 /* loop */ 147 if (n++ == 7) { 148 /* activate visible entities */ 149 ent_actvis(map_frow + MAP_ROW_HTTOP, map_frow + MAP_ROW_HTBOT); 150 151 /* prepare map */ 152 map_expand(); 153 154 /* display */ 155 draw_map(); 156 ent_draw(); 157 draw_drawStatus(); 158 } 159 160 game_rects = &draw_SCREENRECT; 161 162 return SCROLL_RUNNING; 163} 164 165/* eof */