1 /* coded by Ketmar // Vampire Avalon (psyc://ketmar.no-ip.org/~Ketmar)
2 * Understanding is not required. Only obedience.
4 * This program is free software. It comes without any warranty, to
5 * the extent permitted by applicable law. You can redistribute it
6 * and/or modify it under the terms of the Do What The Fuck You Want
7 * To Public License, Version 2, as published by Sam Hocevar. See
8 * http://sam.zoy.org/wtfpl/COPYING for more details. */
17 #include <sys/types.h>
21 #include "libvideo/video.h"
27 static unsigned char map
[32*64];
28 static unsigned char tiles
[6*16*4];
31 static const unsigned char ttypes
[16] = {
51 static void putTile (int trow
, int tnum
, int px
, int py
) {
54 a
= trow
*(6*16)+tnum
*2;
55 for (y
= 0; y
< 16; ++y
) {
56 for (x
= 0; x
< 2; ++x
) {
57 unsigned char b
= tnum
<3 ? tiles
[a
+x
] : 0;
58 for (d
= 7; d
>= 0; --d
, b
>>= 1) putPixel(px
+x
*8+d
, py
+y
, b
&0x01?7:0);
65 static void put2XTiles (unsigned char mapb
, int px
, int py
) {
66 int trow
= (mapb
>>4)&0x03;
67 int tnum
= ttypes
[mapb
&0x0f];
68 putTile(trow
, (tnum
>>4)&0x03, px
, py
);
69 putTile(trow
, tnum
&0x03, px
+16, py
);
73 static void drawMap (int mx
, int my
) {
77 for (dy
= 0; dy
< YTILES
; ++dy
) {
79 for (dx
= 0; dx
< XTILES
/2; ++dx
) {
80 put2XTiles(map
[my
*32+mx
], dx
*32, dy
*16);
81 sprintf(buf
, "%02X", map
[my
*32+mx
]);
82 drawOutlineText(dx
*32+2, dy
*16+2, buf
, 15, 0);
85 mx
= ox
; my
= (my
+1)%64;
90 int main (int argc
, char *argv
[]) {
94 static SDL_Event event
;
96 //static char fname[128];
97 //static char buf[1024];
100 if ((fl
= fopen("../gfx/tiles/blk_ded8_blobs.bin", "rb")) == NULL
) { fprintf(stderr
, "tiles?\n"); return 1; }
101 fread(tiles
, sizeof(tiles
), 1, fl
);
104 if ((fl
= fopen("../maps/map00.bin", "rb")) == NULL
) { fprintf(stderr
, "map?\n"); return 1; }
105 fread(map
, sizeof(map
), 1, fl
);
109 if (setVMode(2, 0)) { videoDeinit(); return 1; }
110 setCaption("enJine level renderer");
111 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY
, SDL_DEFAULT_REPEAT_INTERVAL
);
114 drawOutlineText(10, 10, "test!", 15, 3);
115 drawEllipse(8, 8, 8+6*5+4, 8+8+4, 10);
116 drawCircle(45, 70, 42, 5);
117 drawIconById(ICON_ID_PENTA, 80, 90);
118 drawFilledEllipse(8+40, 8+40, 8+6*5+4+40, 8+8+4+40, 11);
119 drawFilledCircle(120, 150, 42, 5);
120 drawLine(50, 50, 100, 60, 7);
122 putPixel(101, 61, 3);
125 drawCursor(28, 28, 1);
129 drawBar(0, 0, SCREEN_WIDTH
, SCREEN_HEIGHT
, 0);
134 while (SDL_WaitEvent(&event
)) {
135 switch (event
.type
) {
136 case SDL_QUIT
: goto quit
;
137 case SDL_VIDEOEXPOSE
: repaintScreen(); break;
139 //ctrlDown = event.key.keysym.mod&KMOD_CTRL;
140 switch (event
.key
.keysym
.sym
) {
141 case SDLK_ESCAPE
: case SDLK_q
: goto quit
;
142 case SDLK_LEFT
: if (mapX
> 0) --mapX
; goto repaint
;
143 case SDLK_RIGHT
: if (mapX
< 31) ++mapX
; goto repaint
;
144 case SDLK_UP
: if (mapY
> 0) --mapY
; goto repaint
;
145 case SDLK_DOWN
: if (mapY
< 63) ++mapY
; goto repaint
;