選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

49 行
1.6KB

  1. /* Map view (R3). Tile bytes are translated through two 256-entry tables, so the
  2. ** marked/claimed flag bits need no special case when drawing. */
  3. #include <c64.h>
  4. #include "charset.h"
  5. #include "map.h"
  6. #include "view.h"
  7. #define SCREEN ((unsigned char *)0x0400)
  8. #define COLRAM ((unsigned char *)0xD800)
  9. unsigned char tile_glyph[256];
  10. unsigned char tile_color[256];
  11. void view_init(void)
  12. {
  13. unsigned i = 0;
  14. unsigned char t;
  15. do {
  16. t = (unsigned char)i;
  17. if (t & TILE_MARKED) {
  18. tile_glyph[i] = GLYPH_MARKED; tile_color[i] = COLOR_YELLOW;
  19. } else switch (t & TILE_TYPE) {
  20. case TILE_FLOOR: tile_glyph[i] = GLYPH_FLOOR; tile_color[i] = COLOR_GRAY1; break;
  21. case TILE_HARD: tile_glyph[i] = GLYPH_ROCK_HARD; tile_color[i] = COLOR_GRAY2; break;
  22. default: tile_glyph[i] = GLYPH_ROCK_SOFT; tile_color[i] = COLOR_BROWN; break;
  23. }
  24. } while (++i < 256u);
  25. }
  26. void draw_view(unsigned char vx, unsigned char vy)
  27. {
  28. unsigned char row, col, t;
  29. const unsigned char *src;
  30. unsigned char *scr = SCREEN + VIEW_TOP * 40u;
  31. unsigned char *clr = COLRAM + VIEW_TOP * 40u;
  32. for (row = 0; row < VIEW_H; ++row) {
  33. src = MAP_PTR(vx, vy + row);
  34. /* Written with pointer increments: the indexed form (scr[col] = tile_glyph[t])
  35. ** is miscompiled by cc65 V2.19 cc3c40c with -O (it indexes the table with the
  36. ** low byte of the screen address). M1.3 replaces this loop with assembly. */
  37. for (col = 0; col < VIEW_W; ++col) {
  38. t = *src++;
  39. *scr++ = tile_glyph[t];
  40. *clr++ = tile_color[t];
  41. }
  42. }
  43. }

Powered by TurnKey Linux.